Object-Oriented Analysis &
Design (OOAD)
Week 2
Zia ur Rehman
Object-Oriented Analysis & Design
Object-Oriented Analysis (OOA)
Understanding requirements and identifying objects/behaviors in a
system.
Example: For a ride-sharing app, analysis involves defining users,
drivers, rides, and payments.
Requirements gathering using Client’s interviews & Domain
knowledge.
Object-Oriented Design (OOD)
Planning / structuring how to implement the system using classes,
relationships, and patterns.
Example: Designing a Ride class with methods like RequestRide(),
AssignDriver(), UpdateLocation(), StartRide(), CalculateFare().
Object Modeling Technique (OMT)
Object Model (Data-Oriented)
Represents the static structure of the system using classes,
objects, attributes, and relationships.
what objects are in the system? how are they related?
In a Ride-Sharing App:
Objects: Rider, Driver, Ride, Payment.
Interactions: A Rider requests a Ride, which is assigned to a
Driver.
(Class Diagram)
Dynamic Model (Action-Oriented)
Captures behavior over time, including states, events, and
interactions between objects.
what events occur in the system?
when do they occur and in what order?
States: Conditions of an object (e.g., Ride can be Requested,
Ongoing, Completed).
Events: Triggers for state changes (e.g., "Driver accepts ride").
[Ride Requested] → [Driver Accepts] → [Driver Assigned] → [Ride Completed]
→ [CalculateFare]
(State Diagram)
Functional Model (both Data and Action-Oriented)
Describes data flow and processes that transform
inputs into outputs.
“what” does the system do?
Examples:
FoodPanda:
Data flow: Order → Restaurant → Rider → Payment.
Ride-Sharing App:
Rider request → Match driver → Calculate fare → Process
payment.
(Dataflow Diagram)
Four Phases of OMT
Analysis: goal is finding the problem statement.
Key Activities: Object Modeling, Dynamic Modeling, Functional
Modeling.
System Design determines overall architecture of system,
concurrent tasks and data storage.
Object Design concerned with classification of objects into
different classes and about attributes and necessary operations
needed.
Key Activities: Algorithm Design, Optimization, Data Structure
Selection, Error Handling.
implementation translates design into the software
(programming language).
Key activities: Coding, Testing, Integration.
Object Modeling
Concept Explanation Real-World Example
Objects & Class Represents real-world entities Car, Person
Links & Associations Defines relationships between Teacher-Student, Doctor-Patient
objects
Common characteristics inherited
Generalization & Inheritance by specific entities Vehicles (Cars, Bikes, Buses)
Grouping Constructs Organizes related objects together Library Sections, Mall Store
Categories
Aggregation "Has-a" relationship between Company-Departments, Car-Parts
objects
Abstract Class Concept that cannot be instantiated Shape (Circle, Rectangle), Animal
directly (Dog, Cat)
Multiple Inheritance Inheriting from multiple sources Smartphone (Phone + Computer),
Hybrid Car
Meta Data Data about data Book Information, Photo Details
Candidate Key Unique identifier in a database Student ID, Employee ID
Object Modeling - concepts
Class: A blueprint/template that defines the attributes and behavior
(methods) of objects.
Object: A specific instance of a class, representing a real-world entity.
Example:
Class: Student (attributes: studentID, name, Program;
methods: enrollCourse(), submitAssignment()).
Object: student1 = Student("2023-CS-804", "Ali", "Computer Science")
Links & Associations
Link (Object-Level Relationship):
A Link represents a specific connection between two objects
(instances) at a given moment. (e.g., a student attends a course).
A specific student (John) is enrolled in a specific course (CS102).
A specific doctor (Dr. Ahmed) treats a particular patient (Ali).
Association (Class-Level Relationship):
An Association represents a general relationship between two or
more classes. (e.g., a Student enrolls in a Course).
Doctor treat a Patient.
A Customer places an Order (one-to-many association).
A Student enrolls in a Course (many-to-many relationship).
Generalization & Inheritance
Generalization:
Abstracting common characteristics of multiple entities.
Creating a parent class (superclass) from common features of
subclasses.
Example: Bird generalizes Eagle and Sparrow.
Inheritance: A child entity inherits attributes/methods from a parent
entity.
Example:
Vehicle is a generalized concept that includes Cars, Bikes, and Buses.
All have wheels and an engine but differ in specific features.
Banking: SavingsAccount and CurrentAccount inherit from
Account.
Birds is a generalized category that includes Eagles, Sparrows, and
Penguins. Some can fly, while others cannot, but they all share
common bird traits.
Grouping Constructs
Used to group similar entities together for better organization.
Organizing classes into logical units (e.g., packages, namespaces)
Example:
A Library groups different sections like fiction, non-fiction,
research materials, and magazines.
A Shopping Mall groups stores into categories like clothing,
electronics, and food courts.
• Grouping by roles: Students, Faculty, Staff
• Grouping by departments: CS, Engineering, Business
Aggregation
A "has-a" relationship where parts can exist independently of
the whole.
Example:
Department has Students:
If the department closes, students still exist.
Car and Engine: A Car has an Engine, but an Engine can exist
separately from the Car.
Shopping Cart: A cart aggregates Product objects, but
products exist independently.
Abstract Class
Represents an idea or a concept that cannot be instantiated directly.
Imagine you are designing a Drawing Application where you need different
shapes (Circle, Square, Triangle).
• All shapes have a common characteristic: area and perimeter.
• But the formula to calculate the area differs for each shape.
• Instead of defining separate methods for each shape, we create an abstract
class Shape and let child classes implement their own version of area
calculation.
Example:
Shape is an abstract idea that includes specific shapes like Circle, Rectangle,
and Triangle.
Payment Systems: An abstract Payment class with subclasses like CreditCard,
JazzCash, EasyPaisa.
Multiple Inheritance
A class inheriting features from more than one parent class.
it provides descriptive information about objects, attributes,
or processes.
Example:
Hybrid Car: Inherits features from ElectricEngine and
CombustionEngine (conceptual).
Smartphone: Inherits features from Phone, Camera, and
Computer
Meta Data:
Data about data, providing descriptive information.
Example:
A Book's metadata includes title, author, publication date, and
ISBN.
When you take a photo using your phone, Meta Data is stored
along with the image.
It includes details about the photo, such as:
File Name: vacation.jpg
Date & Time Taken: 2024-02-12 14:30
Camera Model: iPhone 13 Pro
Image Resolution: 4000x3000 pixels
Location: New York, USA
Candidate Key:
A unique identifier for a database record.
Example:
In a Student Database, a Roll Number or Student ID can be a
candidate key because each student has a unique number.
Student Table:
Candidate Keys: studentID, email.
Primary Key: studentID (chosen candidate key).
In an Employee Database, an Employee ID or CNIC serves as a
unique identifier
Dynamic Modeling
• Events & States.
• Operations, Nested State Diagram
• Concurrency, Advanced Dynamic Modeling
Concepts