The Source for Java Technology Collaboration
User: Password:



Start New Message Post a Reply

Subject:  superfluous getters and setters
Date:  2007-01-16 09:45:51
From:  weberjn
Response to: Keep the language simple


getters and setters are kind of holy cow. But if almost all do nothing but set or get a value, why not directly access the attribute?
Yes, I know the all-customers-directly-taking-money-from-the-bank-safe argument, but if the bank clerk blindly does what the customers want, she's superfluous and the customer might as well take money from the safe himself. Same goes for setters like

public void setXX(XX xx)
{
this.xx = xx;
}

But if a setter really does something useful, it indeed should be a distinct method and not a C# like setter.

 Feed java.net RSS Feeds