Anda di halaman 1dari 7

PRINCIPLES OF OBJECT ORIENTED MODELLING

OOAD

Basic Principles of Object Orientation


29

Object Orientation

Polymorphism

Encapsulation

Inheritance

Abstraction

Abstraction and Encapsulation


30

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

A concept of Self-containing Information hiding

internal structure is hidden from their surroundings

Behavior and information is represented or implemented internally Functionality and behavior characterized by interfacing operations
31

Object Oriented Analysis

Another Example of Abstraction and Encapsulation


32

<<instanceOf>>

<<instanceOf>>

<<instanceOf>>

Class Car Attributes Model Location #Wheels = 4 Operations Start Accelerate

What is generalization? Forall x [Car(x) -> ]

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 Car Attributes Model Location #Wheels = 4 Operations Start Accelerate

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

Object Oriented Analysis

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

Object Oriented Analysis

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

Student std-id level

Employee emp-id age

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

The ability to hide many different implementations behind a single interface

Manufacturer A

Manufacturer B

Manufacturer C

40