Design Principals


Object Oriented Design

Java and JEE are designed around Object Oriented Programming. Programs are built of classes (complex data types) and objects (instances of classes). A class wraps both data and behavior. There are three pillars of object oriented programs:

  • Encapsulation: Details of data and behavior are hidden within the class. From the outside, a class can only be observed or manipulated through a narrowly defined interface.
    Encapsulation increases modularity and decouples the users of a class from the implementation.
  • Inheritance: Classes may be derived from one or more other classes. The derived classes take on some or all of the data and behavior of their parents. Java supports only single-inheritance, meaning that each class extends from at most one other class.
    Inheritance increases code reuse, since specific classes inherit code from the parent classes.
  • Polymorphism: A variable or property of one specified type may actually refer to objects of several different types. This can be accomplished through inheritance, since derived classes can be assigned to variables of a parent class. In Java, polymorphism can also be accomplished by a class implementing different “interfaces”. An interface is a type definition without any implementation. Although Java is a single-inheritance language, the interfaces allow a class to have several disparate data types.
    Polymorphism allows classes to be defined in a more abstract manner. The use of interfaces decouple class users from implementation.


Layered Design

A layered decomposition splits a system based on higher and lower levels of abstraction. Lower layers deal with low-level details of implementation. Higher layers deal with more abstract and deal with business level requirements. A layer may make use of other layers below it, but may not depend on higher layers. Ideally, each layer only makes reference to the one layer below it.
Layers should have narrow abstract interfaces, so they may be replaced with different implementations.
Graphically, a layered design is usually drawn as a series of horizontal slices stacked on top of each other.


Tiered Design

A tiered decomposition splits a system based on stages of processing. A client/server architecture is considered a two-tiered system. A JEE architecture with web server, application server, and database is considered a three-tier system. Systems of n-tiers may be designed.
Each tier hangs on an abstract framework, which may be swapped out. Components within a tier have abstract interfaces, so they can be replaced with different implementations. Each tier may be subject to a layered decomposition.
Graphically, tiers are usually drawn vertical stripes, progressing from left to right.


Separation of Concerns

Computer systems are often broken into separate concerns or features that overlap as little as possible. A layered decomposition separates concerns of different abstractions over data and processing. A tiered decomposition separates concerns business processing steps.

The idea of dividing systems in multiple ways is illustrated by Sun’s Suntone architecture methodology, which splits a design along three dimensions: layers, tiers, and system qualities.

%d bloggers like this: