Object Oriented Modeling and Design
Object Oriented Modeling and Design
For example, the "Car" subclass might have a number of doors property
and a method to start the engine, while the "Truck" subclass might have a
cargo capacity property and a method to load and unload cargo. By using
classification in this way, we can create a simple and flexible system for
representing different types of vehicles in our code.)
● Implementation: Writing the code for the objects and bringing the software
to life.
Each stage involves careful consideration of various factors, such as user needs,
data structure, and software architecture, to ensure a successful and effective
final product.
● Combining data and behavior: Objects in OOP contain both data and the
functions that manipulate that data, making the relationship between data
and behavior clear and straightforward.
These points are fundamental to OOP and help to make it an effective approach
for software development, as they allow for efficient and modular design, flexible
and reusable code, and improved maintainability.
Module 2
Phases of OMT:
1. Analysis:
The Analysis phase is the first phase of OMT, and it is focused on understanding
the problem domain and requirements of the system. The requirements are then
transformed into a conceptual model, which consists of objects, attributes, and
relationships. The analysis phase helps to identify the main functionalities of the
system and the interactions between its various components. In this phase, the
following three models are created:
● Object Model: This model is used to identify the objects in the system and
their relationships with each other. The object model is created by
analyzing the system requirements and identifying the objects that are
needed to fulfill those requirements.
● Dynamic Model: This model is used to describe the behavior of the
system and how the objects interact with each other over time. The
dynamic model is created by identifying the events that trigger changes in
the system and the actions that the objects take in response to those
events. It includes sequence diagrams, activity diagrams, and state
diagrams that show how objects interact with each other to perform the
behaviors of the system.
● Functional Model: This model is used to describe the functions that the
system must perform. The functional model is created by identifying the
tasks that the system must perform and the objects that are involved in
those tasks.
2. System Design:
The System Design phase is the second phase of OMT, and it is focused on
defining the architecture of the system.
In this phase, the conceptual model developed during the analysis phase is
refined and transformed into a system design. The system design specifies how
the system will be implemented and how its components will interact with each
other. This phase involves the identification of subsystems, interfaces, and their
interactions.
3. Object Design:
The Object Design phase is the third phase of OMT, and it is focused on
designing the details of the objects in the system.
In this phase, the system design is further refined to focus on the design of
individual objects and their interactions. The design of the objects is based on the
attributes and behaviors identified during the analysis phase. Object design
involves the creation of class diagrams, sequence diagrams, and state transition
diagrams.
4. Implementation:
The Implementation phase is the fourth and final phase of OMT, and it is focused
on actually implementing the system. In this phase, the code is written and tested
to ensure that it meets the requirements of the system. The implementation
phase is not represented by a model, but rather by the actual code that is written
for the system.
There are three types of models in the object oriented modeling and designing
they are:
● Class Model
● State Model
● Interaction Model
1. Class Model :
A Class Model is an object-oriented model used to represent the structure
and behavior of a software system. It defines the attributes and behaviors
of objects, as well as the relationships between objects. The Class
Diagram is the corresponding diagram used to represent the Class Model.
Example: Consider a banking system, where we can create a Class Model with
classes such as Account, Customer, and Transaction.
● The Account class may have attributes such as account number, balance,
and account type, and methods such as deposit and withdrawal.
● The Customer class may have attributes such as name, address, and
phone number, and methods such as update contact information.
● The Transaction class may have attributes such as transaction ID, amount,
and date, and methods such as record transaction.
2. State Model :
A State Model is an object-oriented model used to represent the behavior
of an object over time. It shows how an object behaves in different states
and how it transitions from one state to another. The State Diagram is the
corresponding diagram used to represent the State Model.
● In the Red state, the traffic light displays a red light and stops traffic.
● In the Green state, the traffic light displays a green light and allows
traffic to move.
● In the Yellow state, the traffic light displays a yellow light to warn
drivers that the light is about to change.
3. Interaction Model :
An Interaction Model is an object-oriented model used to represent the
interactions between objects in a software system. It shows how objects
communicate with each other and how they collaborate to accomplish a
task. The following diagrams are used to show the interaction model :
● Use case Diagram:
A use case diagram is a high-level diagram that shows the
interactions between actors (users or external systems) and the
system being modeled. It provides a graphical overview of the
system's functionality from a user's perspective.
● Sequence Diagram:
Sequence diagrams, on the other hand, show the interactions
between objects in a time-ordered manner, depicting(portraying) the
messages exchanged between objects and the order in which they
occur.
● Activity Diagram:
Activity diagrams represent the flow of activities or actions within a
system, typically showing the sequence of activities, decision points,
and conditional branching.
Module - 3
Class Modeling
Class modeling typically involves the use of Unified Modeling Language (UML)
notation to create class diagrams that show the classes, their attributes,
methods, and relationships. The class diagram is a type of structural diagram
that provides a high-level view of the system's object-oriented design.
In class modeling, an object is an instance of a class that has its own state and
behavior. It can be thought of as a real-world object with its own identity, that
describes it from other objects in a system; state, that determines the properties
of an object as well as the values of the properties that the object holds; and
behavior, that represents externally visible activities performed by an object in
terms of changes in its state. For example, a car is an object that has properties
such as make, model, and year, and actions such as accelerating, braking, and
turning.
Link:
Association:
UML
UML (Unified Modeling Language) is a standardized visual modeling language
used to represent software systems. It was created by the Object Management
Group (OMG) to provide a common language for software development.
One of the benefits of using UML is that it can be used to generate code in
various programming languages. While UML is not a programming language
itself, the diagrams and models created using UML can be used as a blueprint to
generate code in languages such as Java, C++, and Python.
UML is not a programming language, but rather a set of tools and diagrams that
can be used to model software systems. UML diagrams can be used to represent
various aspects of a software system, including its structure, behavior, and
interactions with other systems. Some of the most commonly used UML
diagrams include:
Class Diagram :
● Class Name
The name of the class is only needed in the graphical representation of the
class. It appears on the top most compartment. A class name should
always start with a capital letter. A class name should always be in the
center of the first compartment.
● Attributes
An attribute is a named property of a class that describes the value holded
by each object of the class. A value is a piece of data.
● Operations
An operation is a function or procedure that may be applied to or by
objects in a class.
Object Diagram :
Object diagrams are useful for visualizing and communicating the structure of a
system, especially when dealing with complex object-oriented systems. They can
help identify potential design flaws or inconsistencies, and can aid in the testing
and debugging process. They are often used in conjunction with other UML
diagrams, such as class diagrams and sequence diagrams, to provide a more
complete view of the system.
Inheritance
@Generalization
Generalization is a fundamental concept in object-oriented programming (OOP)
that allows developers to model real-world concepts and relationships between
them. In object modeling, generalization refers to the process of creating a new
class from an existing class or classes, inheriting the attributes and behaviors of
the parent class(es) and adding additional attributes and behaviors specific to the
new class.
@Aggregation
For example, consider a car object that contains four wheel objects. The car
object is the container object, and the wheel objects are the contained objects.
The aggregation relationship between them can be represented as follows:
+-------+ +---------+
| Car |<>--| Wheel |
+-------+ +---------+
In this example, a car has four wheels, but the wheels can exist independently of
the car.
Abstract Class
An abstract class is a class that cannot be instantiated, meaning you cannot
create an object directly from an abstract class. Instead, you can only create
objects from its concrete subclasses. Abstract classes are used to define a
common interface for a group of related classes. It defines the common attributes
and methods that the subclasses will inherit and share.
An abstract class is defined using the "abstract" keyword in the class declaration.
An abstract class can have both abstract and non-abstract methods. An abstract
method is a method that is declared but not defined, meaning it has no
implementation in the abstract class. Instead, the implementation is provided by
its concrete subclasses.
Multiple Inheritance
For example, in a scenario where a class "Student" inherits from two parent
classes "Person" and "Scholarship", the "Student" class would have access to
attributes and methods defined in both parent classes. This allows for more
flexible and modular class design, as different classes with different
functionalities can be combined to create a more complex class.
#Meta Data
Metadata is data that describes other data. In other words, it provides information
about a particular set of data, such as its format, content, structure, or context.
Metadata is used to help manage and organize large amounts of data and make
it easier to search, access, and use.
…
#Constraints
2. Behavioral constraints: These constraints define the rules that govern the
behavior of the system, such as the order of method calls or the allowed
values for object attributes.
4. Integrity constraints: These constraints define the rules that ensure the
consistency and accuracy of the data in the system, such as constraints on
primary and foreign keys in a database.
Constraints on Objects
Constraints on objects refer to the rules and requirements that must be satisfied
by the objects in an object-oriented system. These constraints are used to
ensure that the objects behave correctly and meet the desired specifications.
There are several types of constraints that can be applied to objects, including:
1. Attribute constraints: These constraints define the rules that govern the
values that can be assigned to an object's attributes. For example, an
object representing a person's age may have an attribute constraint that
requires the age to be a positive integer.
2. Relationship constraints: These constraints define the rules that govern the
relationships between objects. For example, an object representing a book
may have a relationship constraint that requires it to be associated with
one or more objects representing authors.
3. Behavior constraints: These constraints define the rules that govern the
behavior of objects. For example, an object representing a bank account
may have a behavior constraint that requires the balance to be updated
whenever a deposit or withdrawal is made.
4. Integrity constraints: These constraints define the rules that ensure the
consistency and accuracy of the data in the system. For example, an
object representing a database record may have an integrity constraint that
requires a certain field to be unique.
Module - 4
State Modeling
In the context of object-oriented programming (OOP), state modeling is a
technique used to represent the different states that an object can be in during its
lifecycle. It involves defining a set of attributes that describe the state of the
object, and a set of operations that can be performed on the object to change its
state.
For example, let's say we have a class called "Car" that represents a car object.
The state of a car object can be described by attributes such as its speed, fuel
level, and gear. The behaviors that can be performed on the car object to change
its state might include accelerating, braking, and shifting gears.
By modeling the different states of an object and the transitions between those
states, we can better understand how the object behaves and can design more
effective and efficient software systems. State modeling is a powerful tool for
designing complex software systems, especially those that involve many objects
and interactions between those objects.
Event
Events can also have associated conditions or actions that are executed when
the event occurs. For example, in the vending machine example, an event might
have a condition that checks whether the user has inserted enough coins to
make a payment, and an action that deducts the payment from the user's
account.
Overall, events play a critical role in state modeling, as they represent the
external inputs that drive state transitions and enable the system to respond to
changes in its environment or user interactions.
States
For example, consider a traffic light system at an intersection. The traffic light
system can be modeled as a state machine, with states such as "green",
"yellow", and "red", representing the different states of the traffic lights. At any
given time, the traffic light system is in one of these states, and the state
determines the behavior of the traffic lights, such as which lights are illuminated
and for how long.
States can also have associated actions or behaviors that are performed when
the system enters or exits the state. For example, when the traffic light system
transitions from the "green" state to the "yellow" state, it might activate a warning
signal to alert drivers to prepare to stop.
Overall, states play a fundamental role in state modeling, as they enable us to
represent the different modes or conditions of a system and how it behaves
under different circumstances. By defining states and the transitions between
them, we can create a model of a system that accurately reflects its behavior and
can be used to analyze, design, and simulate the system's behavior under
different scenarios.
State Diagram
For example, consider a simple vending machine that accepts coins and
dispenses candy. The state diagram for the vending machine might have states
such as "idle", "waiting for payment", "dispensing", and "out of order", and
transitions between these states that are triggered by events such as "coin
inserted" or "candy dispensed".
State diagrams can be used to model the behavior of a wide variety of systems,
from simple machines like vending machines to complex software systems with
many interacting components. They are a powerful tool for visualizing and
understanding the behavior of systems, and can help to identify potential errors,
inefficiencies, or improvements in the design of a system.
Parts of states
A state model represents the behavior of a system as a sequence of states,
where each state corresponds to a specific condition or situation in the system. A
state consists of a set of attributes that describe the system's behavior,
characteristics, and values at a particular point in time.
The parts of a state in a state model can vary depending on the specific system
being modeled, but typically include:
● State name: A unique identifier for the state that is easy to understand and
remember.
● Attributes: The set of variables or properties that describe the state of the
system, such as temperature, pressure, velocity, etc.
● Events: The actions or stimuli that cause the system to transition from one
state to another, such as user input, sensor readings, or time-based
triggers.
Together, these parts of a state help to create a clear and comprehensive model
of a system's behavior, allowing designers, developers, and other stakeholders to
better understand how the system operates and how it can be improved or
optimized.
Module - 5
A use case diagram is a type of UML (Unified Modeling Language) diagram that
describes the behavior of a system or application from the point of view of its
users. It consists of several components, including:
Actors: Actors are the external users, systems, or entities that interact with the
system being modeled. Actors are represented by stick figures and are usually
located on the left side of the diagram.
Use cases: Use cases are the actions or tasks that a user or actor can perform
within the system. Use cases are represented by ovals and are usually located
on the right side of the diagram.
System boundary: The system boundary is a rectangle that encloses all the
actors and use cases that are part of the system being modeled. It represents the
boundaries of the system and the interactions that take place within it.
# symbols used in use case diagrams are important to remember. See in the
college pdf notes. #
SCENARIO :
A scenario in sequence modeling refers to a specific sequence of events or
actions that occur in a system or process. It describes how different
objects or components interact with each other to accomplish a particular
task or achieve a specific goal. In essence, a scenario outlines a story of
how a system or process behaves in response to certain events or actions.
Let's say we're modeling a simple online ordering system for a pizza
restaurant. One scenario we might consider is the "Place Order" scenario. It
could involve the following steps:
1. The customer selects the desired pizza and adds it to their order.
2. The customer enters their delivery address and payment information.
3. The system verifies the payment and delivery information and
displays a confirmation message to the customer.
4. The system sends the order to the restaurant's kitchen for
preparation.
5. The system updates the customer's order status to "Preparing" and
displays an estimated delivery time.
6. The delivery driver is notified of the order and begins the delivery
process.
7. The system updates the customer's order status to "Out for Delivery."
8. The driver delivers the pizza to the customer and marks the order as
complete.
This scenario outlines a specific sequence of events that must occur in the
system for a customer to successfully place an order and receive their
pizza. By modeling this scenario, we can identify any potential issues or
bottlenecks in the ordering process and optimize the system accordingly.
SEQUENCE DIAGRAM :
A sequence diagram is a type of UML (Unified Modeling Language) diagram
used in software engineering and system design. It represents the
interactions between objects or components in a system over time.
and system design, and can help ensure that systems are designed and
ACTIVITY MODEL
0-level DFD:
It is also known as a context diagram. It’s designed to be an abstraction
view, showing the system as a single process with its relationship to
external entities. It represents the entire system as a single bubble with
input and output data indicated by incoming/outgoing arrows.
1-level DFD:
In 1-level DFD, the context diagram is decomposed into multiple
bubbles/processes. In this level, we highlight the main functions of the
system and breakdown the high-level process of 0-level DFD into
subprocesses.
2-level DFD:
2-level DFD goes one step deeper into parts of 1-level DFD. It can be used to
plan or record the specific/necessary detail about the system’s functioning.
Module - 6
1. System Conception: This is the initial stage where the idea for the system
is conceived. At this stage, the goals and objectives of the system are
defined, and a feasibility study is conducted to determine if the system is
viable.
2. Analysis: This stage involves gathering and analyzing requirements for the
system. Requirements are typically gathered from stakeholders and
end-users of the system. The analysis phase aims to identify the objects,
classes, and relationships that will form the system's architecture.
4. Class Design: In this stage, the detailed design of each class is created.
The class design includes defining the attributes, methods, and
relationships of each class. The design is typically represented using UML
class diagrams.
Development Lifecycle
Requirements
gathering
|
v
System Analysis
|
v
System Design
|
v
Detailed Design
|
v
Implementation
|
v
Testing
|
v
Deployment
|
v
Maintenance
3. Detailed design: In this stage, the detailed design of each class is created.
The class design includes defining the attributes, methods, and
relationships of each class. The design is typically represented using UML
class diagrams.
Module - 7
Breaking a system into subsystems has several benefits. It makes the system
easier to understand, design, and implement, as the complexity is reduced by
dividing the system into smaller, more manageable pieces. It also allows for
greater flexibility, as each subsystem can be developed and tested
independently, making it easier to add new features or modify existing ones.
2. Identity Concurrency
In the context of system design, identifying concurrency refers to the process of
identifying areas of a system where multiple tasks or processes can be executed
simultaneously or in parallel. Concurrency is an important aspect of system
design because it can significantly improve the performance, scalability, and
responsiveness of a system.
● Data volume and velocity: The amount of data that the system generates
and the rate at which it is generated.
● Data structure: The way data is organized and structured, including its
format, schema, and metadata.
● Access patterns: The frequency and manner in which the data will be
accessed, including read and write operations.
● Security and compliance: The need to protect sensitive data, comply with
relevant regulations, and ensure data privacy.
● Scalability: The ability to expand storage capacity as the system grows and
more data is generated.
There are various software control strategies that can be used in system design,
including:
Fuzzy Logic Control: This is a control strategy that uses fuzzy logic rules to
manage the system's behavior based on a set of linguistic rules.
State Space Control: This is a control strategy that represents the system's
behavior using a set of state variables, and adjusts the system's behavior based
on the current state of the system.
Boundary Analysis: This involves analyzing the constraints and limitations that
arise at each boundary, and determining the impact of these boundary conditions
on the behavior and performance of the system.
Some of the key considerations for setting trade-offs and priorities in system
design include:
Risk Analysis: This involves identifying potential risks and uncertainties in the
system design, and assessing their impact on the system's performance and
behavior.
Cost-Benefit Analysis: This involves analyzing the costs and benefits
associated with different design options and making informed decisions about the
most effective use of resources.
Iterative Design: This involves iterating and refining the system design based on
feedback from stakeholders and users, and making adjustments to priorities and
trade-offs as necessary.
Overall, setting trade-offs and priorities in system design is a critical aspect of the
design process, and requires careful consideration of the system's
requirements, constraints, and priorities. By making informed decisions about the
allocation of resources and functionality, system designers can develop systems
that meet the most critical and important requirements, while minimizing the
impact of constraints and trade-offs.
These are just a few examples of common architecture styles in system design.
The choice of architecture will depend on the specific requirements of the system
and the preferences of the development team.
User Interface Class: This class handles the user interface of the ATM, including
displaying options and messages to the user and receiving input from the user.
Account Class: This class represents the user's account information, including
account number, PIN, and balance. It also provides methods to access and
modify the account information, such as checking the balance, depositing funds,
and withdrawing funds.
Bank Class: This class represents the bank that operates the ATM. It provides
methods to authenticate user accounts and validate transactions, such as
checking if the user's PIN is correct and if the account has sufficient funds.
Cash Dispenser Class: This class represents the cash dispenser mechanism of
the ATM. It provides methods to dispense cash to the user, based on the user's
requested amount and the availability of funds in the ATM.
Receipt Printer Class: This class represents the receipt printer mechanism of
the ATM. It provides methods to print receipts for each transaction that the user
performs, including the transaction type, amount, and time.
These classes can be organized into a hierarchy, with the User Interface class at
the top level and the other classes as sub-levels. The Bank class can also be
further subdivided into more specific classes, such as the Authorization Class for
authenticating user accounts, and the Transaction Validation Class for validating
transactions.
Programming styles
1. Reusability :
Reusability is an important concept in object-oriented programming (OOP) that
refers to the ability to reuse existing code in new contexts or projects. In OOP,
reusability is achieved through the use of classes and objects.
One way that OOP achieves reusability is through inheritance. Inheritance allows
new classes to be created that inherit properties and methods from existing
classes. This can save time and effort in development by allowing developers to
reuse existing code, rather than starting from scratch.
Another way that OOP achieves reusability is through the use of interfaces.
Interfaces define a set of methods that a class must implement in order to be
considered compatible with the interface. By implementing an interface, a class
can be used in different contexts where that interface is required, regardless of its
specific implementation.
2. Extensibility :
Extensibility is another important concept in object-oriented programming (OOP)
that refers to the ability to easily extend and modify existing code to
accommodate new requirements or functionality.
In OOP, extensibility is achieved through the use of inheritance, interfaces, and
polymorphism. By creating well-designed classes and interfaces, developers can
create code that can be easily extended and modified without affecting the
existing code.p
Inheritance allows new classes to be created that inherit properties and methods
from existing classes, which can then be extended or overridden as needed. This
allows for the creation of new functionality without modifying the existing code,
making it easier to maintain and update.
Interfaces provide a way to define a set of methods that a class must implement
in order to be considered compatible with the interface. This allows for the
creation of new classes that can be used in place of existing classes, as long as
they implement the required interface.
Polymorphism allows for the use of objects of different types in the same way,
which can make code more flexible and adaptable. By defining methods with the
same signature in different classes, those methods can be used interchangeably,
regardless of the specific class of the object.
3. Robustness :
Robustness is an important concept in object-oriented programming (OOP) that
refers to the ability of a program to handle unexpected or erroneous inputs and
situations without crashing or producing incorrect results.
In addition, OOP provides several features that can help improve the robustness
of a program. Encapsulation, for example, can help prevent unintended
modifications to the state of an object, while inheritance and polymorphism can
make code more flexible and adaptable.
4. Programming-in-the-large :
Programming in the large is a concept in object-oriented programming (OOP)
that refers to the development of large-scale software systems. In large-scale
systems, OOP can be used to create modular and maintainable code that is
easier to develop, test, and maintain.
In OOP, programming in the large typically involves the use of design patterns,
which are standardized solutions to common programming problems. Design
patterns can help developers create code that is reusable, extensible, and
maintainable.