[Newbies] Are setters a good idea?
andy.burnett at knowinnovation.com
Sat Sep 27 18:40:37 UTC 2008
I read somewhere - can't remember where - that setters are considered evil.
The argument was that in the real world you can't suddenly change the colour
of a car, just by settings its colour value. Instead, you have to perform
some action, e.g. sprayPaintCar: aColour. Therefore in the OO world, one
should tackle problems in the same way, i.e. if you want to change the value
of an instance variable, you have to call some sort of action method, that
makes sense in the context of the object.
Without wishing to send startHolyWar to BeginnersList, do any of the
experienced developers work this way, or is it just a theoretical position?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners