introduction to object orientation

29
Introduction to Object Orientation Dr. Ahmed Youssef

Upload: emmett

Post on 06-Feb-2016

49 views

Category:

Documents


0 download

DESCRIPTION

Introduction to Object Orientation. Dr. Ahmed Youssef. Object-Orientation. It is a kind of thinking methodology Everything in the world is an object; Any system is composed of objects; - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction to  Object Orientation

Introduction to Object Orientation

Dr. Ahmed Youssef

Page 2: Introduction to  Object Orientation

Object-Orientation It is a kind of thinking methodologyEverything in the world is an object;

Any system is composed of objects;

The evolution and development of a system is caused by the interactions among the objects inside or outside the system

2SWE 316- Ahmed Youssef

Page 3: Introduction to  Object Orientation

Decomposition of the large problem into small parts that can be solved separately.

Why Object Oriented?

Large Application

3SWE 316- Ahmed Youssef

Page 4: Introduction to  Object Orientation

Object-Oriented Concept

Object & Class InheritancePolymorphismEncapsulation

4SWE 316- Ahmed Youssef

Page 5: Introduction to  Object Orientation

Everything in the world is an object

A flower, a tree, an animal A student, a professor A desk, a chair, a classroom,

a building A university, a city, a country The world, the universe A subject such as CS, SWE,

Math, History, …5SWE 316- Ahmed Youssef

Page 6: Introduction to  Object Orientation

Object

6SWE 316- Ahmed Youssef

Page 7: Introduction to  Object Orientation

Any system is composed of objectsA cultural systemAn educational systemAn economic systemAn Information systemA computer system

7SWE 316- Ahmed Youssef

Page 8: Introduction to  Object Orientation

Procedure Program view

Main Program

Data

Procedure1

Procedure2

Procedure3

8SWE 316- Ahmed Youssef

Page 9: Introduction to  Object Orientation

Main Program(Also a module)

Data

Data Data1

Module2

+

Data Data2

Module1

+

Data Data1

Procedure1Procedure2

The main program coordinates calls to procedures in separate modules and hands over appropriate data as parameters.

Procedure3

9SWE 316- Ahmed Youssef

Page 10: Introduction to  Object Orientation

Object1

Data1+Procedures1

Data Data1Object3

Data3 + Procedures3

Object2

Data2 + Procedures2

Object4

Data4 + Procedures4

10SWE 316- Ahmed Youssef

Page 11: Introduction to  Object Orientation

11

Classesobjects sharing common characteristics

containstate: attributes, fields, variables, data member

behavior: functions, methods

SWE 316- Ahmed Youssef

Page 12: Introduction to  Object Orientation

Class

Person

Ahmed

Majed

Salem

Saad

12SWE 316- Ahmed Youssef

Page 13: Introduction to  Object Orientation

Class

Student

Ahmed

Majed

Salem

Saad

13SWE 316- Ahmed Youssef

Page 14: Introduction to  Object Orientation

Class

Tennis Player

Bandar

Mosaed

Nayef

Khaled

14SWE 316- Ahmed Youssef

Page 15: Introduction to  Object Orientation

Class

Institute

Social Technology

Engineering

Science

Agricultural Technology

15SWE 316- Ahmed Youssef

Page 16: Introduction to  Object Orientation

Class

NameAttributesOperations

16SWE 316- Ahmed Youssef

Page 17: Introduction to  Object Orientation

ClassStudent

StudentIDFirstNameLastNameAddressetc…

RegisterForCourseDropCourseetc...

17SWE 316- Ahmed Youssef

Page 18: Introduction to  Object Orientation

ClassTennis Player

FirstNameLastNameNationalityRankingetc…RegisterForTournamentetc...

18SWE 316- Ahmed Youssef

Page 19: Introduction to  Object Orientation

Class Car

Car Reg. NumberMakerModelColoretc…AccelerateStopetc...

19SWE 316- Ahmed Youssef

Page 20: Introduction to  Object Orientation

ClassAirplane

Plane NumberManufacturerModeletc…TakeOffLandingetc...

20SWE 316- Ahmed Youssef

Page 21: Introduction to  Object Orientation

21

Object & Class

SWE 316- Ahmed Youssef

Page 22: Introduction to  Object Orientation

Object & ClassStudent

StudentIDFirstNameLastNameAddressetc…

RegisterForCourseDropCourseetc...

Student

Ahmed

Majed

Salem

Saad

22SWE 316- Ahmed Youssef

Page 23: Introduction to  Object Orientation

Object & ClassStudent1

B4555555AhmedAlfgdfg7146 sdasds7etc…

RegisterForCourseDropCourseetc...

Student

Ahmed

Majed

Salem

Saad

23SWE 316- Ahmed Youssef

Page 24: Introduction to  Object Orientation

Student1

B4555555AhmedAlfgdfg7146 sdasds7etc…

RegisterForCourseDropCourseetc...

Student

StudentIDFirstNameLastNameAddressetc…

RegisterForCourseDropCourseetc...

24SWE 316- Ahmed Youssef

Page 25: Introduction to  Object Orientation

Building Class

SWE 316- Ahmed Youssef 25

Any Thing

Attributes

Behavior

Page 26: Introduction to  Object Orientation

Student- Class

Lname string Student_ID

string

Levelint

Telstring

Gender string

Programstring

Print_infoInput: -return: voidUpdate_i

nfoInput: name or IDReturn : void

Fname string

26

Page 27: Introduction to  Object Orientation

MainClass

StudentClass

3.

Man

age

obje

ct

1. Create objects from

class

Obj1

Obj2

Obj3

Obj4

2. objects

27

Page 28: Introduction to  Object Orientation

Student Class

Instance variable

Constructor

Constructor

28

Page 29: Introduction to  Object Orientation

Method

OverloadedMethod

Student Class

29