Unit 2
What is UML
UML stands for Unified Modeling Language. It is not a programming language but a
way to draw diagrams that show how a system works. Think of UML like a blueprint
for software — it lets you see and plan out how things will be built before you start
coding.
Here is a simple explanation for the first individual topic from your syllabus.
Importance of Modeling
1. Modeling means making diagrams to show how a system works.
2. It helps everyone understand the system and how it will work before building
it.
3. Modeling makes it easy to find mistakes early, saving time and money.
4. With models, non-technical people can see what is happening even if they
cannot read code.
5. Modeling is useful in teamwork because it helps people share ideas clearly.
Summary:
We use modeling in software so everyone can see what is planned, understand
problems early, and work together easily.
In short: Modeling helps you see the "big picture" and avoids problems later.
Principles of Modeling :
Choose the right model:
Imagine picking the right tool for a job. Just like you use a hammer for nails and a
brush for painting, in software you must choose the model that fits the problem you
are solving. The right model shows you the important parts. The wrong model will
make you work on things that do not matter.
Different levels of precision (detail):
Think of drawing maps. Sometimes you need a simple street map, sometimes you
need a map with every building on it. In modeling, you decide how much detail you
show. For quick ideas, keep it simple. For final plans, add all the details.
Connected to reality:
A good model should show how things actually work. If you make a software model
for a car, your model should look and act like a real car. If not, your model will not
help people build or understand the real thing.
Multiple models for one system:
For big things, you need different views. Imagine looking at a car from the outside,
the engine, and the inside. Each view shows something different. The same goes for
software: you use use-case models, design models, process models, and more. Put
these views together to see the full picture.
Why These Principles Matter
Easy to understand:
Models help everyone see and understand the plan, even if they do not know coding.
Find mistakes early:
With good models, you find problems before building, saving time and money.
Faster development:
With a good plan, building is quicker because you do not get stuck or lost.
Object-Oriented Modeling (OOM)
Object-Oriented Modeling is a way to design a system using "objects." An object is
anything that has a name, features, and actions — like a bank account, a car, or a
student. In software, you create objects to represent things or ideas from the real
world.
Why Use Object-Oriented Modeling?
It helps break big problems into smaller, easy-to-manage pieces called objects.
Objects make code more reusable, easy to change, and simple to understand.
Modeling with objects matches how things work in real life, so it feels natural.
Main Ideas in Object-Oriented Modeling
1. Class: A class is like a blueprint. It describes what features (called attributes)
and actions (called methods) each object will have.
2. Object: An object is a real thing made using the class blueprint. For example,
"Dog" is a class, but "Tommy" (a specific dog) is an object.
3. Encapsulation: Wraps the object's features and actions together inside one
unit. Keeps data safe by hiding details from other objects.
4. Inheritance: One class can share its features with another class. For example,
"Vehicle" class gives its features to "Car" and "Bike" classes.
5. Polymorphism: One action can work in different ways for different objects.
For example, a "draw()" action works differently for "Circle" and "Square".
6. Abstraction: Shows only what is needed and hides the rest; makes things
simple for users.
How Object-Oriented Modeling Works
1. First, think about what objects you need for your system
2. Then, describe their features (attributes) and actions (methods).
3. Show how objects will connect and work together.
4. Use diagrams like class diagrams to show all this in pictures.
Where Is OOM Used?
In software development (creating apps and websites)
In designing databases
In embedded systems (software for devices)
In making games and simulations
Object-Oriented Modeling helps build software step by step, making systems easy to
build, expand, and fix.
Conceptual Model of UML
The conceptual model of UML is like the ABCs and rules for drawing UML diagrams.
Before making diagrams, you need to know the basic parts and the rules for using
them.
Main Parts of the Conceptual Model
1. Building Blocks (Vocabulary)
These are the basic elements you use to build UML diagrams:
Things: Main objects in a system.
Four types:
Structural things (for example: classes, interfaces)
Behavioral things (for example: interactions, actions)
Grouping things (for example: packages)
Annotational things (for example: comments)
Relationships: These show how things are connected.
Four types:
Dependency (one thing uses another)
Association (things are linked)
Generalization (one thing is a special type of another)
Realization (one thing fulfills another)
Diagrams: Drawings that show "things" and "relationships."
Examples include class diagrams, use-case diagrams, and activity diagrams.
2. Rules (Grammar)
Just like in language, there are rules for naming, organizing, and connecting the
elements in UML. These rules help make diagrams clear and useful.
Naming: How you label things.
Scope: Where those names are used
Visibility: Who can see and use those names.
Integrity: Making sure connections are made the right way.
Execution: How the system runs or works.
3. Common Mechanisms
These are features that appear everywhere in UML and make it flexible:
Specifications: Details behind every symbol (for example, what a class icon really
means).
Adornments: Extra small markers that give more information, like "+" for public or "-
" for private.
Divisions: Clear difference between similar elements (like class vs. object)
Extensibility: Ways to add new things if needed.
Why Is This Useful?
Knowing these basics helps you read and make proper UML diagrams.
These parts and rules help everyone in a team understand systems better, even if
they are beginners.
UML Architecture
What is Architecture in UML?
Architecture in UML means planning the main structure of a software system, like
the design of a house.
UML helps you show how different parts (components) of a system fit and work
together.
The Four Main Views of UML Architecture
Structural View:
Shows the "backbone" of the system: the main parts like classes, objects, and
components. Think of this as the walls and rooms in your house.
Behavioral View:
Shows how things work and interact over time — like how you move in your house,
switch on lights, or open doors. In software, it means showing how objects change
and communicate.
Physical View:
Shows how all software (and sometimes hardware) pieces are organized physically:
like where files are stored, how software is deployed on servers, etc.
Development View:
Shows how the system will be built and maintained - like plans for wiring, plumbing,
and repairs in your house.
Why Use UML Architecture?
It helps everyone understand the structure and plan of the system.
Teams can see which parts need to be built, how they connect, and how things will
work together — making teamwork smooth and mistakes easy to spot early.
The UML diagrams most used in system architecture are:
Class Diagram: Shows the structure and relationships between different
parts (classes) in your system. It is the most common diagram for planning
and understanding the backbone of your software.
Component Diagram: Shows how different software pieces (components)
connect and interact. It helps teams see main parts and their connections in
big systems.
Deployment Diagram:Shows how software is placed on hardware (like
servers, computers). Useful for understanding real-world setup of your
system.
Use Case Diagram: Shows who uses the system and what they do. Helps
teams understand system boundaries and user needs.
Activity Diagram/Sequence Diagram: Shows how things happen step by
step and how objects communicate in your system.
Software Development Life Cycle (SDLC) in UML
The Software Development Life Cycle (SDLC) is the step-by-step process for building
software. It helps developers plan, create, test, and maintain new software, making
sure everything works properly.
Main Phases of SDLC
Requirement Analysis:
Find out what users and customers want. UML Use Case diagrams can be used here
to show what functions your system should have.
Design:
Plan how the system will work. UML helps here with diagrams like Class diagrams,
Sequence diagrams, Activity diagrams, and more. These help create the structure
and working details of the system.
Implementation (Coding):
Developers write the actual code, using the design as their guide
Testing:
Check that everything works as planned. UML diagrams (like Sequence and Use Case
diagrams) can help create test cases to check if the system behaves correctly.
Deployment:
Software is released for use. It is installed on users' computers or servers.
Maintenance:
Fix bugs, add new features, and update old parts. UML diagrams are helpful in
understanding the current system while planning changes.
How is UML Used in SDLC?
UML diagrams are mostly useful during Requirement Analysis and Design phases.
They provide clear blueprints that make it easier to understand, build, and test the
software.
By using UML diagrams, teams avoid confusion and mistakes.
Basic Structural Modeling in UML
1. Classes
A class describes a group of objects that share the same properties (attributes) and
actions (methods).
Example: A "Student" class will have properties like name, roll number, and actions
like study or attend class.
Classes are drawn as rectangles divided into sections:
Top: Class name (like Student)
Middle: Attributes (like name, age)
Bottom: Methods (like study(), writeExam())
2. Relationships
There are three main relationships used in UML:
Association: Shows a link between two classes, like Student and Course. Drawn as a
straight line.
Example: "Student enrolls in Course."
Generalization (Inheritance): Shows "is-a" relationship. One class (child) gets
features from another class (parent). Drawn as a hollow arrow.
Example: "Dog is a type of Animal."
Dependency: One class uses another class. Changes in one may affect the other.
Drawn as a dashed arrow.
Example: "Report class uses Data class for generating reports."
Special relationships:
Aggregation: Whole-part relationship (unfilled diamond). Example: "Library
has Books."
Composition: Strong whole-part relationship (filled diamond). Example:
"House has Rooms."
3. Common Mechanisms
Multiplicity: Shows how many objects are linked — one, many, or a range.
Role Names: Shows what role a class plays in a relationship, like "employee" in
Company-Employee.
Visibility: Public (+), Private (-), or Protected (#) — marks before attributes and
methods.
4. Diagrams:
Class Diagram
Shows: Structure of the system. Classes, their properties (attributes), actions
(methods), and relationships.
Used for: Planning and designing the overall system blueprints.
Example:
Class: Student
Attributes: name, roll number
Methods: study(), takeExam()
Relationship: Student enrolls in Course.
Object Diagram
Shows: Actual objects and their links at a single moment (like a photo).
Used for: Visualizing real examples from the system.
Example:
Student: "Ravi", enrolled in: "Physics" course.
Composite Structure Diagram
Shows: Internal parts of a class and how they connect.
Used for: Seeing details inside a single class or component.
Example:
Inside a Car: Engine, Wheels, Seats connected together.
Package Diagram
Shows: Groups of classes or components (packages).
Used for: Organizing the system into sections for easy management.
Example:
Package: School
Includes: Student, Teacher, Course classes
Use Case Diagram (behavioral)
Shows: What functions the system offers and who uses them (actors).
Used for: Understanding what the system must do.
Example:
Actor: Student
Use case: Register for exam, View marks.
Sequence Diagram (behavioral)
Shows: How objects interact step by step to finish a process.
Used for: Mapping out the flow of messages and events.
Example:
Student logs in → System checks password → Student views timetable
These diagrams help visualize and explain how systems are built, organized, and
work. If you want next topic or more diagram examples
Case Study: Traffic Management System
System Goal
The aim is to control traffic signals automatically using sensors, reduce congestion,
help emergency vehicles, and improve road safety.
How the System Works
1. Sensors at traffic signals detect traffic density (how many vehicles are
waiting).
2. These sensors send the data to a Control Room (central server).
3. The control room decides which signal gets the green light and for how long.
4. In case of an accident, sensors inform the control room, which alerts the
nearest hospital and reroutes the traffic.
5. If a vehicle breaks a signal or goes too fast, cameras and sensors note its
number and send info to police at the next signal.
Important UML Diagrams (Simple Explanation)
Diagram Type What It Shows Example
Use Case Who uses the system and what they Police, Driver, Signals; Use cases: Control
Diagram do Signal, Detect Violation
Main parts of system and their Classes: ControlRoom, Sensor, Hospital,
Class Diagram
properties/actions Police, VehicleViolation
Sequence Step-by-step flow of events among Detect accident → Alert hospital →
Diagram objects Reroute traffic
Activity Flow of operations and decision
Normal traffic vs accident handling
Diagram points
States for signals (Green, Red,
State Diagram Traffic signal cycles
Yellow) and transitions
Example: Class Diagram
ControlRoom: Gets data, makes decisions, sends alerts.
Sensor: Detects traffic, sends info.
Hospital: Alerts, responds in emergencies.
Traffic Police: Monitors violations, responds.
ViolateTraffic: Stores info about vehicles violating rules.
Example: Use Case Scenario
Driver waits at signal.
Sensor sends traffic density to ControlRoom.
ControlRoom updates green/red lights based on traffic.
If emergency, Hospital is contacted.
If violation, Police is alerted.
This type of system helps cities manage traffic more efficiently, improves safety, and
handles emergency situations quickly.