at 2004-12-15
in General
by friebe
(5 comments)
Via "PHP is not Python is not Java":
They are a waste of CPU time, but more important, they are a waste of programmer time. Not just for the people writing the code and tests, but for the people who have to read and understand them as well.
I tend to disagree:
- It is fairly easy to understand getters and setters: They follow the naming rule of getSomething, setSomething (and maybe isSomething, hasSomething and addSomething) for accessing the property something.
- It is easy to write getters and setters: In the .nedit-configuration file we have in our CVS here, for instance, we have a shortcut that generates them from member variables
- On: They waste CPU time: Agreed - function (and method) calls are expensive in PHP - but CPU time is not the only factor to be considered when developing an application: Readability (which the verbosity adds) and maintainability (the behaviour of a setter can be changed easily without breaking the API) are the non-plus-ultra in importance when it comes to keeping an application running. And getters and setters are readable
- Design by contract: Getters and setters can be part of an interface whereas members cannot.
|
Subscribe
You can subscribe to the XP framework's news by using RSS syndication.
CategoriesNews General PHP5 Announcements RFCs Further reading Examples Editorial EASC Experiments Unittests Databases
RelatedFind related articles by a search for «Getters».
|