The best approach to the field is in Delphi (Object Pascal)
property hasChildren boolean ; read ifThereAreAny; [write setHasChildrenAndNotifyWorld; ]
so we start with a public field and if necessity arises the field might be redeclared as property and made read-only or writable (if write function is declared). Advantages:
- no ugly getters and setters for 99% of use cases;
- freedom to use most appropriate function names like updateXXX of hasXXX;
- conversion from field to property does not affect rest of code at all;
Sweeet!
Justin Morgan wrote:
Erik Hatcher writes:
Hungarian notation does have its uses.Bah! Not in Java it doesn't.
I write: Agreed. One of the great things about Java is that it eliminates the need for Hungarian notation.
Even in plain old Java, though, we still have Hungarian notation. "Get and set" anyone? How often do you write code like this:
String getFoo() { return foo; }
Does it ever annoy you? Now, you're going to say "yes but that makes it easier in the future if you make it multithreaded or add validation." I argue the language could have handled this more gracefully. Take a look at C#'s object properties for a marginal improvement over this pattern.
Sorry to get off-topic.
-Justin
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Thanks,
Konstantin Ignatyev
http://www.kgionline.com
PS: If this is a typical day on planet earth, humans will add fifteen million tons of carbon to the atmosphere, destroy 115 square miles of tropical rainforest, create seventy-two miles of desert, eliminate between forty to one hundred species, erode seventy-one million tons of topsoil, add 2.700 tons of CFCs to the stratosphere, and increase their population by 263.000
Bowers, C.A. The Culture of Denial: Why the Environmental Movement Needs a Strategy for Reforming Universities and Public Schools. New York: State University of New York Press, 1997: (4) (5) (p.206)
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
