Oop + lecture01

18
Object-Oriented Object-Oriented Programming (OOP) Programming (OOP) Lecture No. 1 Lecture No. 1

description

OOP

Transcript of Oop + lecture01

Page 1: Oop +  lecture01

Object-Oriented Object-Oriented Programming (OOP)Programming (OOP)

Lecture No. 1Lecture No. 1

Page 2: Oop +  lecture01

Course ObjectiveCourse Objective

►Objective of this course is to make Objective of this course is to make students familiar with the concepts of students familiar with the concepts of object-oriented programmingobject-oriented programming

►Concepts will be reinforced by their Concepts will be reinforced by their implementation in C++implementation in C++

Page 3: Oop +  lecture01

Course ContentsCourse Contents

►Object-OrientationObject-Orientation►Objects and ClassesObjects and Classes►OverloadingOverloading► InheritanceInheritance►PolymorphismPolymorphism►Generic ProgrammingGeneric Programming►Exception HandlingException Handling► Introduction to Design PatternsIntroduction to Design Patterns

Page 4: Oop +  lecture01

BooksBooks

►C++ How to ProgramC++ How to ProgramBy Deitel & DeitelBy Deitel & Deitel

►The C++ Programming LanguageThe C++ Programming LanguageBy Bjarne StroustrupBy Bjarne Stroustrup

►Object-Oriented Software EngineeringObject-Oriented Software EngineeringBy Jacobson, Christerson, Jonsson, OvergaardBy Jacobson, Christerson, Jonsson, Overgaard

Page 5: Oop +  lecture01

Grading PolicyGrading Policy

►AssignmentsAssignments 10 %10 %►ProjectProject 10 % 10 %►Quiz & HW 10 %Quiz & HW 10 %► Mid-TermMid-Term 30 % 30 %►FinalFinal 40 % 40 %

Page 6: Oop +  lecture01

Object-Orientation (OO)Object-Orientation (OO)

Page 7: Oop +  lecture01

What is Object-Orientation?What is Object-Orientation?

►A technique for system modelingA technique for system modeling

►OO model consists of several OO model consists of several interacting objectsinteracting objects

Page 8: Oop +  lecture01

What is a Model?What is a Model?

►A model is an abstraction of somethingA model is an abstraction of something

►Purpose is to understand the product Purpose is to understand the product before developing itbefore developing it

Page 9: Oop +  lecture01

Examples – ModelExamples – Model

►Highway mapsHighway maps

►Architectural modelsArchitectural models

►Mechanical modelsMechanical models

Page 10: Oop +  lecture01

Example – OO ModelExample – OO Model

Page 11: Oop +  lecture01

……Example – OO ModelExample – OO Model

►ObjectsObjects AliAli HouseHouse CarCar TreeTree

► InteractionsInteractions Ali lives in the houseAli lives in the house Ali drives the carAli drives the car

Ali

Car

House

Tree

lives-in

drives

Page 12: Oop +  lecture01

Object-Orientation - Object-Orientation - Advantages Advantages

►People think in terms of objectsPeople think in terms of objects

►OO models map to realityOO models map to reality

►Therefore, OO models areTherefore, OO models are easy to developeasy to develop easy to understandeasy to understand

Page 13: Oop +  lecture01

What is an Object?What is an Object?

An object isAn object is

►Something tangible (Ali, Car)Something tangible (Ali, Car)

►Something that can be apprehended Something that can be apprehended intellectually (Time, Date)intellectually (Time, Date)

Page 14: Oop +  lecture01

… … What is an Object?What is an Object?

An object hasAn object has

►State (attributes)State (attributes)►Well-defined behaviour (operations)Well-defined behaviour (operations)►Unique identityUnique identity

Page 15: Oop +  lecture01

Example – Ali is a Tangible Example – Ali is a Tangible ObjectObject

►State (attributes)State (attributes) NameName AgeAge

►behaviour (operations)behaviour (operations) WalksWalks EatsEats

► IdentityIdentity His nameHis name

Page 16: Oop +  lecture01

Example – Car is a Tangible Example – Car is a Tangible ObjectObject

►State (attributes)State (attributes)- Color- Color

- Model- Model

►behaviour (operations)behaviour (operations)- Accelerate- Accelerate - Start Car- Start Car

- Change Gear- Change Gear

► IdentityIdentity- Its registration number- Its registration number

Page 17: Oop +  lecture01

Example – Time is an Object Example – Time is an Object Apprehended IntellectuallyApprehended Intellectually

►State (attributes)State (attributes)- Hours- Hours - Seconds- Seconds

- Minutes- Minutes

►behaviour (operations)behaviour (operations)- Set Hours- Set Hours - Set Seconds- Set Seconds

- Set Minutes- Set Minutes► IdentityIdentity

- Would have a unique ID in the model- Would have a unique ID in the model

Page 18: Oop +  lecture01

Example – Date is an Object Example – Date is an Object Apprehended IntellectuallyApprehended Intellectually

►State (attributes)State (attributes)- YearYear - Day- Day- MonthMonth

►behaviour (operations)behaviour (operations)- Set Year- Set Year - Set Day- Set Day

- Set Month- Set Month

► IdentityIdentity- Would have a unique ID in the model- Would have a unique ID in the model