OOMD Insem
OOMD Insem
Unit 1:
2. Modeling Objects
Object Diagram: Used to model specific instances of classes and their relationships at a particular point in time.
It shows a snapshot of the objects and their links.
Components of an Object Diagram:
Object Representation:
o Notation: An object is depicted as a rectangle with the object name followed by the class name.
Format: objectName : ClassName
Example: john : Customer
Attributes:
o Notation: Attributes of an object can be shown inside the object rectangle.
Format: attributeName = value
Example: name = "John Doe", customerID = 12345
Links:
o Notation: Solid lines connecting objects to show their relationships.
o Example: A line connecting john : Customer to order1 : Order if john has placed order1.
3. Operations (Methods)
Definition: Operations are functions or methods that define the behavior of a class. They describe what an
object of the class can do.
Notation: Listed in the bottom section of the class box, typically in the format visibility name(): returnType.
4. Relationships
Definition: Relationships depict how classes are connected to each other. Common types of relationships in
class diagrams include associations, inheritance (generalization), aggregation, and composition.
Types of Relationships:
Association: A basic relationship between two classes.
o Example: A Driver class might have an association with a Car class (A driver "drives" a car).
Inheritance (Generalization): A relationship where one class (child) inherits attributes and operations from
another class (parent).
o Example: ElectricCar inherits from Car.
Aggregation: A "whole-part" relationship where the part can exist independently of the whole.
o Example: A Car class might have an aggregation relationship with a Wheel class.
Composition: A stronger "whole-part" relationship where the part cannot exist independently of the whole.
o Example: A House class might have a composition relationship with a Room class (Rooms cannot
exist without the House).
5. Multiplicity
Definition: Multiplicity specifies how many instances of one class are associated with one instance of
another class in a relationship.
Notation: Displayed as numbers near the ends of association lines.
6. Visibility
Definition: Visibility defines the accessibility of attributes and operations. It is indicated by symbols:
o + Public: Accessible from anywhere.
o - Private: Accessible only within the class.
o # Protected: Accessible within the class and its subclasses.
6. Explain the types of relationship along with their notations. [5] / Explain different Relations in UML[5]
Association
An association represents a bi-directional relationship between two classes. It indicates that instances of one
class are connected to instances of another class. Associations are typically depicted as a solid line connecting
the classes, with optional arrows indicating the direction of the relationship.
Aggregation
Composition
Composition is a stronger form of aggregation, indicating a more significant ownership or dependency
relationship. In composition, the part class cannot exist independently of the whole class. Composition is
represented by a filled diamond shape on the side of the whole class.
Generalization(Inheritance)
Inheritance represents an “is-a” relationship between classes, where one class (the subclass or child) inherits
the properties and behaviors of another class (the superclass or parent). Inheritance is depicted by a solid line
with a closed, hollow arrowhead pointing from the subclass to the superclass.
Dependency Relationship
A dependency exists between two classes when one class relies on another, but the relationship is not as
strong as association or inheritance. It represents a more loosely coupled connection between classes.
Dependencies are often depicted as a dashed arrow.
Realization (Interface Implementation)
Realization indicates that a class implements the features of an interface. It is often used in cases where a class
realizes the operations defined by an interface. Realization is depicted by a dashed line with an open
arrowhead pointing from the implementing class to the interface.
Multiplicity Not usually specified directly for Often specified using multiplicity indicators
links. (e.g., 1..*, 0..1) to show how many instances
of one class can be related to instances of
another class.
Instance vs. Deals with specific instances of Deals with classes themselves and defines
Class classes (i.e., objects). the potential relationships between their
instances.
Example:
Link:
Object Diagram: john : Person linked to office1 : Office
o Indicates that john (a specific person) is currently associated with office1 (a specific office).
Association:
Class Diagram: Association between Person and Office
o Indicates that any Person can be associated with any Office, and the nature of their relationship
(e.g., "works at").
10. What are different type of analysis classes? Explain with an example. [6]
In object-oriented analysis and design, analysis classes are used to represent the key concepts, entities, or
objects in a system and to facilitate understanding of how these entities interact. Different types of analysis
classes serve various roles in modeling and designing a system. Here are the main types of analysis classes:
1. Entity Classes
Definition: Represent the core business objects or entities in the system that hold data and encapsulate
significant domain concepts. They typically map to real-world objects or concepts.
Role: Manage and store the data relevant to the domain.
Example: In a library management system, an Book class is an entity class. It has attributes like title, author,
ISBN, and publicationYear, and methods to access and modify these attributes.
2. Boundary Classes
Definition: Represent the interfaces or interactions between the system and its external environment, such
as users or external systems. They are responsible for handling inputs and outputs.
Role: Act as the interface between the system and external actors (users or other systems).
Example: In a library management system, a LibraryWebInterface class could be a boundary class. It handles
user interactions, such as receiving book search requests from users and displaying search results.
3. Control Classes
Definition: Represent the logic that coordinates the flow of data and control between entity classes and
boundary classes. They handle the processing and application logic of the system.
Role: Manage the control flow of the system, handling use cases or business processes.
Example: In a library management system, a BookLoanController class could be a control class. It manages
the process of checking out a book, updating the book's status, and recording the transaction in the system.
Example Scenario
Let’s consider an online shopping system to illustrate these types of analysis classes:
1. Entity Class: Product
o Attributes: productID, name, price, description
o Methods: getPrice(), setPrice(price: Double), getDescription()
2. Boundary Class: ShoppingCartUI
o Attributes: None (handles UI interactions)
o Methods: displayProducts(), addProductToCart (productID: String), showCartDetails()
3. Control Class: CartController
o Attributes: cart
o Methods: addProduct(productID: String), removeProduct(productID: String), calculateTotal()
Interaction Example
1. A user interacts with the ShoppingCartUI to add a product to their cart.
2. ShoppingCartUI sends a request to the CartController to add the product.
3. CartController interacts with the Product entity class to get product details and update the cart.
4. CartController calculates the total price and updates the ShoppingCartUI to show the updated cart.
Unit 2:
1. Write a short note on : [5]
i) Package
Definition: A package is a UML construct that groups related classes, interfaces, and other elements into a
single unit. It helps in organizing and managing complex models by structuring related elements together.
Purpose: Packages are used to encapsulate and organize model elements, promoting modularity and
reducing complexity in large systems. They help in defining boundaries and managing dependencies
between different parts of the system.
Notation: In UML diagrams, a package is represented by a rectangle with a small tab or folder icon. It
contains a name and can include other packages or elements. Relationships between packages can be
shown using dependency arrows.
iii) Constraints
Definition: Constraints in UML specify conditions or rules that must be satisfied for the system to be
considered correct. They define limitations or requirements that model elements must adhere to.
Purpose: Constraints help in ensuring that the model adheres to certain rules or conditions, thereby
improving the accuracy and integrity of the system. They are used to enforce business rules, data integrity,
and other critical requirements.
Notation: Constraints are usually represented in UML using curly braces {} and can be attached to various
model elements such as classes, attributes, or associations. They may include textual descriptions or
expressions that define the constraint.
3. Transitivity: If class A aggregates class B, and class B aggregates class C, then class A also indirectly
aggregates class C.
4. Antisymmetric: If class A aggregates class B, then class B does not aggregate class A; the relationship is not
bidirectional.
5. For example: Here we are considering a car and a wheel example. A car cannot move without a wheel. But
the wheel can be independently used with the bike, scooter, cycle, or any other vehicle. The wheel object
can exist without the car object, which proves to be an aggregation relationship.
ii) Composition
Definition: Composition is a stronger form of aggregation that represents a "whole-part" relationship where
the parts' existence is strictly tied to the whole. If the whole is destroyed, the parts are also destroyed. It
indicates a more rigid lifecycle dependency between the whole and the parts.
Characteristics:
1. Strong Relationship: Composition implies a stronger relationship where the lifecycle of the parts is
dependent on the whole. If the whole object is deleted, the parts are also deleted. This reflects a stronger
ownership.
2. Notation: In UML diagrams, composition is represented by a solid line connecting the whole class to the
part class, with a filled diamond shape at the end of the line near the whole class.
3. Example: the composition association relationship connects the Person class with Brain class, Heart class,
and Legs class. If the person is destroyed, the brain, heart, and legs will also get discarded.
3. What do you mean by Association ends? Explain N-ary association in short. [5]
Association Ends
Definition: Association ends in UML represent the roles played by each class in an association. They specify how
classes are connected and the nature of their relationship in a model. Each end of an association can include
multiplicity, role names, and other details.
Components:
1. Role Name: Indicates the role or function that the class plays in the association. It is often used to clarify
the nature of the relationship from the perspective of each class.
2. Multiplicity: Defines the number of instances of a class that can be associated with instances of another
class. Common multiplicities include 1, 0..1, 1..*, and 0..*.
3. Navigation: Shows whether the association is bidirectional or unidirectional. It indicates if instances of one
class can access instances of the associated class.
Example:
In a class diagram with an association between Author and Book, the Author end might have a role name
like "writes" and a multiplicity of 1..*, while the Book end might have a role name like "written by" and a
multiplicity of 1.
N-ary Association
Definition: An N-ary association involves more than two classes and represents a relationship among three or
more classes. It is used to model complex relationships that cannot be adequately captured by binary
associations.
Characteristics:
1. Representation: N-ary associations are depicted as a diamond shape connecting multiple classes. The
diamond includes role names and multiplicities to describe how each class participates in the relationship.
2. Purpose: Useful for capturing complex relationships that involve multiple entities interacting together in a
system, such as transactions involving multiple participants or constraints involving several classes.
3. Example:
7. Draw state diagram with composite states from ATM card reading & authentication system. [5]*
8. Explain different components of a state diagram. [5]
A state diagram in UML (Unified Modeling Language) is used to represent the dynamic behavior of an object by
showing its states, transitions, and events. Here are the main components of a state diagram:
1. States
Definition: States represent specific conditions or situations of an object during its lifecycle. Each state
describes a particular status the object can be in.
Notation: Depicted as rounded rectangles (state boxes) with the state name inside.
Example: For a Process object, states might include Started, Running, and Completed.
Example Representation:
2. Transitions
Definition: Transitions show the movement from one state to another triggered by events. They indicate how
and when an object changes from one state to another.
Notation: Represented as arrows connecting states. The arrow points from the current state to the next
state.
Example: A transition from Started to Running might be triggered by an event called startProcess.
Example Representation:
3. Events
Definition: Events are occurrences that trigger transitions between states. They can be signals, method calls,
changes, or time-based occurrences.
Notation: Typically listed along the transition arrow to indicate what causes the transition.
Example: The startProcess event triggers the transition from Started to Running.
Example Representation:
+-------------+ [startProcess] +--------------+
| Started | --------------------> | Running |
+-------------+ +--------------+
4. Actions
Definition: Actions are activities that are performed as a result of a transition or during the entry or exit of a
state. They define what happens when the object enters or exits a state.
Notation: Actions are usually written inside the state box or next to the transition arrow, typically preceded
by keywords like entry/, exit/, or do/.
Example: In the Running state, an action might be doProcessing(), which occurs continuously while the
object is in that state.
Example Representation:
+---------------------+
| Running |
| doProcessing() |
+---------------------+
2. Call Events
Definition: Call events occur when a method or operation is invoked on an object. They are synchronous and
lead to state transitions based on the method call.
Modeling:
Notation: Represented by an arrow connecting two states, with the method name written along the arrow.
Example: Calling the processOrder() method might transition from Pending to Processing.
Example Diagram:
+-------------+ processOrder() +-------------+
| Pending | -----------------------> | Processing |
+-------------+ +-------------+
3. Change Events
Definition: Change events are triggered by changes in conditions or properties of an object. These events cause
transitions when specific conditions become true.
Modeling:
Notation: Represented by an arrow connecting two states, with a condition in square brackets written along
the arrow.
Example: If an orderAmount exceeds a certain value, it might transition from UnderReview to Approved.
Example Diagram:
+-------------------+ [orderAmount > $100] +------------------+
| UnderReview | ------------------------------------> | Approved |
+-------------------+ +------------------+
4. Time Events
Definition: Time events are triggered by the passage of a certain amount of time. They cause transitions after a
specified duration has elapsed or at a specific time.
Modeling:
Notation: Represented by an arrow connecting two states, with a time duration or time trigger written
along the arrow.
Example: A timeout event might transition from Active to TimedOut after 30 minutes.
Example Diagram:
+-------------+ [after 30 minutes] +--------------+
| Active | -----------------------------> | TimedOut |
+-------------+ +--------------+
5. Trigger Events
Definition: Trigger events are general events that cause state transitions. They can include user interactions,
system notifications, or other significant occurrences.
Modeling:
Notation: Represented by an arrow connecting two states, with the trigger event written along the arrow.
Example: A user clicking a Submit button might transition from FormFilled to FormSubmitted.
Example Diagram:
+----------------+ SubmitButtonClick +--------------------+
| FormFilled | -------------------------> | FormSubmitted |
+----------------+ +--------------------+