Kenneth Ismert
kismert at sbcglobal.net
Tue Jun 13 09:05:28 CDT 2006
OK, lets see... Lambert is correct in that using public variables to create class properties is 'bad practice', or at least non-standard. Drew is correct in that because it can be done in the language, it is 'right', or at least allowable. But the interesting thing to me is no one talks about what is missing in VB objects: * No true class-level variables. All member variables of a class are instance variables. Class variables would eliminate most of the need for globals in VB. * No true constructor. You'd like to create objects like this, but you can't: Set Obj = New clsPerson("Ken", "123 Any St", 789) * No true singleton object. You can simulate it using modules with properties, or public object variables, but neither approach is a complete solution. * No inheritance model, whether it be single, multiple, or mixin. Finally, if you want compact and correct property declarations, look at this Ruby example: Class MyClass attr_accessor :name, :address, :emplID End This creates the instance variables, getters and setters for the three named properties, all in one line. I bring Ruby up because, in arguements over what are essentially limitations of a language, it is valid to suggest alternatives. -Ken