WebSeitz/wikilog
z2004-10-27- When To Use Classes
is a Product Manager/CTO with a track-record of bringing a business perspective to building agile product-development teams for start-ups, and is seeking a senior role in an entrepreneurial organization building disruptive Internet-driven products.

(backlinks off) (map off)
(search off)
last edited by BillSeitz on Oct 15, 2008 7:13 am

[Kent S Johnson] on when to use classes (in ). ( Programming) When: Several functions share state... More than one copy of the same state variables... To extend the behavior of an existing class... A callback function needs persistent state.

Related: column by discussing use of public variables. A class can play two roles in . The first is as an object, in which case we usually make the variables private and provide a few getters and setters for the most important variables. The other role a class can play is as a , in which case we make the variables public and provide no methods... A class that has getters and setters but no other methods isn't an object at all-it's just a data structure that someone has wasted a lot of time and effort trying to encapsulate. That encapsulation buys nothing in the end. Data structures, by definition, aren't encapsulated... Objects are encapsulated because they contain methods that change their variables. They don't have a lot of getters and setters, because the data in an object remains hidden for the most part.


 




Bill Seitz, fluxent at gmail dot com, Weblog