On 8/4/05, Frank W. Zammetti <[EMAIL PROTECTED]> wrote: > Michael Jouravlev wrote: > > If getters and setters do nothing more than simply read field or set > > field, then they are evil, you do not need Rod Johnson to tell you > > that ;) > > I think I may... why exactly is this evil? > > We're talking, at the most basic level, about a construct that > encapsulates properties of a modeled object behind a (theoretically) > well-defined interface. If you do it right you can change details of > the implementation without altering client classes. > > This is all nothing anyone reading this doesn't know of course :) > > If you mean a class who's accessors and mutators simply do: > > return this.field; > > and > > this.field = field; > > ...then, while I'm not sure I would call it "evil", certainly that isn't > using the concept to its full potential.
Yes, this is exactly what I mean. This is evil. I take that you have not used Object Pascal? It is not just for kiddies. Check this article, for example: http://www.informit.com/articles/printerfriendly.asp?p=26862 === cut here === TCustomEdit = class(TWinControl) private FMaxLength: Integer; protected procedure SetMaxLength(Value: Integer); ... published property MaxLength: Integer read FMaxLength write SetMaxLength default 0; ... end; === cut here === Here TCustomEdit is a component, and MaxLength is a property (it does not have to be published, but if it is, then it automatically shows in IDE property editor). You can define either only getter, or only setter or both. You can map private field directly or use method. You can set default value as well. Indexed properties are supported too. Java 5 got annotations and generics, but still does not have properties, that are easy to use, and could be set from IDE. Oh, right, original Javabean specification has something about that, but getters and setters is all that really left from the spec. Probably because it was not simple enough. Considering the commenting style and how javadoc assign comments to methods and groups them in the help file, one simple Java property is at least half a screen of garbage. Instead I would prefer to have: property MaxLength: Integer read FMaxLength write SetMaxLength default 0; Is this so hard to implement in the compiler? > Why anyone would call that evil I don't understand. Care to convince me > it is? :) See above ;-) Michael. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]