[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: OOP sortof
- From: Philippe Lhoste <PhiLho@...>
- Date: Sat, 01 Jan 2011 14:33:35 +0100
On 30/12/2010 08:45, steve donovan wrote:
On Thu, Dec 30, 2010 at 9:20 AM, Dirk Laurie<email@example.com> wrote:
Just why must x and y be private if you plan to provide read and
write access to them?
Having had this moment with some Java I was charged with sorting
out, I must agree. The classic answer is that a.x confuses
implementation with access, but _if_ a.x needs to invoke some code at
some later date, well then there's always the property pattern.
 in any case with Java the IDEs are so good that you can find all
the references to a field and correct them very quickly. Technology
should trump ideology.
Well, it is harder and more annoying when that's a library that changes
that: it means changing all the projects depending on it. Even on a
closed project, management can frown upon making a change list of
hundred of files just replacing variable access with a getter or setter.
Scala (to remain in the JVM realm) resolved that quite elegantly: just
leave the variables in the open, and should you add code around access
(get or set), you can do it without disturbing calling code.
That's indeed a point that a modern language should address elegantly.
-- (near) Paris -- France
-- -- -- -- -- -- -- -- -- -- -- -- -- --