Professional Documents
Culture Documents
Lecture # 3
Dependency Inheritance
Dependency
Multiplicity
Multiplicity
Polymorphism Polymorphism
Encapsulation Encapsulation
Interface
Interface
Package
Package
Object
Oriented
Analysis &
Design
Introduction to
Object
Orientation
Introduction to Objects
Class
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Object Orientation Oriented
Analysis &
Design
Introduction to
Object
Orientation
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
OOA/D Oriented
Analysis &
Design
Package
Object
Oriented
Analysis &
Design
Introduction to
Object
Orientation
Objects
Objects Class
Attributes
Operations
Associations
Aggregation
Composition
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Definition of an object Oriented
Analysis &
Design
I Object: Introduction to
Object
I Objects directly relate to real-world ‘entities’. Orientation
I An object has identity, state & behaviour. Objects
I Identity: the property of an object that distinguishes it Class
from other objects Attributes
Operations
I State: describes the data stored in the object
Associations
I Behaviour: describes the methods in the object’s Aggregation
interface by which the object can be used Composition
Encapsulation
Interface
Package
Object
Definition of an object Oriented
Analysis &
Design
I Behaviour: Inheritance
I Dogs have behaviour (barking, fetching, wagging tail) Dependency
I Bicycles also have behaviour (changing gear, changing Multiplicity
pedal cadence, applying brakes) Polymorphism
Encapsulation
Interface
Package
Object
Identifying & using objects’ states Oriented
Analysis &
Design
Inheritance
I if the bicycle only has 6 gears, a method to change
Dependency
gears could reject any value that is less than 1 or
Multiplicity
greater than 6.
Polymorphism
Encapsulation
Interface
Package
Object
Advantages of using objects Oriented
Analysis &
Design
Introduction to
Object
Orientation
Objects
Class Class
Attributes
Operations
Associations
Aggregation
Composition
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
What is a Class? Oriented
Analysis &
Design
Introduction to
I Many individual objects can be of the same kind: Object
Orientation
I There may be thousands of other bicycles in existence, Objects
all of the same make and model.
Class
I Each bicycle was built from the same set of blueprints Attributes
and therefore contains the same components. Operations
Associations
I In object-oriented terms, we say that your bicycle is an Aggregation
Inheritance
I A class is the blueprint from which individual objects Dependency
are created. Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Class example in Java Oriented
Analysis &
Design
Introduction to
Object
Orientation
Objects
Class
I The fields cadence, speed, Attributes
and gear represent the Operations
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Class example in Java Oriented
Analysis &
Design
Introduction to
Object
Orientation
I Not a complete
Objects
application; it’s just
the blueprint for Class
Attributes
bicycles that might be Operations
used in an application. Associations
The responsibility of Aggregation
Polymorphism
Encapsulation
Interface
Package
Object
Class notation Oriented
Analysis &
Design
Introduction to
Object
Orientation
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
What is an attribute? Oriented
Analysis &
Design
Introduction to
Object
I An element of data that helps to describe an object. Orientation
Objects
I Attribute types may be restricted by a programming
Class
language. Attributes
Operations
I A class that includes many attributes may be Associations
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
What is an operation? Oriented
Analysis &
Design
Introduction to
I It helps to specify the behaviour of a class (object). Object
Orientation
I Can use the syntax of a programming language. Objects
I Specify the visibility of each operation: Class
Attributes
I public (+); Operations
I private (-); Associations
Polymorphism
Encapsulation
Interface
Package
Object
Class Associations Oriented
Analysis &
Design
Introduction to
Object
Orientation
Objects
I Classes (objects) must interact with each other so that Class
a piece of software can do something. Attributes
Operations
I How do classes/objects therefore interact? Associations
Aggregation
I How are associations modelled? Composition
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Class Associations Oriented
Analysis &
Design
Objects
association can be adorned with role names, ownership
Class
indicators, multiplicity, visibility, and other properties. Attributes
Inheritance
I Bi-directional and uni-directional associations are the
Dependency
most common ones.
Multiplicity
I For instance, a flight class is associated with a plane
Polymorphism
class bi-directionally. Association represents the static
Encapsulation
relationship shared among the objects of two classes.
Interface
Example: “department offers courses”, is an association
relation Package
Object
Aggregation Oriented
Analysis &
Design
Introduction to
Object
Orientation
I Whole/Part relationship. Objects
I ‘Smaller’ classes are parts of ‘larger’ classes. Class
Attributes
I Objects belonging to an aggregate can belong to more Operations
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Aggregation Oriented
Analysis &
Design
Interface
I if the container is destroyed, its contents are not. Package
Object
Aggregation Notation Oriented
Analysis &
Design
Introduction to
Object
Orientation
Objects
Class
Attributes
Operations
Associations
Aggregation
Composition
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Composition Oriented
Analysis &
Design
Introduction to
Object
Orientation
Objects
I A stronger form of aggregation.
Class
I Objects may only be part of one composite at a time. Attributes
Operations
I The composite object has sole responsibility for the Associations
Aggregation
creation and destruction of all of its parts. Composition
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Composition Oriented
Analysis &
Design
Introduction to
Object
I Composition is a stronger variant of the “owns a” or Orientation
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Composition Notation Oriented
Analysis &
Design
Introduction to
Object
Orientation
Objects
Class
Attributes
Operations
Associations
Aggregation
Composition
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Aggregation vs. Composition Oriented
Analysis &
Design
I When attempting to represent real-world whole-part
relationships,
I e.g., an engine is a part of a car, the composition
relationship is most appropriate. Introduction to
Object
I However, when representing a software or database Orientation
relationship, Objects
Class
I e.g., car model engine ENG01 is part of a car model Attributes
CM01, an aggregation relationship is best, as the Operations
Introduction to
Object
Orientation
Objects
Inheritance Class
Attributes
Operations
Associations
Aggregation
Composition
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Inheritance (Generalisation) Oriented
Analysis &
Design
Multiplicity
I Each subclass is a specialised version of its superclass.
Polymorphism
I Within UML, generalisation is the preferred term. Encapsulation
Interface
Package
Object
Inheritance (Generalisation) Oriented
Analysis &
Design
Interface
Package
Object
Generalisation Notation Oriented
Analysis &
Design
Introduction to
Object
Orientation
Objects
Class
Attributes
Operations
Associations
Aggregation
Composition
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Oriented
Analysis &
Design
Introduction to
Object
Orientation
Objects
Dependency Class
Attributes
Operations
Associations
Aggregation
Composition
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Dependency Oriented
Analysis &
Design
Introduction to
Object
I Weaker form of relationship which indicates that one Orientation
Objects
class depends on another.
Class
I One class depends on another if the latter is a Attributes
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Oriented
Analysis &
Design
Introduction to
Object
Orientation
Objects
Multiplicity Class
Attributes
Operations
Associations
Aggregation
Composition
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Multiplicity Oriented
Analysis &
Design
Encapsulation
Interface
Package
Object
Oriented
Analysis &
Design
Introduction to
Object
Orientation
Objects
Polymorphism Class
Attributes
Operations
Associations
Aggregation
Composition
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Polymorphism Oriented
Analysis &
Design
Dependency
I the “+” operator which allows similar or polymorphic
Multiplicity
treatment of numbers (addition), strings Polymorphism
(concatenation), and lists (attachment). Encapsulation
Interface
Package
Object
Oriented
Analysis &
Design
Introduction to
Object
Orientation
Objects
Encapsulation Class
Attributes
Operations
Associations
Aggregation
Composition
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Encapsulation Oriented
Analysis &
Design
Multiplicity
boxes’.
Polymorphism
I Communication is achieved through an ‘interface’. Encapsulation
Interface
Package
Object
Oriented
Analysis &
Design
Introduction to
Object
Orientation
Objects
Interface Class
Attributes
Operations
Associations
Aggregation
Composition
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Interface Oriented
Analysis &
Design
Encapsulation
Interface
Package
Object
Oriented
Analysis &
Design
Introduction to
Object
Orientation
Objects
Package Class
Attributes
Operations
Associations
Aggregation
Composition
Inheritance
Dependency
Multiplicity
Polymorphism
Encapsulation
Interface
Package
Object
Package Oriented
Analysis &
Design
Polymorphism
Encapsulation
Interface
Package
Object
Packages in Java Oriented
Analysis &
Design
filesystem; Associations
Aggregation
I a Socket object allows for the creation and use of Composition
network sockets; Inheritance
I various GUI objects control buttons and checkboxes and Dependency
anything else related to graphical user interfaces.
Multiplicity
I There are literally thousands of classes to choose from. Polymorphism