This document discusses object-oriented concepts in software development. It describes the four main types of object-oriented paradigms used in the software lifecycle: object-oriented analysis, design, programming, and testing. It then explains some benefits of the object-oriented approach like modularity, reusability, and mapping to real-world entities. Key concepts like inheritance, encapsulation, and polymorphism are defined. The document also provides examples of how classes and objects are represented and compares procedural with object-oriented programming.
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.
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
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
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)
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
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.