Principles of Object Oriented Modelling
Principles of Object Oriented Modelling
OOAD
Object Orientation
Polymorphism
Encapsulation
Inheritance
Abstraction
Abstraction
Focus on the essential Omits tremendous amount of details Focus on what an object is and does
Encapsulation
a.k.a. information hiding Objects encapsulate:
property behavior as a collection of methods invoked by messages state as a collection of instance variables
Encapsulation
31
Behavior and information is represented or implemented internally Functionality and behavior characterized by interfacing operations
31
<<instanceOf>>
<<instanceOf>>
<<instanceOf>>
Class
33
What is CLASS?
a collection of objects that share common properties, attributes, behavior and semantics, in general. A collection of objects with the same data structure (attributes, state variables) and behavior (function/operations) in the solution space. Grouping of common objects into a class The act of creating an instance.
Classification
Instantiation.
<<instanceOf>>
<<instanceOf>>
<<instanceOf>>
Class
34
A class represents a template for several objects and describes how these objects are structured internally Objects of the same class have the same definition both for their operations and their information structure Class is an implementation of objects
Sample Class
35
Class Course
Properties Name Location Days offered Credit hours Start time End time Behavior Add a student Delete a student Get course roster Determine if it is full
a + b = 10
Levels of abstraction
36
Increasing abstraction
Asset
BankAccount
Security
RealEstate
Savings Checking
Decreasing abstraction
Stock
Bond
Elements at the same level of the hierarchy should be at the same level of abstraction
36
Instance
37
An instance is an object created from a class A class describes the behavior and information structure of an instance, while the current state of the instance is defined by the operations performed on the instance Systems behavior is performed via the interactions between instances
37
Inheritance
38
Specialization: The act of defining one class as a refinement of another (Generalized). Subclass: A class defined in terms of a specialization of a superclass using inheritance. Superclass: A class serving as a base for inheritance in a class hierarchy Inheritance: Automatic duplication of superclass attribute and behavior definitions in subclass.
Person name NIC No
multiple inheritance?
Why Inheritance?
39
Show similarities Reuse common descriptions Software Reuse Easy modification of model by performing modification in one place Avoid redundancy, leading to smaller and more efficient model, easier to understand
39
What is Polymorphism?
40
Manufacturer A
Manufacturer B
Manufacturer C
40