Definitions

Value-based classes

Value-based Classes Some classes, such as java.util.Optional and java.time.LocalDateTime, are value-based. Instances of a value-based class: are final and immutable (though may contain references to mutable objects); have implementations of equals, hashCode, and toString which are computed solely from the instance’s state and not from its identity or the state of any other object or variable; make no use of identity-sensitive operations such as reference equality (==) between instances, identity hash code of instances, or synchronization on an instances’s intrinsic lock; are considered equal solely based on equals(), not based on reference equality (==); do not have accessible constructors, but are instead instantiated through factory methods which make no committment as to the identity of returned instances; are freely substitutable when equal, meaning that interchanging any two instances x and y that are equal according to equals() in any computation or method invocation should produce no visible change in behavior.

A program may produce unpredictable results if it attempts to distinguish two references to equal values of a value-based class, whether directly via reference equality or indirectly via an appeal to synchronization, identity hashing, serialization, or any other identity-sensitive mechanism. Use of such identity-sensitive operations on instances of value-based classes may have unpredictable effects and should be avoided.

CRC (Class-Responsibility-Collaborator) cards

A CRC Model is a collection of cards (usually standard index cards or larger) that are divided into three sections.

  1. Class
  2. Responsibility
  3. Collaborator

The back of the CRC card is often used for a more detailed description of the class. Along with any other notes captured during the CRC session. Many times these include the actual attributes of the class.

Class

A Class represents a collection of similar objects.

Responsibility

A Responsibility is anything that the class knows or does.

Collaborator

A Collaborator is another class that is used to get information for, or perform actions for the class at hand