There are several oo mechanisms that can overcome this, including inheritance and friendship. However, if, with a full understanding of oo techniques, a 'clean' OO implementation still doesn't fit the requirement then I would recommend not using OO rather than being forced from the outset to abuse it.
| [reply] |
I read the other OO articles linked in this thread about not using accessors. In my opinion there are many benefits of using an OO approach to some parts of a program and not for others. I'd rather abuse OO and have a bastardized OO/procedural program that works and is done in a reasonable amount of time than spend spend years coming up with some other paradigm just so I can get away from using accessors.
I did give a clear example of where I thought using some accessors was okay, and I was hoping for a response from you suggesting an alternate way of solving the problem. Any chance of this?
| [reply] |
Sorry not have replied sooner - I am not very regularly on this site and have a busy time in general.
My latest approach is to reduce this to just three methods, a define method that recursively sets anything anywhere in a multilevel hash or hash of arrays or any combination to which there is a blessed reference to the top; a recursive get method that is insensitive to reference types and similarly a prune method that deletes anywhere in the tree. But I am still checking whether the prune method needs to collect its own garbage or whether 'delete' is recursive before I would publish examples.
| [reply] |