lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 30/12/2010 08:45, steve donovan wrote:
On Thu, Dec 30, 2010 at 9:20 AM, Dirk Laurie<dpl@sun.ac.za>  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[2] 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.[1]

[2] 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.

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --