Introduction to UML (Unified modeling Language) By Sandhya Satyarthi UML(Unified Modeling Language) • A diagrammatic way of showing the relationships among classes • This will help our understanding of the definitions of our collections and the usage of our collections in applications 1-2 What is the use of UML? • Basically, UML has been used as a general-purpose modeling language in the field of software engineering. However, it has now found its way into the documentation of several business processes or workflows. • For example, activity diagrams, a type of UML diagram, can be used as a replacement for flowcharts. They provide both a more standardized way of modeling workflows as well as a wider range of features to improve readability and efficacy. 1-3 UML Diagrams • Unified Modeling Language (UML) is a standard notation for object-oriented design • Used to model object-oriented designs • Shows overall design of a solution • Shows class specifications • Shows how classes interact with each other • Diagrams use specific icons and notations • It is language independent 1-4 • UML is a way of visualizing a software program using a collection of diagrams. The notation has evolved from the work of Grady Booch, James Rumbaugh, Ivar Jacobson, and the Rational Software Corporation to be used for objectoriented design, but it has since been extended to cover a wider variety of software engineering projects. • Today, UML is accepted by the Object Management Group (OMG) as the standard for modeling software development. 1-5 Types of UML Diagrams • • The current UML standards call for 13 different types of diagrams: These diagrams are organized into two distinct groups: Structural diagrams Behavioral or interaction diagrams Structural UML diagrams Class diagram Package diagram Object diagram Component diagram Composite structure diagram Deployment diagram 1-6 • Behavioral UML diagrams Activity diagram Sequence diagram Use case diagram State diagram Communication diagram Interaction overview diagram Timing diagram 1-7 UML Class Diagram • A class is represented in a UML diagram by a rectangle divided into 3 sections: • name of the class • attributes of the class (i.e. the data fields of the class, including variables and constants) • operations of the class (essentially equivalent to a Java method or a C++ function) 1-8 Features of UML Class Diagrams • Class diagrams are the main building block of any object-oriented solution. It shows the classes in a system, attributes, and operations of each class and the relationship between each class • Attributes and operations may be left incomplete, and completed as design is developed 1-9 Example of Class diagram 1-10 Package Diagram • As the name suggests, a package diagram shows the dependencies between different packages in a system. • We use Package Diagrams to depict how packages and their elements have been organized. • A package diagram simply shows us the dependencies between different packages and internal composition of packages. • Packages help us to organise UML diagrams into meaningful groups and make the diagram easy to understand. • They are primarily used to organise class and use case diagrams. 1-11 1-12 Object Diagram • Object is an instance of a class in a particular moment in runtime that can have its own state and data values. • An Object Diagram can be referred to as a screenshot of the instances in a system and the relationship that exists between them. • Since object diagrams depict behaviour when objects have been instantiated, we are able to study the behaviour of the system at a particular instant. • An object diagram is similar to a class diagram except it shows the instances of classes in the system. We depict actual classifiers and their relationships making the use of class diagrams. • On the other hand, an Object Diagram represents specific instances of classes and relationships between them at a point of time. 1-13 1-14 Component Diagram • It is use to show the structural relationships between the components of the system. • Component is a physical and replaceable part of system and models physical things. • It does not describe the functionality of the system but it describes the components used to make those functionalities. • The purpose of the component diagram can be summarized as − Visualize the components of a system. Construct executables by using forward and reverse engineering. Describe the organization and relationships of the components. 1-15 • It does not describe the functionality of the system but it describes the components used to make those functionalities. • Component diagrams illustrate the pieces of software, embedded controllers, etc., that will make up a system. • Use to show the static view of component and their relationship. • Node is component (set of classes with well defined interface) • Edge is relationship between the components. 1-16 1-17 Deployment Diagram • Deployment diagrams model the physical architecture of a system. • Deployment diagrams show the relationships between the software and hardware components in the system and the physical distribution of the processing. • Deployment diagrams consist of nodes and their relationships • Component diagrams and deployment diagrams are closely related. • Component diagrams are used to describe the components and deployment diagrams shows how they are deployed in hardware. 1-18 • The purpose of deployment diagrams can be described as − Visualize the hardware topology of a system. Describe the hardware components used to deploy software components. Describe the runtime processing nodes. Basic elements by focusing on them we draw the deployment diagram: • Nodes • Relationships among nodes • They model physical hardware elements and the communication paths between them 1-19 1-20 Composite-structure Diagram • We use composite structure diagrams to represent the internal structure of a class and its interaction points with other parts of the system. • A composite structure diagram represents relationship between parts and their configuration which determine how the classifier (class, a component, or a deployment node) behaves. • They represent internal structure of a structured classifier making the use of parts, ports, and connectors. • We can also model collaborations using composite structure diagrams. They are similar to class diagrams except they represent individual parts in detail as compared to the entire class. 1-21 1-22 Activity Diagram • Activity diagrams are typically used for business process modeling, for modeling the logic captured by a single use case or usage scenario, or for modeling the detailed logic of a business rule. • Although UML activity diagrams could potentially model the internal logic of a complex operation it would be far better to simply rewrite the operation so that it is simple enough that you don’t require an activity diagram. • In many ways UML activity diagrams are the object-oriented equivalent of flow charts and data flow diagrams (dfds) from structured development 1-23 Let’s start by describing the basic notation : • Initial node. The filled in circle is the starting point of the diagram. An initialnode isn’t required although it does make it significantly easier to read the diagram. • Activity final node. The filled circle with a border is the ending point. Anactivity diagram can have zero or more activity final nodes. • Activity. The rounded rectangles represent activities that occur. An activity maybe physical, such as Inspect Forms, or electronic, such as Display Create StudentScreen. • Flow/edge. The arrows on the diagram. Although there is a subtle differencebetween flows and edges,never a practical purpose for the difference although. 1-24 1-25 Use Case Diagram According to the UML specification a use case diagram is “a diagram that shows the relationships among actors and use cases within a system.” Use case diagrams are often used to: • Provide an overview of all or part of the usage requirements for a system or organization in the form of an essential model or a business model • Communicate the scope of a development project • Model your analysis of your usage requirements in the form of a system use case model 1-26 Use case diagram components • To answer the question, "What is a use case diagram?" you need to first understand its building blocks. Common components include: • Actors: The users that interact with a system. An actor can be a person, an organization, or an outside system that interacts with your application or system. They must be external objects that produce or consume data. • System: A specific sequence of actions and interactions between actors and the system. A system may also be referred to as a scenario. • Goals: The end result of most use cases. A successful diagram should describe the activities and variants used to reach the goal 1-27 1-28 1-29 Interaction Diagrams An interaction diagram depicts the messages between objects or classes in a program. It shows collaborations between objects. The UML includes two types of interaction diagrams – sequence diagrams collaboration diagrams Sequence Diagrams • Describe the flow of messages, events, actions between objects. • Show concurrent processes and activations • Show time sequences that are not easily depicted in other diagrams • Typically used during analysis and design to document and understand the logical flow of your system • Emphasize on time ordering. Sequence Diagram Elements: 1.Object: • Sequence diagram is made up of collection of objects. • The objects interact with each other by sending and receiving messages. 2. LifeLine: • Lifeline represents the existence of an object over a period of time. • Mostly the objects in the interaction diagram will be in existence for the duration of an interaction • Objects are aligned at top of sequence diagram with their lifeline from top to bottom. 3. Activation Bar: • It is called as focus of control. • It shows the period of time during which an object is performing an action. • Top of rectangle in aligned with start of action and the bottom is aligned with the completion and can be marked by written message. 4. Messages: • The interaction between objects can be done by using message . • The message flow in sequence diagram specify by using an arrow. And the flow of message is in any direction from left to right or right to left. Example of sequence diagram Collaboration Diagrams • • • • A collaboration diagram is a network model of the messages between interacting objects and classes. The collaboration diagram will indicate the objects participating in the collaboration, and The sequence of messages {message(parameters), sender, receiver} exchanged to achieve the task involved. There is a UML convention for numbering the messages to show the sequence in which they occur. Collaboration Diagrams • Collaboration diagrams are also relatively easy to draw. • They show the relationship between objects and the order of messages passed between them. • The objects are listed as icons and arrows indicate the messages being passed between them. • The numbers next to the messages are called sequence numbers. Collaboration Diagram Elements • There are three primary elements of a collaboration diagram: • Objects • Links • Messages Example of Collaboration Diagram Example of Collaboration Diagram State-Chart Diagrams • They define different states of an object during its lifetime and these states are changed by events. • State-chart diagrams are useful to model the reactive systems. • Reactive systems can be defined as a system that responds to external or internal events. • State-chart diagram describes the flow of control from one state to another state. • States are defined as a condition in which an object exists and it changes when some event is triggered • State Chart Diagrams provide a way to model the various states in which an object can exist. • Process that occur while an object is in certain state are called actions. Basic components of a state-chart diagram • Initial state – We use a black filled circle represent the initial state • • • • • of a System or a class. Transition – We use a solid arrow to represent the transition or change of control from one state to another. The arrow is label with the event which causes the change in state. State – We use a rounded rectangle to represent a state. A state represents the conditions or circumstances of an object of a class at an instant of time. Fork –We use the fork notation to represent a state splitting into two or more concurrent states. Join –We use the join notation when two or more states concurrently converge into one on the occurrence of an event or events Self transition- We use a solid arrow pointing back to the state itself to represent a self transition. when the state of the object does not change upon the occurrence of an event. A STATE CHART DIAGRAM FOR RESERVATION OF TICKETS & DISPLAY OF CONFIRMATION FORM. THANK YOU!! 1-43