Names Should Describe Side Effects

''Don't use a simple verb to describe something that does more than a simple action''

public ObjectOutputStream getOos() throws IOException {
  if (m_oos == null) {
    m_oos = new ObjectOutputStream(m_socket.getOutputStream());
  }
  return m_oos;
}

Here the function name getOos doesn't include the fact that it creates a new oos if it is null. A better name is createOrReturnOos.



bj 2019-09-22