Cohesion
Cohesion refers to an entity’s level of focus. For example,
a Swiss Army knife
is a low cohesion entity because it can do multiple things, but it can’t do them
very well. A multi-tool could never match the productivity
of a toolbox filled
with highly cohesive tools. In software applications, cohesive components are
more robust and easier to test.
Object-Oriented Programming
(Part I)
Classes & Objects
Java objects are built from a blueprint called a class. A class defines the name
of an object, what type of state the object
has in the form of fields, and what kind
of behavior the object has in the form of methods.
When an object is instantiated with the new keyword, the
class file and all of its
superclasses are loaded into the JVM by the system class loader. After the one-
time initialization of the class, the object is initialized
by invoking a special
method called a constructor. A constructor performs initialization logic after
recursively invoking all of the constructors of its superclasses. Superclasses must
be initialized before subclasses in case a child object
relies on functionality from
a parent.