0% found this document useful (0 votes)
13 views8 pages

Unit 5 OODesign 09 Dec 2024

Uploaded by

cst1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views8 pages

Unit 5 OODesign 09 Dec 2024

Uploaded by

cst1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

OBJECT-ORIENTED ANALYSIS AND MODELING (OOA/OOM)

In software engineering, object-oriented analysis and modelling (OOA/OOM) is a methodological


approach that emphasizes comprehending and creating a system based on object-oriented (OO)
programming concepts. Real-world issues and their resolutions are to be modeled as objects, which are
instances of classes. These objects work together to solve problems by encapsulating behavior (methods
or functions) and the data (attributes).
1. Object-Oriented Analysis (OOA)
The method of examining and comprehending a problem domain by determining the objects, their
characteristics, and their behaviors is known as object-oriented analysis. OOA's primary objective is to
develop a model that outlines the functions that the system must have without considering how it will
be put into practice just yet.
In other words, Object-Oriented Analysis is the process of analyzing and understanding a problem
domain by identifying the objects, their attributes, and their behaviors. The main goal of OOA is to create
a model that describes what the system needs to do, without worrying about how it will be implemented
yet.
Key concepts in OOA:
 Objects: Real-world entities that have both state (attributes) and behavior (methods).
 Classes: Blueprints or templates for creating objects. A class defines the attributes and behaviors
that its objects will have.
 Attributes: Characteristics or properties of an object (e.g., name, age).
 Methods: Functions or operations that an object can perform (e.g., calculate area, update
address).
 Relationships: How objects interact with each other (e.g., association, inheritance, aggregation).

2. Object-Oriented Modeling (OOM)


Object-Oriented Modeling extends OOA into a more formalized representation of the system, often with
diagrams that describe the structure and behavior of the system. The most common tool for object-
oriented modeling is the Unified Modeling Language (UML), which includes various types of diagrams.
Key activities in OOM:
 Modeling the system's structure: Creating class diagrams, which show how classes are related,
their attributes, and their methods.
 Modeling the system’s behavior: Using sequence diagrams, activity diagrams, and state
diagrams to model the dynamic behavior of the system.
 Modeling interactions: Creating use case diagrams to show how users interact with the system,
and collaboration or communication diagrams to show how objects collaborate to perform a task.
Key UML Diagrams in OOM
 Class Diagram: Represents the static structure of a system, including classes, attributes,
operations, and relationships like inheritance and associations.
 Use Case Diagram: Describes the functional requirements of a system by showing how users
(actors) interact with the system's functionality (use cases).
 Sequence Diagram: Illustrates how objects interact in a particular sequence, showing messages
passed between objects.
 State Diagram: Models the different states an object can be in and the transitions between those
states.
 Activity Diagram: Models the workflow or activities in a system, representing decision points,
parallel activities, and process flows.

OOA/OOM Process:
1. Requirements Gathering: Identify the requirements of the system, often through
communication with stakeholders.
2. Object Identification: Determine the key objects (entities) in the problem domain.
3. Class Definition: Define the classes based on the identified objects, specifying their attributes
and methods.
4. Define Relationships: Model how classes relate to one another (inheritance, association,
composition, etc.).
5. Model System Behavior: Use UML diagrams to model how objects interact and how the system
behaves over time.
6. Refinement and Iteration: Continuously refine the model as new requirements emerge or
changes occur, ensuring the system stays aligned with its goals.

Benefits of Object-Oriented Analysis and Modeling:


 Improved Communication: OO models provide a clear and visual way of communicating system
design and behavior, which is accessible to both technical and non-technical stakeholders.
 Modularity and Reusability: OO principles like inheritance and polymorphism encourage
reusable and modular code, which can reduce redundancy and simplify maintenance.
 Easier Maintenance: Since objects encapsulate both data and behavior, it’s easier to update a
system by modifying individual objects or classes without affecting other parts of the system.
 Better Alignment with Real-World Systems: OOA/OOM encourages thinking about real-world
entities and processes, making the system more intuitive to design and understand.
1. Object-Oriented Analysis:
o Identify the objects: Product, Customer, Order, Supplier, etc.
o Define attributes: A Product might have attributes like name, price, and quantity.
o Define methods: A Product might have methods like updateQuantity(), applyDiscount().
o Identify relationships: For example, a Customer places an Order, and an Order contains one
or more Products.
2. Object-Oriented Modeling:
o Create a class diagram showing the relationships between classes such as Product,
Customer, Order, and Supplier.

o Create a sequence diagram to model the interaction between a customer and the system
when placing an order.
o Create a use case diagram to show the actions available to different actors (customers,
admin) like Place Order, View Product, etc.
DATA MODELING IN OBJECT-ORIENTED ANALYSIS AND DESIGN (OOAD)
Data modeling in Object-Oriented Analysis and Design (OOAD) involves creating a structured
representation of the system’s data, as well as understanding and defining how that data interacts with
the system. In the context of OOAD, data modeling focuses on identifying and defining the objects (and
their attributes) that represent real-world entities, their relationships, and the interactions between
objects.
The goal of data modeling is to capture the essential data elements of the problem domain and translate
them into a structure that is both easy to understand and implement within the system, using object-
oriented principles like encapsulation, inheritance, and polymorphism.

Key Concepts of Data Modeling in OOAD:


1. Objects as Data Containers:
o In OOAD, data is encapsulated within objects (instances of classes). An object represents
a real-world entity and contains both attributes (data) and methods (behavior).
o Attributes define the data or properties of an object, while methods define its behavior
or operations.
2. Classes and Objects:
o A class is a blueprint or template for creating objects. The class defines the structure
(attributes) and behavior (methods) that objects of that class will have.
o An object is an instance of a class. It holds actual data for the attributes defined by the
class.
3. Attributes:
o These are the data fields or properties of an object. Each attribute holds some value that
defines the state of the object.
For example, a Customer class might have attributes like name, address, phoneNumber.
4. Relationships between Objects:
Data modeling in OOAD also involves identifying how objects relate to one another. These
relationships can be defined using various types of associations:
 Association: A relationship where one object is linked to another (e.g., a Customer
places an Order).
 Aggregation: A special type of association where one object is a "whole" and
other objects are its "parts" (e.g., a Team consists of multiple Players).
 Composition: A stronger form of aggregation where the existence of child
objects is dependent on the parent object (e.g., a House contains Rooms, and if the
house is destroyed, the rooms cease to exist).
 Inheritance: A mechanism where a new class (child class) inherits properties and
behaviors from an existing class (parent class), allowing for reuse and
specialization of data (e.g., a Manager class might inherit from a Employee class).
 Dependency: When one object depends on another to perform its operations
(e.g., a Car object depends on an Engine object).
5. Behavior of Data:
o In OOAD, the behavior associated with data is equally important as the data itself. The
data should not only be stored but also manipulated, validated, and processed using
methods defined in the object.
o Methods define how data can be accessed or modified and how objects interact with each
other to achieve system behavior. For example, methods in the Order class might include
addProduct(), calculateTotal(), or placeOrder().

The Role of UML in Data Modeling


UML (Unified Modeling Language) plays a significant role in visualizing, specifying, constructing, and
documenting data models in OOAD. Some of the key UML diagrams for data modeling in OOAD are:
 Class Diagram: Represents the static structure of the system, showing the classes, their
attributes, methods, and relationships (associations, inheritance, etc.). This is the primary
diagram used for data modeling in OOAD.
 Object Diagram: Shows an instance of the system at a specific moment in time, illustrating the
relationships between objects and their data.
 Use Case Diagram: While primarily used for behavior modeling, use case diagrams can provide
context on how different data elements (objects) interact with system users (actors).

Example of Data Modeling in OOAD:


Imagine designing a Library Management System. The key objects might include:
 Book:
o Attributes: title, author, price, pages, isbn, availability
o Methods: borrow(), returnBook(),reserve()
 Library:
o Attributes: libraryName, location
o Methods: addBook(), removeBook(), searchBook()
 LibraryMember:
o Attributes: name, membershipId, email, phoneNo
o Methods: checkOutBook(), reserveBook(), renewMembership()
 Relationships:
o A LibraryMember borrows a Book through a Loan.
o A Library contains many Books.

OBJECT-ORIENTED DESIGN (OOD) CONCEPTS


Object-Oriented Design (OOD) is a methodology for designing a software system using the principles of
object-oriented programming (OOP). It focuses on defining the system in terms of objects, which are
instances of classes that represent real-world entities or concepts. In OOD, the system's structure and
behavior are modeled in terms of objects that encapsulate data and functionality.
Here are the core Object-Oriented Design Concepts:
1. Encapsulation
 Definition: Encapsulation is the principle of bundling data (attributes) and methods (behavior)
that operate on the data into a single unit known as a class. This helps to hide the internal
implementation details from the outside world and restrict access to the internal state of an
object, providing a clear interface for interaction.
 Benefits:
o Data protection: Encapsulation protects the integrity of an object's data by preventing
outside components from directly modifying it.
o Simplified interface: Users of the class interact with a well-defined interface without
needing to understand the internal workings.
2. Abstraction
 Definition: Abstraction involves hiding complex implementation details and showing only the
essential features of an object. The goal of abstraction is to simplify interactions by focusing on
what an object does rather than how it does it.
 Benefits:
o Simplified interactions: The user interacts with high-level operations rather than dealing
with low-level details.
o Reduced complexity: Helps manage and reduce system complexity by abstracting away
unnecessary details.
3. Inheritance
 Definition: Inheritance is the mechanism by which one class (the child or subclass) can inherit
attributes and methods from another class (the parent or superclass). It allows for code reuse
and the creation of a hierarchical relationship between classes.
 Benefits:
o Code reuse: Common functionality is inherited by subclasses, reducing duplication.
o Extendability: New functionality can be added by extending existing classes without
modifying them.
4. Polymorphism
 Definition: Polymorphism allows objects of different classes to be treated as objects of a common
superclass. The primary benefit is that the same method name can be used for different types of
objects, with each class providing its own implementation (method overriding).
 Benefits:
o Flexibility: The same interface can be used to interact with objects of different types.
o Extendability: New subclasses can be added without changing the code that uses
polymorphism.
5. Composition (Has-a Relationship)
 Definition: Composition is a design principle where one object (the composite) contains
references to other objects (the components) as part of its state. Unlike inheritance, which
models an "is-a" relationship, composition models a "has-a" relationship (i.e., an object is
composed of other objects).
 Benefits:
o Flexibility: Objects can be composed dynamically and changed at runtime.
o Reusability: Components can be reused in different contexts without the need for
inheritance.
6. Coupling and Cohesion
 Coupling:
o Definition: Coupling refers to the degree of dependency between different classes or
modules. Loose coupling means that classes have minimal dependencies, while tight
coupling indicates high dependency.
o Benefit: Loose coupling improves maintainability and flexibility because changes in one
class are less likely to affect others.
 Cohesion:
o Definition: Cohesion refers to how closely the responsibilities of a class are related to
each other. A class with high cohesion means that its methods and attributes are closely
related to its primary responsibility.
o Benefit: High cohesion leads to more understandable, maintainable, and focused classes.
 Example:
o Loose Coupling: A class that interacts with another class through well-defined interfaces
or abstractions (e.g., using an interface or abstract class).
o High Cohesion: A BankAccount class should only focus on operations related to banking,
like deposits and withdrawals, rather than including unrelated functionality such as
printing customer statements.
7. Design Patterns
 Definition: Design patterns are reusable solutions to common design problems. They represent
best practices for organizing code and managing complexity.
 Common Design Patterns:
o Singleton: Ensures a class has only one instance and provides a global access point to it.
o Factory Method: Provides an interface for creating objects, but allows subclasses to alter
the type of objects that will be created.
o Observer: Defines a one-to-many dependency between objects so that when one object
changes state, all its dependents are notified.
o Strategy: Allows algorithms to be selected at runtime, enabling a class to delegate
responsibility to one of several strategies.

Relationship between Class and Object


In Object-Oriented Programming (OOP), the relationship between classes and objects is fundamental
to understanding how software systems are designed and implemented. Here’s a detailed explanation
of this relationship:
1. Class: The Blueprint or Template
 Definition: A class is a blueprint or template that defines the structure and behavior of objects.
It specifies what attributes (data) and methods (functions) the objects created from the class will
have. A class itself is not an instance of a real-world entity, but it serves as the foundation for
creating multiple instances (objects).
 Components of a Class:
o Attributes (or Properties): These represent the data or state of an object. Attributes are
defined in the class and can have default values, types, and access modifiers (e.g., private,
public).
o Methods (or Functions): These represent the behaviors or actions that objects of the class
can perform. Methods operate on the object's attributes or perform other operations.
2. Object: An Instance of a Class
 Definition: An object is an instance of a class. It is a specific realization of the blueprint defined
by the class. Each object has its own state (attribute values) and can invoke the behaviors
(methods) defined in the class.
 Characteristics of Objects:
o State: The state of an object is determined by the values of its attributes. Every object
created from the class has its own set of attribute values, which makes each object
unique.
o Behavior: Objects exhibit behavior by using the methods defined in the class. Each object
can have different results when invoking the same method (depending on its state).
 Creating an Object: To create an object, you instantiate a class by calling the class name, often
passing in arguments for its constructor.

Class and Object Relationship Summary


1. Class is a Template, Object is an Instance:
o A class defines the attributes and methods that are common to all objects of that class.
o An object is a specific instance of that class, with its own set of attributes (data), and it
can invoke the methods defined in the class.
2. Objects are Created from Classes:
o To create an object, the class is instantiated. This involves allocating memory for the
object and initializing its state through the constructor method ( __init__ in Python).
3. Multiple Objects, Same Class:
o Multiple objects can be created from a single class. Each object is independent, with its
own state, but they share the same structure and behavior (methods) defined in the class.
4. Objects have State and Behavior:
o The state of an object is defined by the values of its attributes.
o The behavior of an object is defined by its methods, which modify or interact with the
object's state.
5. Example (from the car analogy):
o Class (Car): A blueprint that defines the attributes (make, model, year, speed) and
methods (accelerate) that all cars will have.
o Object (car1, car2): Instances of the Car class with their own unique states (e.g., car1 has
"Toyota" as its make, while car2 has "Honda").

Key Differences between Class and Object


Aspect Class Object
A blueprint or template for creating
Definition An instance of a class.
objects.
Existence Exists as a definition in code. Exists at runtime after instantiation.
Defines attributes (variables) for Contains actual data (values) for these
Attributes
objects. attributes.
Defines the behavior that objects can Invokes the class methods to perform
Methods
perform. actions.
Example class Car: defines the structure of cars. car1 = Car() creates a specific car.

You might also like