Let's say you implement an interface like:
public interface Example {
InputStream getThatContent();
}
In this case there is no property, and the implementation may also have side effects (it can open a new InputStream).
This is happening also in other API, like JDBC:
public static Connection getConnection(String url,
String user,
String password)
throws SQLException
The method starts with get, and actually creates a new connection, so I'm wondering, is the getter/setter method naming convention valid only in POJO classes? Or in all Java classes?
createConnection()
, since that's what it actually does?AtomicInteger.getAndIncrement()
starts withget
and obviously mutates state...