Design Concepts  «Prev  

Generalization

1) Vehicle class
1) The vehicle class defines properties that boats, trucks and planes have in common on such as manufacturer, model, and the abilities to accelerate and decelerate

2) Boat, truck, and plane classes
2) The boat, truck and plane classes contain only the additional properties that distinguish them from the other two types of vehicles. For example, each type of vehicle has a different method of acceleration, and each type operates in a different medium (air, land, or water).

Unified Software Development Process
Use composition when you have a class that has a set of other objects, in any quantity. Use generalization when you have a class that shares common properties with a set of objects, but can also have different properties or behavior. For example, a Car has components like engine, wheels, seats, etc. This is a composition relationship. But a Vehicle is a generalization of a Car, because you can have other types of Vehicles with different properties, like a Truck. Car and Truck are derived classes of Vehicle.

Object-oriented programming has two main objectives:
  1. to build highly cohesive classes and
  2. to maintain loose coupling between those classes.
High-cohesion means well-structured classes and loose coupling means more flexible, extensible software."
Cohesive means that a certain class performs a set of closely related actions. A lack of cohesion, on the other hand, means that a class is performing several unrelated tasks. Though lack of cohesion may never have an impact on the overall functionality of a particular class or of the application itself the application software will eventually become unmanageable as more and more behaviours become scattered and end up in wrong places."