On May 9, 2012, at 9:21 AM, MB Software Solutions, LLC wrote: > I recently saw (both in our stuff here and in Ken Getz' video for this > training) that they had all these get/set lines and I wondered why? > (And I think Stephen posted such too, iirc) I vaguely recall learning > that VB6 classes had to have _Get and _Set methods to their properties. > Guess that continues the tradition.
But that's exactly the sort of inelegance I mean. I'll wager that 99.9% of code created does nothing special with these getter/setter methods; they simply get/set the value unchanged. So in order to handle the few cases where code is needed, you are stuck with all this useless baggage. Contrast that with Python, where you have simple attributes with no special code needed to get/set. class Foo(object): def __init__(self): self.bar = "" f = Foo() f.bar = "ed" print f.bar -> 'ed' Now let's say that you actually need to make 'bar' into a property with getter/setter methods. No problem; just change the class: class Foo(object): def __init__(self): self._bar = "" def _getBar(self): return self._bar def _setBar(self, val): self._bar = val.upper() bar = property(_getBar, _setBar) f = Foo() f.bar = "ed" print f.bar -> 'ED' The point being that for the vast majority of object attributes, no such manipulation is needed, so the code is simple. When more complex behavior is needed, then and *only* then do you need to write more complex code. -- Ed Leafe _______________________________________________ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/87f40ae0-89b6-422e-8e3c-cd84e3e3f...@leafe.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.