I am writing some immutable types in Java and wondering what to call access methods. The Java Bean specification says accessors must be getX or isX, but since the fields are final, there is no setter, and the fields are more like attributes than properties.
There, I would prefer to call getter methods like:
public T x()
but not
public T getX()
Pay attention to an example:
public int java.lang.String#length()
(which could have been indicated so early in the history of Java, so the agreement is where they are not already).
Immutable objects expose the means for creating modified versions of themselves using methods that I tried to name as a verb, and not MyObject MyObject#setX(), this should limit the risk of the user calling setX () and think that the object has changed. So: MyObject MyObject#shine(newShineLevel).
. , Rectangle.setUpperLeft()? Rectangle.adjustUpperLeft , .
, , , , Java.