in reply to Re: Psychic Disconnect and Object Systems
in thread Psychic Disconnect and Object Systems
This is, in my opinion as a result of my personal experience of using OO & of working with others OO, completely the wrong way to approach the problem.I could not agree more. I've seen discussions on automatically generating reader and writer methods for state variables (in which languages I don't recall), and I join the chorus of those pointing out that this probably isn't a good thing to be doing. It just encourages making the state not encapsulated, and is no different t han just declaring all the fields public.
The right way--I know, I know. bear with me.--is to define the methods first. Ask yourself not: what do these objects contain? But rather: what do these objects need to do? ... The right way--again--is to write the code that will use the objects first.For sure! I start with use-cases and from there describe the object user's view of the object. I've written full documentation before finalizing the underlying design of just how it manages to do all that.
It sounds like we are on the same page. So, how would you use Moose today? Certainly I can start by writing the methods, and plan that any internal state that I need to implement them are indeed internal implementation details. So how do you declare your has's to create per-instance storage, for internal use only?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Psychic Disconnect and Object Systems
by BrowserUk (Patriarch) on Apr 18, 2011 at 02:35 UTC |