Please enable JavaScript.
Coggle requires JavaScript to display documents.
Chapter 4 Object Oriented Paradigm - Coggle Diagram
Chapter 4 Object Oriented Paradigm
4.1 overview
Encapsulation
: Often called information hiding, the purpose of encapsulation is to separate interface from implementation. By hiding the implementation details .
Inheritance
: Developers can define new classes that derive from existing base classes, thus inheriting the base classes' interface elements (attributes and operations) and implementation of operations. Inheritance allows software reuse, hence improving the effectiveness of software development.
Polymorphism
: Polymorphism refers to the ability of an object tobehave differently and assume different forms based on its inheritance hierarchy. Polymorphism includes vertical override operations between parent classes and derived classes, and horizontal overloading operations within the same class.
4.2 Introducing the Object-Oriented Paradigm
A class groups together related data and their operations.
An object is an
instance of a class.
it generally consists of three elements: a class name, a list
of attributes, and a list of operations
4.2.2 Relationships
The dynamic (behavioral) specification describes the relationships among objects, e.g., how objects of the system accomplish the required functionalities via message exchanging
At the static (logical) level,the relationships among classes are described. Classes may be derived fromother classes by composition and by inheritance. Classes may have other consistency requirements that are similar to those in relational database theory.
4.2.2.1Composition,
Composition represents the whole/part relationship between classes
This restriction usually is enforced by the constructor and destructor operations of a class. For example, when an online order instance is destructed, all of its items are destructed. In UML, a composition relationship is represented using a solid diamond arrowhead
4.2.2.2Aggregation
In UML, aggregation is represented using a hollow diamond arrowhead.
Whereas in a composition relationship, the description of an object means that all of its attributes must be de-allocated from memory. In an aggregation relationship
these attributes may instead be reused by other objects.
4.2.2.3 Association
In UML, an association is represented by a solid line and it has the following parts: name of the association, end type at each end of the association link, and multiplicity at each end.
4.2.2.4 Inheritanc
To prevent repeatedly writing the same code for similar classes, OO provides the inheritance mechanism. When class A is derived from class B, class A inherits all attributes and operations of class B unless otherwise specified
In UML, the inheritance relationship is represented using a line with a closed arrowhead.
If the line is dashed, it is a realization relationship.
4.2.2.5 Composition vs. Inheritance
Use the inheritance relationship only when the derived class "is-a" base class. For example, a HouseOwner is a Person; however, a HouseOwner is not a House. Thus, the HouseOwner class should not inherit from the House class.
Composition (or aggregation) can be used to model the "has-a" relationship among classes. For example, it is natural to include an attribute referencing to House in the HouseOwner class, because a HouseOwner has a House.
4.3 00 Analysis
Outcome
: Requirement specification
Initial logic structure of the system
Two UML
tools available Use case diagram Analysis class diagram
Step 1: Design of Use Case Diagram
Use Case is a way that a user accesses the system
User can be either real human user, or components of a bigger picture
Use Case Diagram depicts their relationship
Step 2: Analysis Class Diagram
Analysis Class Diagram also called “Concepts Class Diagram”
Describes Key classes of a system Their relationship
Abstraction of the system Not every class in analysis class diagram is implemented
The diagram does not include all classes in the real implementation
4.4 OO Design
4.4.1 Step 1: Identify Classes—CRC Card
4.4.2 Step 2: Construct an Interaction Diagram
4.4.3 Step 3: Build a State Machine Diagram
4.4.4 Step 4: Class Specification
4.5 Design Principles
4.5.1 Principle of Decoupling
4.5.2 Ensuring Cohesion
4.5.3 Open-Closed Principle