OBJECT ORIENTED PROGRAMMING overview
description
Transcript of OBJECT ORIENTED PROGRAMMING overview
![Page 1: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/1.jpg)
1
OBJECT ORIENTED PROGRAMMING OVERVIEWChapter 1
![Page 2: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/2.jpg)
2
Introduction Aims:• to establish understanding of basic
concepts of Object Oriented Programming (OOP)
What will be covered:• Procedural Programming vs OOP• History of OOP• Object Oriented Application• basic concept of OOP
![Page 3: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/3.jpg)
3
Introduction There are two most widely used
programming language styles:
1. Procedural Programming
2. Object Oriented Programming
![Page 4: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/4.jpg)
4
Procedural Vs Object Oriented Programming
• Procedural programming• also known as structural programming
languages • This type of style allows programmers to
write program according to a set of steps for solving problems, usually in a top down manner and in chronological order.
• It relies on functional decomposition which means the system is broken down into components/ functions/ procedures.
• The programming relies heavily on the 3 basic structures: sequence, selection and iteration.
• using traditional programming languages e.g. C, Fortran, Cobol etc.
![Page 5: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/5.jpg)
5
Object-oriented programming The world around us are made up of
objects e.g. people, cars, trees, buildings etc
This is used to model a software system as a set of objects interacted with each other.
The Objects represent the system components
Each OO program file must contain at least one class
Some of the programming language used are Java, C++, C#, VB.NET etc.
Procedural Vs Object Oriented Programming
![Page 6: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/6.jpg)
6
Object-Oriented Programming is VERY different from procedural programming. Instead of think of "steps/processes" to
solving a problem, we need to think about and identify the objects involved in the
problem and how they'll interact. Each object is responsible for its own activities and data.
OO developer however must still follow the step of understanding the problem
andplanning the application
Procedural Vs Object Oriented Programming
![Page 7: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/7.jpg)
7
Data
Application file:VariablesMethods
InputOutput
Data
Application file:Input
OutputObject creation
Class file: variablesmethods
Class file: variablesmethods
Class file: variablesmethods
PROCEDURAL APPLICATION
OBJECT ORIENTED APPLICATION
Procedural Vs Object Oriented Programming
![Page 8: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/8.jpg)
8
The previous diagrams shows that In procedural programming,
• all input, output, variables and methods are put in a single file.
• This is quite large and difficult to maintain
In Object Oriented Programming, • most variables and methods are organized
within separate classes that define different kind of objects.
• A separate, smaller application file handles input and output and creates the needed objects.
• OO approach produces more modular and organized application
Procedural Vs Object Oriented Programming
![Page 9: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/9.jpg)
9
Architecture - JavaOO program file
e.g. calculateSalary.java
Class/ese.g. calculateSalary
Method/se.g. (main)
Statementse.g. System.out.println(“Please enter hours worked”)
![Page 10: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/10.jpg)
10
Object Oriented Approach Object oriented approach intended to
produce systems which are composite, modular constructions, build using abstraction, and organized around the data.
Suitable to solve large and evolving software system.
Most research claimed that OO IS is much easier to maintain compared to the traditional IS.
![Page 11: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/11.jpg)
11
History of OOP Object programming was reported to exists
in Simula 67 back in 1960s Simula 67 is developed at the Norwegian
Computing Center in Oslo, by Ole-Johan Dahl and Kristen Nygaard.
Simula 67 is used to program Simulation Influenced from Simula 67, later, the theory
of OOP is introduced by smallTalk (Xerox PARC) which further designed it to include the pervasive use of objects and messages as the basis for computation.
Mid 1980s, OOP dominant the programming methodology through C++ (an extension of C Language)
More recently, a number of OOP languages exists such as Visual Basic .NET, C#
![Page 12: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/12.jpg)
12
Object Oriented Programming Why is Object Oriented introduced?
Object Oriented Programming is introduced because of the limitation of the procedural programming which are:
• programs written in procedural language become complex very quickly (1000s lines of code) if very large system is developed
• difficult to test and maintain• often re-implement code unnecessarily (a
large system is normally programmed by more than 1 developer
![Page 13: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/13.jpg)
13
Object-Oriented programming uses 3 main concepts: Inheritance – copying the
attributes and methods from the base/parent classes
Encapsulation – data hiding (hiding the attributes from the outside world)
Polymorphism – using methods of the same name for a variety of purposes (overriding or overloading)
Object Oriented Programming
![Page 14: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/14.jpg)
14
Object Oriented Terms and ConceptsAn object simply represents any object that you may think of in the "real world".
Tangible (like real objects that you can touch): e.g., a House, a Car, a Person, etc...
Non tangible objects (sometimes harder to identify):
e.g., a BankAccount, Insurance, a Loan, a Vacation, etc...
![Page 15: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/15.jpg)
15
Objects are made up of two "things": state (a.k.a.
attributes/fields/properties + value) A given set of data which describes the
object e.g., colour, size, amount, name,
phoneNumber, etc...
behaviour (a.k.a. methods or functions) A set of operation that the object can
perform e.g., walk, run, drive, sell, buy, transfer,
computeTotal, open, close, etc...
Object Oriented Terms and Concepts
![Page 16: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/16.jpg)
16
withdraw, deposit, transfer, get balance
owner, balance, accountnumberBankAccount
make purchase, list items bought, return
item
name, address,purchase history
Customer
get the address, change phone number
name, age, gender, phone numberPerson
BehaviourStateObject
Example of Object, state, behaviour
Object Oriented Terms and Concepts
![Page 17: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/17.jpg)
17
• An object is a specific item in the class, often referred to an instance/example of a class.
• A class is simply a template/mould/blueprint for constructing objects of a specific type.
• Before you can use an object in your program, you MUST define the class. In fact, ALL objects MUST belong to a class of some kind.
Object Oriented Terms and Concepts
![Page 18: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/18.jpg)
18
Instances of fruit
An instance of the Fruit class refers to a specific fruit.These are all objects
Class : Fruit
Object Oriented Terms and Concepts
![Page 19: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/19.jpg)
19
Construction of OO Programming So how do we actually write an
Object-Oriented program ?
• Identify the Objects (i.e., Classes) that represent our problem which is to be solved (or simulated)
• identify the object characteristics (i.e., state and behaviour)
• Identify the inter-relationships between the Objects (i.e., how they interact).
![Page 20: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/20.jpg)
20
ExampleScheduling application Involves objects such as:
Students Course Schedule
Objects attributes Student – ID, name, gender, dob Course – dept, number, descr, credit hrs Schedule – semester, studentID, a number
of courses Object behaviour
Schedule – assign studentID and course20
![Page 21: OBJECT ORIENTED PROGRAMMING overview](https://reader033.fdocuments.in/reader033/viewer/2022061510/56816381550346895dd466aa/html5/thumbnails/21.jpg)
21
Exercise Identify 3 objects that might
belongs to each of the following classes: automobile animal bankAccount footballPlayer mobilePhone
21