Partial class implementation

janderson askme at me.com
Fri Jul 20 09:47:03 PDT 2007


Robert Fraser wrote:
> Hi Joel,
> 
> Indeed, my company style guide requires that getters/setters exist for all variables, most of which are private and used internally by other methods of the class. These and the constructors are the only methods allowed to refer to the variables directly. Personally, I find this going _way_ overboard (plus, the class internals start to get out of sync if legacy properties are supported for non-existent fields), but it's actually saved me once or twice.
> 

Personally I hate writing tons of getter setters.  Its like smashing my 
head against concrete.  I hate having to write 5 lines simply to add a 
new variable.  Then if anything changes you've got 5 more lines per 
getter/setter to maintain.  So I try to keep the number of setters low, 
most data private and have actually useful functions for managing them 
instead.  Sometimes its possible to use a strut component (as a param to 
a setter or getter) to minimize getters setters.  Many times I return a 
object which can be modified.  That object has its own set of 
validations.  Although I can see setter/getter they add superior 
interface benefits.

I think programming is a balancing act in every reguard.

-Joel



More information about the Digitalmars-d mailing list