2010/12/18 Benoît Minisini <gam...@users.sourceforge.net>: >> >> Hi Benoît. I know that property exists, but: >> >> >> 1) In some situations (rare I admit, but real) could be necessary >> write a setter and unnecessary write a getter, but properties are >> both: write and read or only read, there's no option to automatically >> write only the code for property write > > For me, a write-only property is a non-sense. Just use a normal method then.
I want to write some linux commands wrappers classes. I don't want use EXEC directly in my applications to reduce the syntax complexity. Then, I just need write static methods to do that, and I will use normal method to do that "just because if I use properties I will need to write READ method". >> 2) Properties, forces to have more code > > Just one line to declare the property. Just one line to each private variable that belong to the interface class. That can be 5, 10 or 15 additional lines to do the same thing, more the obligation to write READ methods in situations that it's unnecessary. >> 3) Properties, forces to use the dot notation or to write getters and >> setter by hand > > No, both. And this is better. It allows to underline that normally a property > is a light O(1) process (just reading something somewhere, or writing and > updating something somewhere), whereas a method underlines a more complex and > heavier algorithm. I mean that properties use an assignment notation (I don't know why I repeat the error to say "dot notation"). And many programmers could be more comfortable using a method notation. In reference to the computational complexity: the syntax for the _READ _WRITE methods is the usual and Gambas relates this methods with the property by it's name, so the same thing should be done to allow getter and setters methods favoring them with the special treatment that you explain. And the minor computational complexity is a good reason for use properties than just will be Write, instead a normal method. >> 4) Write and Read methods are generated while code is being write. I >> would appreciate can write sketch code for a class without Write/Read >> or getters/setters methods, and when I finished the class design can >> generate that code automatically by one step. > > When you enter the property declaration, the getter and the eventual setter > are written automatically. But they do nothing, so what is the problem? The problem is that when I'm writing a sketch of the class, what I do initially, is just to write stub methods, I declare the needed variables to support these behaviors, and the message protocol, I mean methods and properties that constitute the class interfaz. In this way I can focus in the design. So, to have 20, 30 or more additional lines of code for properties, is something that I want to avoid, because there become in visual garbage until the moment when there are really useful. > Setter and getters were invented only for languages that do not have > properties. :-) At the end, the principal subject is about the possibility to have an automatic code generator for properties o getter and setter (in spanish "o" is or, but it is inclusive) that can be called just one time, when it is really necessary. What about to do "Make code pretty" option customizable? Saluti. -- Fabián Flores Vadell www.comoprogramarcongambas.blogspot.com www.speedbooksargentina.blogspot.com ------------------------------------------------------------------------------ Lotusphere 2011 Register now for Lotusphere 2011 and learn how to connect the dots, take your collaborative environment to the next level, and enter the era of Social Business. http://p.sf.net/sfu/lotusphere-d2d _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user