Say I got an Employee class that has a hire date data member. This member 开发者_如何学运维only get set one time only and it is constant too. So it'll get initialised when the object is created.
If I want the class to have a method that returns the hire date, what's better:
getHireDate();
Or just:
hireDate();
Am I thinking too much :D ?
Just
getHireDate();
is fine. It doesn't need a 'set' method to be proper OO.
Edit: if you haven't yet, read some Java Coding Style docs... they're simple enough, and standard coding conventions make everybody' life easier. I just found this: Java Programming Style Guidelines. Good reading.
精彩评论