se_lec 06_object oriented analysis and design

38
1

Upload: amr-e-mohamed

Post on 13-Jan-2017

59 views

Category:

Software


2 download

TRANSCRIPT

Page 1: SE_Lec 06_Object Oriented Analysis and Design

1

Page 2: SE_Lec 06_Object Oriented Analysis and Design

2

System development refers to all activities that go into

producing information system solution.

System development activities consist of system

analysis, modeling, design, implementation, testing and

maintenance.

Object-Oriented (OO) systems development is a way to

develop software by building self-contained modules

that can be more easily:

Replaced

Modified

and Reused.

Page 3: SE_Lec 06_Object Oriented Analysis and Design

3

A software system is a set of mechanism for performing

certain action on certain data.

Algorithm + Data structure = Program

Page 4: SE_Lec 06_Object Oriented Analysis and Design

4

The code is subdivided into modules

Each module is made of procedures and data structures

Procedures operate on data, e.g. modifying them

e.g. the “C” programming language

There is no strong connection between procedures

Every procedure may possibly access any data and modify

it and data

Page 5: SE_Lec 06_Object Oriented Analysis and Design

5

OO approach is more like creating a lot of helpers that

take on an active role, a spirit, that form a community

whose interactions become the application.

Models the problem to be solved as a set of interacting

objects, each carrying its own state and exhibiting its

own behavior

By separating concerns, this approach has proved to be

robust and useful to solve more complex programming

problems.

Page 6: SE_Lec 06_Object Oriented Analysis and Design

6

The physical world is made of a set of objects that can

interact

Each of them presents

An identity (objects can be recognized)

A state (objects remember their history)

A behavior (objects react to external stimuli in a

predictable way)

Page 7: SE_Lec 06_Object Oriented Analysis and Design

7

Faster development,

Increased quality

Raising the level of abstraction.

It adapts to

Changing requirements

Easier to maintain

More robust

Promote greater design

Code reuse

Page 8: SE_Lec 06_Object Oriented Analysis and Design

8

Goals:

Define Objects and classes

Describe objects‘ methods, attributes and how objects

respond to messages,

Define Polymorphism, Inheritance, data abstraction,

encapsulation, and protocol,

Describe objects relationships,

Describe object persistence.

Understand meta-classes.

Page 9: SE_Lec 06_Object Oriented Analysis and Design

9

The term object was first formally utilized in the Similar

language to simulate some aspect of reality.

An object is an entity.

It knows things (has attributes)

It does things (provides services or has methods)

Note:

Attributes or properties represented by data type and

describe object‘s state (data)

Methods define objects behavior and specify the way in

which an Object‘s data are manipulated.

Page 10: SE_Lec 06_Object Oriented Analysis and Design

10

It Knows things (attributes)

I am an Employee.

I know my name, social security number and my address.

Attributes

I am a Car.

I know my color,

manufacturer, cost,

owner and model.

It does things (methods)

I know how to compute my payroll.

Page 11: SE_Lec 06_Object Oriented Analysis and Design

11

In an object-oriented system, everything is an object:

numbers, arrays, records, fields, files, forms, an

invoice, etc.

An Object is anything, real or abstract, about which we

store data and those methods that manipulate the data.

Conceptually, each object is responsible for itself.

A window object is responsible for things like opening,

sizing, and closing itself.

Page 12: SE_Lec 06_Object Oriented Analysis and Design

12

When developing an O-O application, two basic

questions always arise.

What objects does the application need?

What functionality should those objects have?

Page 13: SE_Lec 06_Object Oriented Analysis and Design

13

Simple Name (written as UpperCase-first Noun)

Path Name

Page 14: SE_Lec 06_Object Oriented Analysis and Design

14

Represent named properties of a UML class

UML class can have many attributes of different names

Attribute name is generally a short noun or a noun

phrase written in lowerCase-first text

Attribute declaration may include visibility, type and

initial value: +attributeName : type = initial-value

Page 15: SE_Lec 06_Object Oriented Analysis and Design

15

Represent named services provided by a UML class

UML class can have many operations of different

names

Operation name is generally a short verb or a verb

phrase written in lowerCase-first text

Operation may include visibility, parameters, and

return type: +opName(param1 : type = initial_value)

: return-type

Page 16: SE_Lec 06_Object Oriented Analysis and Design

16

Three levels of class, attribute and operation visibility:

• private (-), available only to the current class

• protected (#), available to the current and inherited

classes

• public (+), available to the current and other classes

Page 17: SE_Lec 06_Object Oriented Analysis and Design

17

Each class represents a set of objects that share the

same attributes, operations, relationships, and

semantics

For each of the class attributes, objects can have

specific attribute values

For each of the class operations, objects may have

different implementations

Page 18: SE_Lec 06_Object Oriented Analysis and Design

18

Represent a relation between a parent (a more abstract

class) and a child (a more specific class)

Generally referred to as a “is-a-kind-of” relationship

Child objects may be used instead of parent objects

since they share attributes and operations; the opposite

is not true

Page 19: SE_Lec 06_Object Oriented Analysis and Design

19

An object-oriented system organizes classes into

subclass-super hierarchy.

At the top of the hierarchy are the most general classes

and at the bottom are the most specific

A subclass inherits all of the properties and methods

(procedures) defined in its super class.

Page 20: SE_Lec 06_Object Oriented Analysis and Design

20

Inheritance is a relationship between classes where one

class is the parent class of another (derived) class.

Inheritance allows classes to share and reuse behaviors

and attributes.

The real advantage of inheritance is that we can build

upon what we already have and,

Reuse what we already have.

Page 21: SE_Lec 06_Object Oriented Analysis and Design

21

Page 22: SE_Lec 06_Object Oriented Analysis and Design

22

Page 23: SE_Lec 06_Object Oriented Analysis and Design

23

OO systems permit a class to inherit from more than

one superclass.

Page 24: SE_Lec 06_Object Oriented Analysis and Design

24

Information hiding is a principle of hiding internal data

and procedures of an object.

By providing an interface to each object in such a way

as to reveal as little as possible about its inner

workings.

Encapsulation protects the data from corruption.

Page 25: SE_Lec 06_Object Oriented Analysis and Design

25

Objects perform operations in response to messages.

For example, you may communicate with your

computer by sending it a message from hand-help

controller.

Page 26: SE_Lec 06_Object Oriented Analysis and Design

26

Consider a payroll program that processes employee

records at a small manufacturing firm. This company

has three types of employees:

Managers: Receive a regular salary.

Office Workers: Receive an hourly wage and are eligible

for overtime after 40 hours.

Production Workers: Are paid according to a piece rate.

Page 27: SE_Lec 06_Object Oriented Analysis and Design

27

Structured Approach

FOR EVERY EMPLOYEE DO

BEGIN

IF employee = manager THEN

CALL computeManagerSalary

IF employee = office worker THEN

CALL computeOfficeWorkerSalary

IF employee = production worker THEN

CALL computeProductionWorkerSalary

END

Page 28: SE_Lec 06_Object Oriented Analysis and Design

28

OO Approach

Page 29: SE_Lec 06_Object Oriented Analysis and Design

29

OO Approach

FOR EVERY EMPLOYEE DO

BEGIN

employee computePayroll

END

Page 30: SE_Lec 06_Object Oriented Analysis and Design

30

Polymorphism means that the same operation may

behave differently on different classes.

Example: computePayroll

Page 31: SE_Lec 06_Object Oriented Analysis and Design

31

Link: model of logical or physical link between objects

Page 32: SE_Lec 06_Object Oriented Analysis and Design

32

Relationship: descriptor of links

Page 33: SE_Lec 06_Object Oriented Analysis and Design

33

Multiplicity: constraint on the min/max number of links

connected to an object

Page 34: SE_Lec 06_Object Oriented Analysis and Design

34

The concept of association represents relationships

between objects and classes. For example a pilot can

fly planes

Association can be binary, between two classes, or n-

ary, among more than two classes

Can include association name, direction, role names,

multiplicity, and aggregation type

Page 35: SE_Lec 06_Object Oriented Analysis and Design

35

Represent a specific, whole/part structural relationship

between class objects

Composition [is entirely made of]: (closed diamond)

represents exclusive relationship between two class

objects (e.g., a faculty cannot exist without nor be a part

of more than one university)

Aggregation [is part of]: (open diamond) represents

nonexclusive relationship between two class objects (e.g.,

a student is a part of one or more faculties)

Page 36: SE_Lec 06_Object Oriented Analysis and Design

36

Objects have a lifetime. An object can persist beyond

application session boundaries, during which the object

is stored in a file or a database, in some file or database

form.

Page 37: SE_Lec 06_Object Oriented Analysis and Design

37

Everything is an object.

How about a class?

Is a class an object?

Yes, a class is an object! So, if it is an object, it must

belong to a class.

Indeed, class belongs to a class called a Meta-Class or

a class' class.

Meta-class used by the compiler. For example, the

meta-classes handle messages to classes, such as

constructors and "new.“

Page 38: SE_Lec 06_Object Oriented Analysis and Design

38