OOAD Unit 1 Notes
OOAD Unit 1 Notes
SYLLABUS:
Introduction to UML:
Introduction to UML:
Object orientation is a programming paradigm that organizes data and behavior into reusable
units called objects. In object-oriented programming (OOP), the focus is on the object, rather
than the logic required to handle it.
OOPs Concepts:
1. Class
2. Objects
3. Data Abstraction
4. Encapsulation
5. Inheritance
6. Polymorphism
7. Dynamic Binding
8. Message Passing
1. Class:
A class is a user-defined data type. It consists of data members and member functions, which can
be accessed and used by creating an instance of that class. It represents the set of properties or
methods that are common to all objects of one type. A class is like a blueprint for an object.
For Example: Consider the Class of Cars. There may be many cars with different names and
brands but all of them will share some common properties like all of them will have 4 wheels,
Speed Limit, Mileage range, etc. So here, Car is the class, and wheels, speed limits, mileage are
their properties.
2. Object:
It is a basic unit of Object-Oriented Programming and represents the real-life entities. An Object
is an instance of a Class. When a class is defined, no memory is allocated but when it is
instantiated (i.e. an object is created) memory is allocated. An object has an identity, state, and
behavior. Each object contains data and code to manipulate the data. Objects can interact without
having to know details of each other’s data or code, it is sufficient to know the type of message
accepted and type of response returned by the objects.
For example “Dog” is a real-life Object, which has some characteristics like color, Breed, Bark,
Sleep, and Eats.
Object
3. Data Abstraction:
Data abstraction is one of the most essential and important features of object-oriented
programming. Data abstraction refers to providing only essential information about the data to
the outside world, hiding the background details or implementation. Consider a real-life example
of a man driving a car. The man only knows that pressing the accelerators will increase the speed
of the car or applying brakes will stop the car, but he does not know about how on pressing the
accelerator the speed is increasing, he does not know about the inner mechanism of the car or the
implementation of the accelerator, brakes, etc in the car. This is what abstraction is.
4. Encapsulation:
Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that
binds together code and the data it manipulates. In Encapsulation, the variables or data of a class
are hidden from any other class and can be accessed only through any member function of their
class in which they are declared. As in encapsulation, the data in a class is hidden from other
classes, so it is also known as data-hiding.
Benefits:
Types of Encapsulation:
1. Data Encapsulation: Hides data attributes.
2. Method Encapsulation: Hides method implementation.
3. Behavioral Encapsulation: Hides object behavior.
Implementation Techniques:
1. Access Modifiers (public, private, protected).
2. Getter and Setter methods.
3. Encapsulated classes.
4. Interfaces.
5. Polymorphism:
The word polymorphism means having many forms. In simple words, we can define
polymorphism as the ability of a message to be displayed in more than one form. For example, A
person at the same time can have different characteristics. Like a man at the same time is a
father, a husband, an employee. So the same person posses different behavior in different
situations. This is called polymorphism.
Example
The classic example is of the Shape class and all the classes that are inherited from it, such as:
● Rectangle
● Triangle
● Circle
Types of polymorphism
● Compile time polymorphism
○ Example: Method overloading
● Runtime polymorphism
○ Example: Method overriding
Advantages of polymorphism:
● It helps programmers reuse code and classes once written, tested, and implemented.
● A single variable name can be used to store variables of multiple data types (float,
double, long, int, etc).
● It helps compose powerful, complex abstractions from simpler ones.
Inheritance
Inheritance is the mechanism that permits new classes to be created out of existing classes by
extending and refining its capabilities. The existing classes are called the base classes/parent
classes/super-classes, and the new classes are called the derived classes/child classes/subclasses.
The subclass can inherit or derive the attributes and methods of the super-class(es) provided that
the super-class allows so. Besides, the subclass may add its own attributes and methods and may
modify any of the super-class methods. Inheritance defines an “is – a” relationship.
Example
From a class Mammal, a number of classes can be derived such as Human, Cat, Dog, Cow, etc.
Humans, cats, dogs, and cows all have the distinct characteristics of mammals. In addition, each
has its own particular characteristics. It can be said that a cow “is – a” mammal.
Types of Inheritance
In Object-Oriented Analysis and Design (OOAD), an entity object represents a real-world object
or concept that has its own identity, properties, and behavior.
Example:
- Properties:
- Attributes: name, address, phone
- Behavior:
Genericity:
The concept of Generalization in OOAD is a powerful mechanism that enables abstraction,
reusability, and the creation of flexible and maintainable software architectures. Generalization is
the process of extracting common characteristics from a set of classes and abstracting them into a
more general superclass or interface.
What is Generalization?
Generalization is the process of extracting common characteristics from a set of classes and
abstracting them into a more general superclass or interface. It embodies the "is-a" relationship,
where a subclass is said to be a specialized version of its superclass, inheriting its attributes and
behaviors while potentially adding or modifying its own.
Importance of Generalization in OOAD
● Code Reusability: Generalization enables the reuse of code by allowing common
attributes and behaviors to be inherited by multiple classes.
● Abstraction: Generalization promotes abstraction by identifying commonalities
among classes and abstracting them into a higher-level superclass.
● Ease of Maintenance: By defining common characteristics in a superclass, changes
made to those characteristics propagate to all subclasses, reducing the need for
redundant modifications.
● Polymorphism: Generalization facilitates polymorphism, allowing objects of
different subclasses to be treated interchangeably through their common superclass
interface.
● Hierarchical Organization: Generalization provides a structured way to organize
classes into hierarchies, making the system easier to understand and maintain.
Specialization
Specialization is the reverse process of generalization. Here, the distinguishing features of groups
of objects are used to form specialized classes from existing classes. It can be said that the
subclasses are the specialized versions of the super-class.
The Bank Account class serves as the generalized representation of all types of bank accounts,
while the subclasses (Current Account, Savings Account, Credit Account) represent specialized
versions that inherit and extend the functionality of the base class.
Generalization vs. Specialization
Below are the differences between Generalization and Specialization:
It represents an "is-a-kind-of"
It represents an "is-a"
relationship, where subclasses
Relationship relationship, where subclasses
are more specialized versions
are types of the superclass.
of the superclass.
Modeling in OOAD
While creating software, imagine using blueprints to design a house that's what models do in
Object Oriented Analysis and Design (OOAD). Just like blueprints help us understand how a
house will be built, models in OOAD help developers visualize and plan out software before they
start coding. These models focus on identifying the objects or components of the software, how
they interact, and how they come together to make the software work.
What is OOAD?
Object-Oriented Analysis and Design (OOAD) is a structured approach used in software
engineering for planning, designing, and implementing software systems. OOAD uses the
principles of object-oriented programming to model a system based on real-world objects, their
properties, behaviors, and how they interact with each other. This approach is beneficial for
system design because it allows developers to break down complex systems into manageable
components, making the development process more efficient and the systems more scalable and
maintainable.
● Analysis in OOAD: During the analysis phase, the focus is on understanding the
problem domain, identifying the requirements of the system, and modeling the
system's functionality without deciding on how the system will be implemented.
● Design in OOAD: The design phase takes the outcomes of the analysis phase and
plans how the system will achieve its requirements. This involves defining the
software architecture, choosing data structures and algorithms, and detailing the
design of the system's objects and their interactions.
Models in OOAD
In Object-Oriented Analysis and Design (OOAD), models are used to visualize, specify,
construct, and document the design of software systems. These models provide various
perspectives of the system, enabling developers to see the big picture, as well as the finer details
of the design. Below are the key models in OOAD, each serving a distinct purpose in system
design.
To identify the interactions between external actors, users or other systems and the system itself,
detailing the system's functional requirements.
Components:
To describe the structure of the system in terms of objects (instances of classes), their attributes,
and relationships.
Components:
● Classes: Templates that define the properties attributes and behaviors methods of
objects.
● Attributes: Characteristics or properties of classes.
● Operations Methods: Functions or behaviors that can be performed by an object.
● Associations: Relationships between classes indicating how instances of one class
connect to instances of another.
● Class Diagrams: UML diagrams that depict the classes, their attributes, operations,
and the relationships among them.
To detail how objects within the system interact with each other over time to carry out specific
functions.
Components:
● Sequence Diagrams: Focus on the time sequence of message exchanges between
objects. They show how objects interact in a particular scenario of a use case.
● Communication Diagrams: Highlight the way in which objects that transmit and
receive messages are structured. Collaboration diagrams offer a more comprehensive
perspective of the object organization, even though they are identical to sequence
diagrams.
To model the dynamic behavior of a single object, showing how the object changes state in
response to events.
Components:
● States: Different conditions in which an object can exist.
● Transitions: The movement from one state to another, typically triggered by events.
● Events: External occurrences that can affect the state of an object.
● Actions: Activities that result from a state change.
5. Activity Diagram
To model the workflow of a system or a method, showing the sequence of activities and their
conditions of execution.
Components:
6. Package Diagram
Components:
● Packages: Groupings of classes, interfaces, or other packages that are related or work
together.
● Dependencies: Relationships between packages indicating that changes in one
package may affect another.
To model the physical aspects of the system, detailing the software components (pieces of code or
modules) and the physical hardware that hosts or executes them.
Components:
● Component Diagrams: Show the organization and dependencies among a set of
components.
● Deployment Diagrams: Show the actual physical deployment of the software by
concentrating on the setup of runtime processing nodes and the components that are
located on them.
Each of these models plays a crucial role in providing a comprehensive view of the system from
different perspectives, ensuring that the system is well-understood, properly designed, and ready
for implementation. By utilizing these models, developers can address both the functional and
non-functional requirements of the system, leading to a more robust, maintainable, and efficient
software solution.
Principles of Modeling
By applying these principles, you'll create effective models that accurately represent complex
systems and facilitate successful OOAD projects.
Types of Models in Object Oriented Modeling and
Design
Intention of object oriented modeling and design is to learn how to apply object -oriented
concepts to all the stages of the software development life cycle.Object-oriented modeling and
design is a way of thinking about problems using models organized around real world concepts.
The fundamental construct is the object, which combines both data structure and behavior.
Purpose of Models:
1. Testing a physical entity before building it
2. Communication with customers
3. Visualization
4. Reduction of complexity
Types of Models:
There are 3 types of models in object oriented modeling and design are: Class Model, State
Model, and Interaction Model. These are explained below.
1. Class Model:
The class model shows all the classes present in the system. The class model shows
the attributes and the behavior associated with the objects.
The class diagram is used to show the class model.The class diagram shows the class
name followed by the attributes followed by the functions or the methods that are
associated with the object of the class.Goal in constructing class model is to capture
those concepts from the real world that are important to an application.
2. State Model:
State model describes those aspects of objects concerned with time and the
sequencing of operations – events that mark changes, states that define the context for
events, and the organization of events and states.Actions and events in a state diagram
become operations on objects in the class model. State diagram describes the state
model.
3. Interaction Model:
Interaction model is used to show the various interactions between objects, how the
objects collaborate to achieve the behavior of the system as a whole.
The following diagrams are used to show the interaction model:
● Use Case Diagram
● Sequence Diagram
● Activity Diagram
These are the fundamental elements in UML. Every diagram can be represented using these
building blocks. The building blocks of UML contain three types of elements. They are:
1) Things (object oriented parts of uml)
2) Relationships (relational parts of uml)
3) Diagrams
Things
A diagram can be viewed as a graph containing vertices and edges. In UML, vertices are
replaced by things, and the edges are replaced by relationships. There are four types of things in
UML. They are:
1) Structural things (nouns of uml – static parts)
2) Behavioral things (verbs of uml – dynamic parts)
3) Grouping things (organizational parts)
4) Annotational things (explanatory parts)
Structural things
Represents the static aspects of a software system. There are seven structural things in UML.
They are:
Class: A class is a collection of similar objects having similar attributes, behavior, relationships
and semantics. Graphically class is represented as a rectangle with three compartments.
Graphical representation:
Example:
Graphical representation:
or
Use Case: A use case is a collection of actions, defining the interactions between a role (actor)
and the system. Graphically use case is represented as a solid ellipse with its name written inside
or below the ellipse.
Graphical representation:
Example:
Graphical representation:
Example:
Node: A node is a physical element that exists at run time and represents a computational
resource. Graphically node is represented as a cube. Examples of nodes are PCs, laptops,
smartphones or any embedded system.
Purpose of Models:
Types of Models:
There are 3 types of models in object oriented modeling and design are: Class Model,
State Model, and Interaction Model. These are explained below.
1. Class Model:
The class model shows all the classes present in the system. The class model
shows the attributes and the behavior associated with the objects.
The class diagram is used to show the class model.The class diagram shows
the class name followed by the attributes followed by the functions or the
methods that are associated with the object of the class.Goal in constructing
class model is to capture those concepts from the real world that are
important to an application.
2. State Model:
State model describes those aspects of objects concerned with time and the
sequencing of operations – events that mark changes, states that define the
context for events, and the organization of events and states.Actions and
events in a state diagram become operations on objects in the class model.
State diagram describes the state model.
3. Interaction Model:
Interaction model is used to show the various interactions between objects,
how the objects collaborate to achieve the behavior of the system as a
whole.
The following diagrams are used to show the interaction model:
● Use Case Diagram
● Sequence Diagram
● Activity Diagram
Behavioral Things
Represents the dynamic aspects of a software system. Behavior of a software system can be
modeled as interactions or as a sequence of state changes.
State Machine: A behavior that specifies the sequences of states an object or interaction goes
through during its’ lifetime in response to events. A state is represented as a rectangle with
rounded corners. Below is an example of state machine representing the states of a phone
system:
Grouping Things
Elements which are used for organizing related things and relationships in models.
Package: A general purpose mechanism for organizing elements into groups. Graphically
package is represented as a tabbed folder. When the diagrams become large and cluttered,
related are grouped into a package so that the diagram can become less complex and easy to
understand.
Graphical representation:
Example:
Annotational Things
Note: A symbol to display comments. Graphically note is represented as a rectangle with a dog
ear at the top right corner.
Graphical representation:
Relationships
The things in a diagram are connected through relationships. So, a relationship is a connection
between two or more things.
Dependency: A semantic relationship, in which a change in one thing (the independent thing)
may cause changes in the other thing (the dependent thing). This relationship is also known as
“using” relationship. Graphically represented as dashed line with stick arrow head.
Graphical representation:
Example:
Example:
Graphical representation:
Example:
Realization: Defines a semantic relationship in which one class specifies something that another
class will perform. Example: The relationship between an interface and the class that realizes or
executes that interface.
Diagrams
1) Class diagram
2) Object diagram
4) Component diagram
5) Deployment diagram
6) Sequence diagram
7) Collaboration diagram
9) Activity diagram.
The rules of UML specify how the UMLs building blocks come together to develop diagrams.
The rules enable the users to create well-formed models. A well-formed model is self-consistent
and also consistent with the other models.
Visibility – How these names are seen and can be used by the other names
UML- Architecture
Software architecture is all about how a software system is built at its highest level. It is needed to
think big from multiple perspectives with quality and design in mind. The software team is tied to
many practical concerns, such as:
Software architecture provides a basic design of a complete software system. It defines the elements
included in the system, the functions each element has, and how each element relates to one another.
In short, it is a big picture or overall structure of the whole system, how everything works together.
To form an architecture, the software architect will take several factors into consideration:
The architect plans the structure of the system to meet the needs like these. It is essential to have
proper software architecture, mainly for a large software system. Having a clear design of a complete
system as a starting point provides a solid basis for developers to follow
Each developer will know what needs to be implemented and how things relate to meet the desired
needs efficiently. One of the main advantages of software architecture is that it provides high
productivity to the software team. The software development becomes more effective as it comes up
with an explained structure in place to coordinate work, implement individual features, or ground
discussions on potential issues. With a lucid architecture, it is easier to know where the key
responsibilities are residing in the system and where to make changes to add new requirements or
simply fixing the failures.
In addition, a clear architecture will help to achieve quality in the software with a well-designed
structure using principles like separation of concerns; the system becomes easier to maintain, reuse,
and adapt. The software architecture is useful to people such as software developers, the project
manager, the client, and the end-user. Each one will have different perspectives to view the system
and will bring different agendas to a project. Also, it provides a collection of several views. It can be
best understood as a collection of five views:
Design View
○ It is a view that shows how the functionality is designed inside the system in terms of
static structure and dynamic behavior.
○ It captures the vocabulary of the problem space and solution space.
○ With UML, it represents the static aspects of this view in class and object diagrams,
whereas its dynamic aspects are captured in interaction diagrams, state chart diagrams,
and activity diagrams.
Implementation View
○ It is the view that represents the organization of the core components and files.
○ It primarily addresses the configuration management of the system's releases.
○ With UML, its static aspects are expressed in component diagrams, and the dynamic
aspects are captured in interaction diagrams, state chart diagrams, and activity diagrams.
Process View
○ It is the view that demonstrates the concurrency of the system.
○ It incorporates the threads and processes that make concurrent system and synchronized
mechanisms.
○ It primarily addresses the system's scalability, throughput, and performance.
○ Its static and dynamic aspects are expressed the same way as the design view but focus
more on the active classes that represent these threads and processes.
Deployment View
○ It is the view that shows the deployment of the system in terms of physical architecture.
○ It includes the nodes, which form the system hardware topology where the system will be
executed.
○ It primarily addresses the distribution, delivery, and installation of the parts that build the
physical system.
Graphical representation:
Example:
Active Class: A class whose objects can initiate its own flow of control (threads) and work in
parallel with other objects. Graphically active class is represented as a rectangle with thick
borders.
Graphical representation:
Example:
Behavioral Things
Represents the dynamic aspects of a software system. Behavior of a software system can be
modeled as interactions or as a sequence of state changes.
Interaction: A behavior made up of a set of messages exchanged among a set of objects to
perform a particular task. A message is represented as a solid arrow. Below is an example of
interaction representing a phone conversation:
State Machine: A behavior that specifies the sequences of states an object or interaction goes
through during its’ lifetime in response to events. A state is represented as a rectangle with
rounded corners. Below is an example of state machine representing the states of a phone
system:
Grouping Things
Elements which are used for organizing related things and relationships in models.
Package: A general purpose mechanism for organizing elements into groups. Graphically
package is represented as a tabbed folder. When the diagrams become large and cluttered,
related are grouped into a package so that the diagram can become less complex and easy to
understand.
Graphical representation:
Example:
Annotational Things
Note: A symbol to display comments. Graphically note is represented as a rectangle with a dog
ear at the top right corner.
Graphical representation:
Relationships
The things in a diagram are connected through relationships. So, a relationship is a connection
between two or more things.
Dependency: A semantic relationship, in which a change in one thing (the independent thing)
may cause changes in the other thing (the dependent thing). This relationship is also known as
“using” relationship. Graphically represented as dashed line with stick arrow head.
Graphical representation:
Example:
Example:
Realization: Defines a semantic relationship in which one class specifies something that another
class will perform. Example: The relationship between an interface and the class that realizes or
executes that interface.
Diagrams
A diagram is a collection of elements often represented as a graph consisting of vertices and
edges joining these vertices. These vertices in UML are things and the edges are relationships.
UML includes nine diagrams:
1) Class diagram
2) Object diagram
3) Use case diagram
4) Component diagram
5) Deployment diagram
6) Sequence diagram
7) Collaboration diagram
8) Statechart diagram and
9) Activity diagram.
The rules of UML specify how the UMLs building blocks come together to develop diagrams.
The rules enable the users to create well-formed models. A well-formed model is self-consistent
and also consistent with the other models.
UML has rules for:
Names – What elements can be called as things, relationships and diagrams
Scope – The context that gives a specific meaning to a name
Visibility – How these names are seen and can be used by the other names
Integrity – How things properly relate to one another
Execution – What it means to run or simulate a model
UML- Architecture
Software architecture is all about how a software system is built at its highest level. It is needed to
think big from multiple perspectives with quality and design in mind. The software team is tied to
many practical concerns, such as:
To form an architecture, the software architect will take several factors into consideration:
The architect plans the structure of the system to meet the needs like these. It is essential to have
proper software architecture, mainly for a large software system. Having a clear design of a complete
system as a starting point provides a solid basis for developers to follow
Each developer will know what needs to be implemented and how things relate to meet the desired
needs efficiently. One of the main advantages of software architecture is that it provides high
productivity to the software team. The software development becomes more effective as it comes up
with an explained structure in place to coordinate work, implement individual features, or ground
discussions on potential issues. With a lucid architecture, it is easier to know where the key
responsibilities are residing in the system and where to make changes to add new requirements or
simply fixing the failures.
In addition, a clear architecture will help to achieve quality in the software with a well-designed
structure using principles like separation of concerns; the system becomes easier to maintain, reuse,
and adapt. The software architecture is useful to people such as software developers, the project
manager, the client, and the end-user. Each one will have different perspectives to view the system
and will bring different agendas to a project. Also, it provides a collection of several views. It can be
best understood as a collection of five views:
Design View
○ It is a view that shows how the functionality is designed inside the system in terms of
static structure and dynamic behavior.
○ It captures the vocabulary of the problem space and solution space.
○ With UML, it represents the static aspects of this view in class and object diagrams,
whereas its dynamic aspects are captured in interaction diagrams, state chart diagrams,
and activity diagrams.
Implementation View
○ It is the view that represents the organization of the core components and files.
○ It primarily addresses the configuration management of the system's releases.
○ With UML, its static aspects are expressed in component diagrams, and the dynamic
aspects are captured in interaction diagrams, state chart diagrams, and activity diagrams.
Process View
○ It is the view that demonstrates the concurrency of the system.
○ It incorporates the threads and processes that make concurrent system and synchronized
mechanisms.
○ It primarily addresses the system's scalability, throughput, and performance.
○ Its static and dynamic aspects are expressed the same way as the design view but focus
more on the active classes that represent these threads and processes.
Deployment View
○ It is the view that shows the deployment of the system in terms of physical architecture.
○ It includes the nodes, which form the system hardware topology where the system will be
executed.
○ It primarily addresses the distribution, delivery, and installation of the parts that build the
physical system.