Konstantin Iignatyev wrote:

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;


True, but remember that you would also need a different syntax for interfaces. Which is something that Delphi lacked.

property hasChildren boolean; read; [write;]

Otherwise you still have to make the getter and setter methods like you had to do in Delphi.

BTW I use 'I' for interfaces often too, because besides using the -able kind of interfaces, I also use them just to design parts of my application without having to think about the implementation. In that case I would have to keep postfixing my classes with Impl when I implement the interfaces.
So I prefer IExample for the interface and Example for the class, instead of Example and ExampleImpl.
As a developer I often find it very useful to know if I am dealing with an interface or class.


Oh and curly braces have to go on the next line of course ;)
I like balance.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to