Upload
nazmul-haque
View
226
Download
0
Embed Size (px)
Citation preview
8/7/2019 CSE 222 L1
1/16
CSE 222 : ObjectOriented Programming
Lecture 1: Introduction toObject Oriented Programming
8/7/2019 CSE 222 L1
2/16
Topics to be Covered
Introduction to Object-Oriented Concepts
What is an Object?
What can & cant be a Object
Classes Basic Concepts of OOP
Encapsulation
Polymorphism
Inheritance
The Origins of C++
Advantages of C++
A way to OOP
8/7/2019 CSE 222 L1
3/16
Introduction to Object-Oriented
Concepts
Object orientation allows to constructsystems
based on the idea of components.
This component-based development allowsobjects to be
re-used
extended
reducing development time dramatically.
8/7/2019 CSE 222 L1
4/16
Introduction to Object-Oriented
Concepts cont..
Object-oriented programming allows the following: A system can be constructed from a set of objects
just as a house is built from bricks, windows and doors
Adding new capabilities to existing objects can expand asystem
A door for a house could be a door to a room a cupboard this could be extended to include garage doors.
Creating new objects can expand a system a house object may have stairs or a lift. No stairs could mean a bungalow
stairs would allow the house to have more than one floor a lift would allow a tall block of flats to be built.
Reduces the development time by facilitating re-use The bricks, windows and door objects, which were designed for the
first house, can also be used to build other houses.
8/7/2019 CSE 222 L1
5/16
What is an Object? The world around us is full of objects and modern software
aims to imitate the real world. objects have state (variables) and behaviour (method). An objects state can be thought of as the features that
describe it a carmay have an engine type, a make, model numberand a
colour.
An objects behaviours are the things that it knows how todo accelerate brake
change gear turn the windscreen wipers on and off.
8/7/2019 CSE 222 L1
6/16
What can & cant be a Object
An object can be: A physical thing in the real world.
A representation of reality.
A tangible or visible thing.
A thing to which action or thought can be directed. Passive doing nothing until activated e.g. a switch.
Active continually monitoring until conditions change,e.g. a
thermostat.
An object is never: A value (e.g. name).
A process (e.g. sort).
Time (e.g. five minutes).
8/7/2019 CSE 222 L1
7/16
Classes
A class is a template definition of themethods and variables in a particularkind of object .
an object is a specific instance of a class;it contains real values instead of variables.
8/7/2019 CSE 222 L1
8/16
Basic Concepts of OOP
Object-Oriented Programming consists of 3primary ideas: Encapsulation
Is a black box technique The mechanism that binds together code and data it
manipulates Keeps both safe from outside interference and misuse Operations on the data are considered to be part of the
data type We can understand and use a data type without knowing
all of its implementation detailsNeither how the data is represented nor how the operationsare implemented
We just need to know the interface (or method headers) how to communicate with the object
Compare to functional abstraction with methods
8/7/2019 CSE 222 L1
9/16
Inheritance
Process by which oneobject can acquire theproperties of anotherobject
Properties of a datatype can be passeddown to a sub-type we can build newtypes from old ones
We can build classhierarchies with manylevels of inheritance
8/7/2019 CSE 222 L1
10/16
Polymorphism
In the context of object-oriented programming, isthe ability to create avariable, a function, or an
object that has more thanone form.
Polymorphism ismanifested in the form ofmultiple methods havingthe same name.
operations can have thesame name even thoughthey are associated withdifferent objects.
8/7/2019 CSE 222 L1
11/16
The Origins of C++
It was developed by Bjarne Stroustrupin1979 at Bell Labs
As an enhancement to the C programming
language and originally named "CwithClasses".
C++ is an object oriented programming
language. It was renamed to C++ in 1983.
8/7/2019 CSE 222 L1
12/16
The origins of C++ cont.. C++ is designed to be a statically typed general-purpose
language that is as efficient and portable as C C++ is designed to directly and comprehensively support
multiple programming styles (procedural programming,data abstraction, object-oriented programming, and
generic programming) C++ avoids features that are platform specific or not
general purpose
C C++
Templates
class
Operatoroverloading
Virtualfunctions
Multipleinheritance
Exceptionhandling
8/7/2019 CSE 222 L1
13/16
Advantages of C++
Can handle more complex program (ifLOC>25,000 100,000 it becomes socomplex to handle in C)
C++ allows the programmer tocomprehend and manage larger, morecomplex programs
STL is there which provides genericroutines to manipulate data.
8/7/2019 CSE 222 L1
14/16
Towards OOP
Structured Programming Method (SPM):
Invented in 1960s
Method was encouraged by C and Pascal
Fairly ease to write moderately complexprograms
Support stand-alone subroutine, localvariables, rich control structures & eliminate
GOTO Reach their limit when project becomes too
large
8/7/2019 CSE 222 L1
15/16
Breaking the Barriers of SPM
OOP Took the best ideas of SPM and combine with several
new concepts.
Program Organization Around its code :
what is happening
Structured Programming uses this organization
Programs are organized around code
Code acting on data
Around its data : who is being affected
Datacontrolling access ofcode
Define data and routines that permitted to act on data
8/7/2019 CSE 222 L1
16/16
Readings
Chapter 11 : An Overview of C++, TheComplete Reference : C++, By- HerbertSchildt, 4th Edition, pp:256-259
Chapter 1: Introduction to Programming,Programming Methods, NCC EducationLimited, pp: 1-14 to 1-26