SlideShare a Scribd company logo
5- Object-Oriented in
Software lifecycle
Object-Oriented in Software
lifecycle
• Types of object oriented paradigms in SLC:
– Object-oriented analysis (OOA)
– Object-oriented design (OOD)
– Object-oriented programming (OOP)
– Object-oriented testing (OOT)
Why OOP?
• “Software Crisis” in procedural programming:
– Too many modules…
– Too many functions… An expensive mess!!!
– Too many variables…
• While OOP approach provides:
1-Greater Reliability
– Break complex software projects into small, self-
contained, and modular objects
2- Maintainability
– Modular objects make locating bugs easier, with less
impact on the overall project
Benefits of OOP..
• 3- Inheritance: Elimination of Redundant Code and extend
the use of existing classes.
• 4- Encapsulation: Helps in building secure programs.
• 5- Easy to map objects in problem domain to those objects
in the program.
• 6- It is easy to partition the work in a project based on
objects.
analysis
requirements
design
using class /
object
diagrams
programming
(coding / testing
/ debugging)
in Java
OOD
OOP: background
Simula
1967
C ++
Late 1980s
Smalltalk
1972
Java
1991
The UML
1996
C#
2000+
Software life cycle
OOPOOA
Procedural vs. OOP
• Data Structure A
• Data Structure B
• Data Structure C
• Function A1
• Function A2
• Function B
• Function C
• Class A
– Data Structure A
– Function A1
– Function A2
• Class B
– Data Structure B
– Function B
• Class C
– Data Structure C
– Function C
Examples of Objects
Figure 1.9: Examples of objects
CAR
VDU
BOY GIRL
TREEBOOK
CLOCK
TRIANGLE
Class Candidates
• External Entities
– devices or people
• Things in Problem Domain
– Reports, displays, signals
• Events
– completion of some task
• Roles
– manager, engineer, salesperson
• Organizational Units
– divisions, groups, teams
• Structures
– sensors, vehicles, computers
Unified Modeling Language
• UML (Unified Modeling Language) is a
modeling technique, which is well suited for
object-oriented programming
 The UML is approved as a standard and has become
widely accepted in the IT industry
 The UML is a modeling language, not a software
development process; it intends to support different
object oriented approaches to software production
Object Oriented Paradigm
The General Principle
“ An object oriented program is structured as a community of
interacting agents called objects. Action is initiated in object
oriented programming by the transmission of a message to an
agent (an object).
The message encodes the request for action and is accompanied by
additional information (arguments) needed to carry out the
request.
The receiver is the agent to which the message is sent. If the
receiver accepts the message it accepts the responsibility to
carry out the indicated action. In response to a message the
receiver will perform some method to satisfy the request. “
OO Concepts
• Object
– encapsulates both data (attributes) and data
manipulation functions (called methods, operations, and
services)
• Class
– generalized description (template or pattern) that
describes a collection of similar objects
• Superclass
– a collection of objects
• Subclass
– an instance of a class
Classes: Objects with the same
attributes and behavior
Person Objects
Vehicle Objects
Polygon Objects
Abstract Person Class
Attributes:
Operations:
Name, Age, Sex
Speak(), Listen(), Walk()
Into
Abstract Vehicle Class
Attributes:
Operations:
Name, Model, Color
Start(), Stop(), Accelerate()
Into
Abstract
Polygon Class
Attributes:
Operations: Draw(), Erase(), Move()
Vertices, Border,
Color, FillColorInto
Figure 1.12: Objects and classes
Inheritance
• New data types (classes) can be defined as
extensions to previously defined types.
• Parent Class (Super Class) – Child Class (Sub
Class)
• Subclass inherits
properties from the
• parent class.
Parent
Child
Inherited
capability
Inheritance - Example
• Example
– Define Person to be a class
• A Person has attributes, such as age, height, gender
• Assign values to attributes when describing object
– Define student to be a subclass of Person
• A student has all attributes of Person, plus attributes of his/her
own ( student no, course_enrolled)
• A student has all attributes of Person, plus attributes of his/her
own (student no, course_enrolled)
• A student inherits all attributes of Person
– Define lecturer to be a subclass of Person
• Lecturer has all attributes of Person, plus attributes of his/her own
( staff_id, subjectID1, subjectID2)
Inheritance - Example
• Circle Class can be a subclass (inherited from
) of a parent class - Shape
Shape
Circle Rectangle
Inheritance - Example
• Inheritance can also have multiple levels.
Shape
Circle Rectangle
GraphicCircle
What is Polymorphism?
• The ability to hide many different
implementations behind a single interface
Manufacture A Manufacture B Manufacture C
What is Encapsulation
• Hide implementation from clients
• Clients depend on interface
It associates the code and the data
it manipulates into a single unit;
and keeps them safe from external
interference and misuse.
Data
Functions
What is Abstraction?
Counter
Queue
Item
• An example of an item purchasing abstraction
• A model that includes most important aspects of a given
problem while ignoring less important details
Java’s OO Features
OOP
Paradigm
Encapsulation
Multiple Inheritance
Genericity
Delegation
Persistence
Polymorphism
Single Inheritance
Data Abstraction
Java
Object = Identity + State + Behavior
• Identity
– Distinguishes an object from all other objects.
• State
– Consists of a set of attributes (or fields), which have
names, types, and values.
• Behavior
– Defined by the set of operations (or methods) that may
operate on the object.
– Each method has a name, a type, and a value, where
• The type consists of the return type and the list of parameter types of the
method, often called signature.
• The value is the implementation of the method often expressed as a
sequence of statements, in languages like Java and C++.
objects
– oo-program:
consists of a set of communicating objects
– object: fundamental abstractions to build software systems
where do objects come from ?
• From the problem statement
• Analyze the problem to identify objects
– e.g.: program to manage bank accounts
• accounts (Account)
• customers (Customer)
• transactions (Transaction)
• “money machines” (ATM)
• windows (MainWindow)
objects: notation
• representation
object-name : Type name
steven : Person
c1 : Circle
objects: attributes and operations
– example:
• account (Account) objects:
– attributes: number of account (accountnumber)
name of owner (owner)
date of opening (date opened)
balance at opening initial balance)
balance today (current balance)
operations: on deposit (deposit)
on transfer (transfer)
on withdrawl (withdrawal)
what’s my balance ? (get balance)
queries and commands
objects: notation –
attributes and operations
c1 : Circle
20.6
radius
getRadius
getCircumference
getSurface
myAccount : Account
098-2356784-45
accountnumber
deposit
withdraw
get balance
…
3/10/2004
date opened
1345.04
current balance
dirk : Person
Dirk Smith
name
getName
getGender
itsYourBirthday
…
m
gender
21
age
…
current account
…
savings account
dirk : Person
Dirk Smith
name
getName
getGender
itsYourBirthday
…
m
gender
21
age
…
current account
…
savings account
:Account
045-5873784-53
accountnumber
deposit
withdraw
get balance
…
2/10/2004
date opened
10945.05
current balance
:Account
098-2356784-45
accountnumber
deposit
withdraw
get balance
…
3/10/2004
date opened
1345.04
current balance
Class Compartments
• A class is comprised of three sections
• The first section contains the class name
• The second section shows the structure
(attributes)
• The third section shows the behavior
(operations) Lecturer
Name
save()
change()
delete()
empID
create()
Class Compartments (cont.)
• The second and third sections may be
suppressed if they need not be visible on the
diagram
Lecturer
Name
save()
change()
delete()
empID
create()
Lecturer
Name
empID
Lecturer
save()
change()
delete()
create()
Lecturer
Lecturer
Example of specification for
Counter
• Start listing its responsibilities:
– Class: Counter
• queries:
– currentCount the current value of count, a non-
negative integer
• commands:
– reset set the value of count to 0
– incrementCount increment the value of count by 1
Defining class Counter in Java
/**
* A simple integer counter.
*/
public class Counter {
}
Definitions of features goes here.
Specifying a Method for a query
/**
* The number of items counted.
*/
public int currentCount () {
}
Method implementation goes here.
Type of value returned
by query.
Name of method.
Specifying a Method for a command
/**
* The number of items counted.
*/
public void incrementCount () {
}
Method implementation goes here.
Type of value returned
by command.
Name of method.
End

More Related Content

What's hot

Pursuing practices of Domain-Driven Design in PHP
Pursuing practices of Domain-Driven Design in PHPPursuing practices of Domain-Driven Design in PHP
Pursuing practices of Domain-Driven Design in PHP
Giorgio Sironi
 

What's hot (20)

Object Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesObject Oriented Programming Lecture Notes
Object Oriented Programming Lecture Notes
 
Object Oriented Programming Principles
Object Oriented Programming PrinciplesObject Oriented Programming Principles
Object Oriented Programming Principles
 
Pursuing practices of Domain-Driven Design in PHP
Pursuing practices of Domain-Driven Design in PHPPursuing practices of Domain-Driven Design in PHP
Pursuing practices of Domain-Driven Design in PHP
 
Lecture 1 - Objects and classes
Lecture 1 - Objects and classesLecture 1 - Objects and classes
Lecture 1 - Objects and classes
 
Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java
 
Chap01
Chap01Chap01
Chap01
 
Session 09 - OOPS
Session 09 - OOPSSession 09 - OOPS
Session 09 - OOPS
 
Object Oriented Paradigm
Object Oriented ParadigmObject Oriented Paradigm
Object Oriented Paradigm
 
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
 
Ruby OOP: Objects over Classes
Ruby OOP: Objects over ClassesRuby OOP: Objects over Classes
Ruby OOP: Objects over Classes
 
itft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in javaitft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in java
 
Java
JavaJava
Java
 
Dom structures
Dom structuresDom structures
Dom structures
 
Introduction to oop with c++
Introduction to oop with c++Introduction to oop with c++
Introduction to oop with c++
 
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,NoidaTeaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
 
Fundamentals of OOP (Object Oriented Programming)
Fundamentals of OOP (Object Oriented Programming)Fundamentals of OOP (Object Oriented Programming)
Fundamentals of OOP (Object Oriented Programming)
 
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3
 
Ifi7174 lesson3
Ifi7174 lesson3Ifi7174 lesson3
Ifi7174 lesson3
 
Module 6 : Essentials of Object Oriented Programming
Module 6 : Essentials of Object Oriented ProgrammingModule 6 : Essentials of Object Oriented Programming
Module 6 : Essentials of Object Oriented Programming
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 

Similar to Software Engineering Lec5 oop-uml-i

Object Modelling Technique " ooad "
Object Modelling Technique  " ooad "Object Modelling Technique  " ooad "
Object Modelling Technique " ooad "
AchrafJbr
 
Introduction to oop
Introduction to oop Introduction to oop
Introduction to oop
Kumar
 
unit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdf
unit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdfunit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdf
unit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdf
RojaPogul1
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
Jay Patel
 

Similar to Software Engineering Lec5 oop-uml-i (20)

ppt_ooad.pdf
ppt_ooad.pdfppt_ooad.pdf
ppt_ooad.pdf
 
Handout on Object orienetd Analysis and Design
Handout on Object orienetd Analysis and DesignHandout on Object orienetd Analysis and Design
Handout on Object orienetd Analysis and Design
 
Object Modelling Technique " ooad "
Object Modelling Technique  " ooad "Object Modelling Technique  " ooad "
Object Modelling Technique " ooad "
 
Ooad unit – 1 introduction
Ooad unit – 1 introductionOoad unit – 1 introduction
Ooad unit – 1 introduction
 
M01_OO_Intro.ppt
M01_OO_Intro.pptM01_OO_Intro.ppt
M01_OO_Intro.ppt
 
Lecture 1.pptx
Lecture 1.pptxLecture 1.pptx
Lecture 1.pptx
 
Ooad ch 2
Ooad ch 2Ooad ch 2
Ooad ch 2
 
Assignment 1 SYD601 2012 rick_danby completed with audio
Assignment 1 SYD601 2012 rick_danby completed with audioAssignment 1 SYD601 2012 rick_danby completed with audio
Assignment 1 SYD601 2012 rick_danby completed with audio
 
Ooad ch 1_2
Ooad ch 1_2Ooad ch 1_2
Ooad ch 1_2
 
Introduction to oop
Introduction to oop Introduction to oop
Introduction to oop
 
Cs2305 programming paradigms lecturer notes
Cs2305   programming paradigms lecturer notesCs2305   programming paradigms lecturer notes
Cs2305 programming paradigms lecturer notes
 
SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPT
 
unit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdf
unit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdfunit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdf
unit-1modellingconceptsclassmodeling-140929182538-phpapp01.pdf
 
5-CEN6016-Chapter1.ppt
5-CEN6016-Chapter1.ppt5-CEN6016-Chapter1.ppt
5-CEN6016-Chapter1.ppt
 
Analyzing a system and specifying the requirements
Analyzing a system and specifying the requirementsAnalyzing a system and specifying the requirements
Analyzing a system and specifying the requirements
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object-Oriented Analysis and Design
Object-Oriented Analysis and DesignObject-Oriented Analysis and Design
Object-Oriented Analysis and Design
 
Unit 1( modelling concepts & class modeling)
Unit  1( modelling concepts & class modeling)Unit  1( modelling concepts & class modeling)
Unit 1( modelling concepts & class modeling)
 
OOSE Unit 3 PPT.ppt
OOSE Unit 3 PPT.pptOOSE Unit 3 PPT.ppt
OOSE Unit 3 PPT.ppt
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
 

More from Taymoor Nazmy

More from Taymoor Nazmy (20)

Cognitive systems
Cognitive  systemsCognitive  systems
Cognitive systems
 
Cognitive systems
Cognitive  systemsCognitive  systems
Cognitive systems
 
Artificial intelligent Lec 5-logic
Artificial intelligent Lec 5-logicArtificial intelligent Lec 5-logic
Artificial intelligent Lec 5-logic
 
Artificial intelligent Lec 3-ai chapter3-search
Artificial intelligent Lec 3-ai chapter3-searchArtificial intelligent Lec 3-ai chapter3-search
Artificial intelligent Lec 3-ai chapter3-search
 
Lec 2-agents
Lec 2-agentsLec 2-agents
Lec 2-agents
 
Artificial intelligent Lec 1-ai-introduction-
Artificial intelligent Lec 1-ai-introduction-Artificial intelligent Lec 1-ai-introduction-
Artificial intelligent Lec 1-ai-introduction-
 
Image processing 2
Image processing 2Image processing 2
Image processing 2
 
Image processing 1-lectures
Image processing  1-lecturesImage processing  1-lectures
Image processing 1-lectures
 
Software Engineering Lec 10 -software testing--
Software Engineering Lec 10 -software testing--Software Engineering Lec 10 -software testing--
Software Engineering Lec 10 -software testing--
 
Software Engineering Lec 8-design-
Software Engineering Lec 8-design-Software Engineering Lec 8-design-
Software Engineering Lec 8-design-
 
Software Engineering Lec 7-uml-
Software Engineering Lec 7-uml-Software Engineering Lec 7-uml-
Software Engineering Lec 7-uml-
 
Software Engineering Lec 4-requirments
Software Engineering Lec 4-requirmentsSoftware Engineering Lec 4-requirments
Software Engineering Lec 4-requirments
 
Software Engineering Lec 3-project managment
Software Engineering Lec 3-project managmentSoftware Engineering Lec 3-project managment
Software Engineering Lec 3-project managment
 
Software Engineering Lec 2
Software Engineering Lec 2Software Engineering Lec 2
Software Engineering Lec 2
 
Software Engineering Lec 1-introduction
Software Engineering Lec 1-introductionSoftware Engineering Lec 1-introduction
Software Engineering Lec 1-introduction
 
Lec 6-
Lec 6-Lec 6-
Lec 6-
 
presentation skill
presentation skillpresentation skill
presentation skill
 
Lec 4
Lec 4Lec 4
Lec 4
 
Lec 3
Lec 3Lec 3
Lec 3
 
Lec 2
Lec 2Lec 2
Lec 2
 

Recently uploaded

678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
plant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated cropsplant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated crops
parmarsneha2
 

Recently uploaded (20)

INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
plant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated cropsplant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated crops
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 

Software Engineering Lec5 oop-uml-i

  • 2. Object-Oriented in Software lifecycle • Types of object oriented paradigms in SLC: – Object-oriented analysis (OOA) – Object-oriented design (OOD) – Object-oriented programming (OOP) – Object-oriented testing (OOT)
  • 3. Why OOP? • “Software Crisis” in procedural programming: – Too many modules… – Too many functions… An expensive mess!!! – Too many variables… • While OOP approach provides: 1-Greater Reliability – Break complex software projects into small, self- contained, and modular objects 2- Maintainability – Modular objects make locating bugs easier, with less impact on the overall project
  • 4. Benefits of OOP.. • 3- Inheritance: Elimination of Redundant Code and extend the use of existing classes. • 4- Encapsulation: Helps in building secure programs. • 5- Easy to map objects in problem domain to those objects in the program. • 6- It is easy to partition the work in a project based on objects.
  • 5. analysis requirements design using class / object diagrams programming (coding / testing / debugging) in Java OOD OOP: background Simula 1967 C ++ Late 1980s Smalltalk 1972 Java 1991 The UML 1996 C# 2000+ Software life cycle OOPOOA
  • 6. Procedural vs. OOP • Data Structure A • Data Structure B • Data Structure C • Function A1 • Function A2 • Function B • Function C • Class A – Data Structure A – Function A1 – Function A2 • Class B – Data Structure B – Function B • Class C – Data Structure C – Function C
  • 7.
  • 8. Examples of Objects Figure 1.9: Examples of objects CAR VDU BOY GIRL TREEBOOK CLOCK TRIANGLE
  • 9. Class Candidates • External Entities – devices or people • Things in Problem Domain – Reports, displays, signals • Events – completion of some task • Roles – manager, engineer, salesperson • Organizational Units – divisions, groups, teams • Structures – sensors, vehicles, computers
  • 10. Unified Modeling Language • UML (Unified Modeling Language) is a modeling technique, which is well suited for object-oriented programming  The UML is approved as a standard and has become widely accepted in the IT industry  The UML is a modeling language, not a software development process; it intends to support different object oriented approaches to software production
  • 11. Object Oriented Paradigm The General Principle “ An object oriented program is structured as a community of interacting agents called objects. Action is initiated in object oriented programming by the transmission of a message to an agent (an object). The message encodes the request for action and is accompanied by additional information (arguments) needed to carry out the request. The receiver is the agent to which the message is sent. If the receiver accepts the message it accepts the responsibility to carry out the indicated action. In response to a message the receiver will perform some method to satisfy the request. “
  • 12. OO Concepts • Object – encapsulates both data (attributes) and data manipulation functions (called methods, operations, and services) • Class – generalized description (template or pattern) that describes a collection of similar objects • Superclass – a collection of objects • Subclass – an instance of a class
  • 13. Classes: Objects with the same attributes and behavior Person Objects Vehicle Objects Polygon Objects Abstract Person Class Attributes: Operations: Name, Age, Sex Speak(), Listen(), Walk() Into Abstract Vehicle Class Attributes: Operations: Name, Model, Color Start(), Stop(), Accelerate() Into Abstract Polygon Class Attributes: Operations: Draw(), Erase(), Move() Vertices, Border, Color, FillColorInto Figure 1.12: Objects and classes
  • 14. Inheritance • New data types (classes) can be defined as extensions to previously defined types. • Parent Class (Super Class) – Child Class (Sub Class) • Subclass inherits properties from the • parent class. Parent Child Inherited capability
  • 15. Inheritance - Example • Example – Define Person to be a class • A Person has attributes, such as age, height, gender • Assign values to attributes when describing object – Define student to be a subclass of Person • A student has all attributes of Person, plus attributes of his/her own ( student no, course_enrolled) • A student has all attributes of Person, plus attributes of his/her own (student no, course_enrolled) • A student inherits all attributes of Person – Define lecturer to be a subclass of Person • Lecturer has all attributes of Person, plus attributes of his/her own ( staff_id, subjectID1, subjectID2)
  • 16. Inheritance - Example • Circle Class can be a subclass (inherited from ) of a parent class - Shape Shape Circle Rectangle
  • 17. Inheritance - Example • Inheritance can also have multiple levels. Shape Circle Rectangle GraphicCircle
  • 18. What is Polymorphism? • The ability to hide many different implementations behind a single interface Manufacture A Manufacture B Manufacture C
  • 19. What is Encapsulation • Hide implementation from clients • Clients depend on interface It associates the code and the data it manipulates into a single unit; and keeps them safe from external interference and misuse. Data Functions
  • 20. What is Abstraction? Counter Queue Item • An example of an item purchasing abstraction • A model that includes most important aspects of a given problem while ignoring less important details
  • 21. Java’s OO Features OOP Paradigm Encapsulation Multiple Inheritance Genericity Delegation Persistence Polymorphism Single Inheritance Data Abstraction Java
  • 22. Object = Identity + State + Behavior • Identity – Distinguishes an object from all other objects. • State – Consists of a set of attributes (or fields), which have names, types, and values. • Behavior – Defined by the set of operations (or methods) that may operate on the object. – Each method has a name, a type, and a value, where • The type consists of the return type and the list of parameter types of the method, often called signature. • The value is the implementation of the method often expressed as a sequence of statements, in languages like Java and C++.
  • 23. objects – oo-program: consists of a set of communicating objects – object: fundamental abstractions to build software systems where do objects come from ? • From the problem statement • Analyze the problem to identify objects – e.g.: program to manage bank accounts • accounts (Account) • customers (Customer) • transactions (Transaction) • “money machines” (ATM) • windows (MainWindow)
  • 24. objects: notation • representation object-name : Type name steven : Person c1 : Circle
  • 25. objects: attributes and operations – example: • account (Account) objects: – attributes: number of account (accountnumber) name of owner (owner) date of opening (date opened) balance at opening initial balance) balance today (current balance) operations: on deposit (deposit) on transfer (transfer) on withdrawl (withdrawal) what’s my balance ? (get balance) queries and commands
  • 26. objects: notation – attributes and operations c1 : Circle 20.6 radius getRadius getCircumference getSurface
  • 27. myAccount : Account 098-2356784-45 accountnumber deposit withdraw get balance … 3/10/2004 date opened 1345.04 current balance
  • 28. dirk : Person Dirk Smith name getName getGender itsYourBirthday … m gender 21 age … current account … savings account
  • 29. dirk : Person Dirk Smith name getName getGender itsYourBirthday … m gender 21 age … current account … savings account :Account 045-5873784-53 accountnumber deposit withdraw get balance … 2/10/2004 date opened 10945.05 current balance :Account 098-2356784-45 accountnumber deposit withdraw get balance … 3/10/2004 date opened 1345.04 current balance
  • 30. Class Compartments • A class is comprised of three sections • The first section contains the class name • The second section shows the structure (attributes) • The third section shows the behavior (operations) Lecturer Name save() change() delete() empID create()
  • 31. Class Compartments (cont.) • The second and third sections may be suppressed if they need not be visible on the diagram Lecturer Name save() change() delete() empID create() Lecturer Name empID Lecturer save() change() delete() create() Lecturer Lecturer
  • 32. Example of specification for Counter • Start listing its responsibilities: – Class: Counter • queries: – currentCount the current value of count, a non- negative integer • commands: – reset set the value of count to 0 – incrementCount increment the value of count by 1
  • 33. Defining class Counter in Java /** * A simple integer counter. */ public class Counter { } Definitions of features goes here.
  • 34. Specifying a Method for a query /** * The number of items counted. */ public int currentCount () { } Method implementation goes here. Type of value returned by query. Name of method.
  • 35. Specifying a Method for a command /** * The number of items counted. */ public void incrementCount () { } Method implementation goes here. Type of value returned by command. Name of method.
  • 36. End