Document Details

RadiantInfinity6072

Uploaded by RadiantInfinity6072

Pondicherry University

Tags

uml diagrams unified modeling language object-oriented analysis and design software engineering

Summary

This document provides an overview of UML diagrams, including use case diagrams, class diagrams, interaction diagrams, state diagrams, and activity diagrams. It also details requirements for an ATM banking system case study.

Full Transcript

UNIT II UML Diagrams: Use case diagram – UML class diagram – interaction diagram – state diagram – activity diagram – Requirements for ATM banking system – case study.  INTRODUCTION  A model is an abstract representation of a system, constructed to understand the system prior to building or...

UNIT II UML Diagrams: Use case diagram – UML class diagram – interaction diagram – state diagram – activity diagram – Requirements for ATM banking system – case study.  INTRODUCTION  A model is an abstract representation of a system, constructed to understand the system prior to building or modifying it.  The term system is used to include any process or structure. Example, the organizational structure of a corporation.  According to Egraim Turban, model is a simplified representation of reality. The model provides a means of conceptualization and communication of ideas in a specific and clear form.  Static Model And Dynamic Model  Static Model  It can be viewed as a snapshot of a system’s parameters at rest or at specific point in time. Static models are needed to represent the structural or static aspect of a system.  Eg. Customer having more than one account. UML is an example of a static model.  Dynamic Model  It can be viewed as a collection of procedures or behaviors that reflect the behavior of the system over time.  It explains how the business objects interact with each other to perform tasks.Eg. UML interaction diagram and activity models.  Following are the advantages of having modeling as an important concept o Clarity o Familiarity o Maintenance o Simplification  UML- Unified Modeling Language  UML is a language for specifying, constructing, visualizing and documenting the software system and its components.  UML is graphical language with sets of rules and semantics. The rules and semantics of a model are expresses in English in a form known as object constraint language (OCL).  OCL is a specification language that uses simple logic for specifying the properties of a system.  The primary goals in the design of the UML are: o Provide users a ready-to-use, expressive visual modeling language so they can develop and exchange meaningful models. o Provide extensibility and specialization mechanisms to extend core concepts. o Be independent of particular programming language and development process. o Provide a formal basis for understanding the modeling language. o Encourage the growth of the OO tools market. o Support higher level development concepts. o Integrate best practices and methodologies.  UML Diagrams  Every complex system is best approached through a small set of nearly independent views of a model.  Every model may be expressed in different levels of fidelity. The UML defines 9 graphical diagrams: o Class Diagram(static) o Use case diagram o Behavior diagram  Interaction diagram  Sequence diagram  Collaboration diagram  Statechart diagram  Activity diagram o Implementation diagram  Component diagram  Deployment diagram  The choice of what models and diagram one created has a great influence on how a problem is encountered and how a corresponding solution is shaped  USE CASE DIAGRAM  The use case concept was introduced by Ivar Jacobson in the Object Oriented Software Engineering(OOSE) method.  The functionality of a system is described in a number of different use cases, each of which represents a specific flow of events in the system.  A use case corresponds to a sequence of transactions, in which each transaction is invoked from outside the system (actors).  It engages internal objects to interact with one another and with the system’s surroundings.  An Actor is a Stick figure labeled with the name of the Actor. An actor is a person, group, or system that interacts with the use case. The actor symbol represents a textual explanation of the actor that is created in a document independently from a diagram. Fig 1: UML symbols for use case diagram  The description of a use case defines what happens in the system when the use case is performed.  The use case model defines the outside(actors) and the inside(use case) of the system’s behavior.  Use case represents the specific flows of events in the system.  The use cases are initiated by actors and describe the flow of events in the system that these actors set off.  An actor is anything that interacts with the use case: can be a human user, external hardware or another system.  Several users can play the same role. Eg, in terms of member actor, many people can be members of library, which can be represented by one actor called Member.  A use-case diagram is a graph of actors, a set of use case enclosed by a system boundary, communication(participation) associations between the actors and the use cases, and generalization among the use cases. Fig 2: Use case diagram for wheels Fig 3: A use case diagram shows the relationship among actors and use cases within a system  In the above figure the client makes a calls that is taken by an operator, who determines the nature of the problem.Some calls can be answered immediately, other calls require research and a return call.  A use case is shown as an ellipse containing the name of the use case. The name of the use case can be placed below or inside the ellipse.  Actor’s name and use case names should follow the capitalization and punctuation guidelines of the model.  An actor is shown as a class rectangle with the label , or the label and a stick figure, or just the stick figure with the name of the actor below the figure. Fig 4: Three Representation of an actor are equivalent  These relationships are shown in the use case diagram:  Communication: The communication relationship of an actor in a use case is shown by connecting the actor symbol to the use case symbol with a solid path. The actor is said to “communicate: with the use case.  Uses: A uses relationship between use cases is shown by generalization arrow from the use case.  Extends: This extends relationship is used when you have one use case that is similar to another use case but does a bit more. It is more like a sub class  UML CLASS DIAGRAM  The UML class diagram, is also referred to as object modeling. It is a static analysis diagram. These diagram represent the static structure of the model.  A class diagram is the collection of static modeling elements, such as classes and their relationships, connected as a graph to each other and to their contents.  For eg. The things that exist, their internal structures and their relationships to other classes.  Class diagrams don’t show any temporal information, which is required in dynamic modeling.  Object modeling is the process by which the logical objects in the real world are represented by the actual objects in the program.  First should understand what objects are necessary to model the system  Class Notation: Static Structure  A class is drawn as a rectangle with three components separated by horizontal lines.  The top name compartment holds the class name, the middle compartment other general properties of the class such as attributes and the bottom compartment holds the list of operations. Fig 5: CLASS Notation  Object Diagram  A static object diagram is an instance of a class diagram. IT shows the snapshot of the detailed state of the system at a point of time. Notation is the same for an object diagram and a class diagram.  Class diagram can contain objects, so a class diagram with objects and no classes is an object diagram.  Class Interface Notation  Class interface notation is used to describe the externally visible behavior of a class. Eg. An operation with public visibility.  Identifying class interfaces is a design activity of object oriented system development.  The UML notation for an interface is a small circle with the name of the interface connected to the class.  A class that requires the operations in the interface may be attached to the circle by the dashed arrow.  For eg.A person object may need to interact with the BankAccount object to get the Balance. Fig 6: Interface notation of a class  Binary Association Notation  It is drawn as a solid path connecting two classes or both ends may be connected to the same class.An association may have an association name.  The association name may have an optional black triangle in it, the point of triangle indicating the direction in which to read the name.  The end of an association, where it connects to a class, is called the association role. Fig 7: Association Notation  Association Role  The role is part of association, not part of the class.Each association has two ir more roles to which it is connected. Fig 8: Association notation  The above figure explains the association works. For that connects two roles employee and employer.Person is the employee of the company and the company is the employer of a Person.  The UML uses the term association navigation or navigability to specify a role affiliated with each end of an association relationship.  An arrow may be attached to the end of the path to indicate that navigation is supported in the direction of the class pointed to.  Arrows could be shown whenever navigation is supported in a given direction. Fig 9: Association role  Navigability is distinguished from inheritance, which is denoted by an unfilled arrow head symbol near the superclass.  Eg. The association is navigable in only direction, from the BankAccount to Person, but not the reverse.  Qualifier  A qualifier is an association attribute. Eg. A person object may be associated to a Bank object. An attribute of this association is the account#.  A qualifier is shown as a small rectangle attached to the end of an association path, between the final path segment and the symbol of the class to which it connects.  The qualifier rectangle is part of the association path, not part of the class. The qualifier rectangle is usually smaller than the attached class rectangle. Fig 10: Association qualifier and multiplicity  Multiplicity  This specifies the range of allowable associated classes.It is given for roles within association,parts within composition,repetitions and other purposes.  A multiplicity specification is shown as a text string comprosing a period separated sequence of integer intervals, where an interval represents a range of integers in this format  Lower bound..upper bound  The terms lower bound and upper bound are integer values, specifying the range of integers including the lower bound to higher bound.  The star character (*) may be used for upper bound, denoting an unlimited upper bound.  If a single integer value is specified ,then the integer range contains the single values. Eg 0..1 0..* 1..3,7..10,15,19..*  OR Association  An OR association indicates a situation in which only one of the several potential association may be instantiated at one time for any single object.  This is shown as a dashed line connecting two or more associations, all of which must have a class in common, with the constraint string {or} labeling the dashed line. Fig 11.An OR association notation. A car may associate with person or a company  Association Class  An association class is an association that also has class properties.An association class is shown as a class symbol attached by a dashed line to an association path.  The name in the class symbol and the string attached to the association path are same.  N-ary Association  It is an association among more than two classes.  As it is difficult to understand n-ary association, it is better to convert n-ary to binary association.  An n-ary association is shown as a large diamond with a path from the diamond to each participant class.  The name of the association is shown near the diamond. The role attachment may appear on each path as with a binary association.  An association line can be attached to the diamond by dashed line. Fig 13: a n-ary association  Aggregation and Composition( a –part-of)  Aggregation is a form of association. A hollow diamond is attached to the end of the path to indicate aggregation.  Composition, also known as a –part-of is a form of aggregation with strong ownership to represent the component of a complex object. It is also referred to as part- whole relationship.  The UML notation for composition is a solid diamond at the end of a path.  Generalization Generalization is the relationship between a more general class and a more specific class. It is displayed as a directed line with a closed, hollow arrow head at the super class end. Fig 14:Generalization  INTERACTION DIAGRAM  From the name Interaction it is clear that the diagram is used to describe some type of interactions among the different elements in the model. So this interaction is a part of dynamic behavior of the system.  This interactive behavior is represented in UML by two diagrams known asSequence diagram and Collaboration diagram. The basic purposes of both the diagrams are similar.  Sequence diagram emphasizes on time sequence of messages and collaboration diagram emphasizes on the structural organization of the objects that send and receive messages.  Purpose:  The purposes of interaction diagrams are to visualize the interactive behaviour of the system. Now visualizing interaction is a difficult task.  So the solution is to use different types of models to capture the different aspects of the interaction.  That is why sequence and collaboration diagrams are used to capture dynamic nature but from a different angle. So the purposes of interaction diagram can be describes as: o To capture dynamic behaviour of a system. o To describe the message flow in the system. o To describe structural organization of the objects. o To describe interaction among objects.  How to draw Interaction Diagram?  The purpose of interaction diagrams is to capture the dynamic aspect of a system.  So to capture the dynamic aspect we need to understand what a dynamic aspect is and how it is visualized.  Dynamic aspect can be defined as the snap shot of the running system at a particular moment.  There are two types of interaction diagrams in UML. o Sequence diagram o Collaboration diagram.  The sequence diagram captures the time sequence of message flow from one object to another and the collaboration diagram describes the organization of objects in a system taking part in the message flow. So the following things are to identified clearly before drawing the interaction diagram: o Objects taking part in the interaction. o Message flows among the objects. o The sequence in which the messages are flowing. o Object organization.  Following are two interaction diagrams modeling order management system. The first diagram is a sequence diagram and the second is a collaboration diagram.  The Sequence Diagram  The sequence diagram is having four objects (Customer, Order, SpecialOrder and NormalOrder).  The following diagram has shown the message sequence for SpecialOrder object and the same can be used in case of NormalOrder object. Now it is important to understand the time sequence of message flows. The message flow is nothing but a method call of an object.  The first call is sendOrder () which is a method of Order object. The next call isconfirm () which is a method of SpecialOrder object and the last call is Dispatch () which is a method of SpecialOrder object. So here the diagram is mainly describing the method calls from one object to another and this is also the actual scenario when the system is running. Fig :Sequence Diagram  The Collaboration Diagram  The second interaction diagram is collaboration diagram. It shows the object organization as shown below.  Here in collaboration diagram the method call sequence is indicated by some numbering technique as shown below.  The number indicates how the methods are called one after another. We have taken the same order management system to describe the collaboration diagram.  The method calls are similar to that of a sequence diagram. But the difference is that the sequence diagram does not describe the object organization where as the collaboration diagram shows the object organization.  Now to choose between these two diagrams the main emphasis is given on the type of requirement. If the time sequence is important then sequence diagram is used and if organization is required then collaboration diagram is used. Fig: Collaboration diagram  Where to use Interaction Diagrams?  The interaction diagrams are used to describe dynamic nature of a system.  The main purposes of both the diagrams are similar as they are used to capture the dynamic behavior of a system. But the specific purposes are more important to clarify and understood.  Sequence diagrams are used to capture the order of messages flowing from one object to another. And the collaboration diagrams are used to describe the structural organizations of the objects taking part in the interaction.  A single diagram is not sufficient to describe the dynamic aspect of an entire system so a set of diagrams are used to capture is as a whole.  The interaction diagrams are used when we want to understand the message flow and the structural organization. Now message flow means the sequence of control flow from one object to another and structural organization means the visual organization of the elements in a system. In a brief the following are the usages of interaction diagrams: o To model flow of control by time sequence. o To model flow of control by structural organizations. o For forward engineering. o For reverse engineering.  STATECHART DIAGRAM  The name of the diagram itself clarifies the purpose of the diagram and other details. It describes different states of a component in a system. The states are specific to a component/object of a system.  A Statechart diagram describes a state machine. Now to clarify it state machine can be defined as a machine which defines different states of an object and these states are controlled by external or internal events.  A statechartdiagram(state diagram) shows the sequence of states that an object goes through during its life in response to outside stimuli and messages.  The state is the set of values that describes an object at a specific point in time and is represented by state symbols and transitions are represented by arrows connecting the state symbols.  Purpose:  Statechart diagram is one of the five UML diagrams used to model dynamic nature of a system. They define different states of an object during its lifetime.  And these states are changed by events. So Statechart diagrams are useful to model reactive systems. Reactive systems can be defined as a system that responds to external or internal events.  Statechart 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.  So the most important purpose of Statechart diagram is to model life time of an object from creation to termination.  Statechart diagrams are also used for forward and reverse engineering of a system. But the main purpose is to model reactive system. Following are the main purposes of using Statechart diagrams: o To model dynamic aspect of a system. o To model life time of a reactive system. o To describe different states of an object during its life time. o Define a state machine to model states of an object.  How to draw Statechart Diagram?  Statechart diagram is used to describe the states of different objects in its life cycle. So the emphasis is given on the state changes upon some internal or external events.  These states of objects are important to analyze and implement them accurately.  Statechart diagrams are very important for describing the states. States can be identified as the condition of objects when a particular event occurs. Before drawing a Statechart diagram we must have clarified the following points: o Identify important objects to be analyzed. o Identify the states. o Identify the events.  The following is an example of a Statechart diagram where the state of Orderobject is analyzed.  The first state is an idle state from where the process starts. The next states are arrived for events like send request, confirm request, and dispatch order. These events are responsible for state changes of order object.  During the life cycle of an object (here order object) it goes through the following states and there may be some abnormal exists also. This abnormal exit may occur due to some problem in the system.  When the entire life cycle is complete it is considered as the complete transaction as mentioned below. The initial and final state of an object is also shown below. Fig: State Chart diagram  Where to use Statechart Diagrams?  Statechart diagrams are used to model dynamic aspect of a system like other four diagrams discussed in this tutorial.  But it has some distinguishing characteristics for modeling dynamic nature.  Statechart diagram defines the states of a component and these state changes are dynamic in nature.  So its specific purpose is to define state changes triggered by events. Events are internal or external factors influencing the system.  Statechart diagrams are used to model states and also events operating on the system. When implementing a system it is very important to clarify different states of an object during its life time and statechart diagrams are used for this purpose.  When these states and events are identified they are used to model it and these models are used during implementation of the system.  If we look into the practical implementation of Statechart diagram then it is mainly used to analyze the object states influenced by events. This analysis is helpful to understand the system behavior during its execution. So the main usages can be described as: o To model object states of a system. o To model reactive system. Reactive system consists of reactive objects. o To identify events responsible for state changes. o Forward and reverse engineering.  ACTIVITY DIAGRAM  Activity diagram is another important diagram in UML to describe dynamic aspects of the system.  Activity diagram is basically a flow chart to represent the flow form one activity to another activity. The activity can be described as an operation of the system.  So the control flow is drawn from one operation to another. This flow can be sequential, branched or concurrent. Activity diagrams deals with all type of flow control by using different elements like fork, join etc.  Purpose:  The basic purposes of activity diagrams are similar to other four diagrams. It captures the dynamic behavior of the system.  Other four diagrams are used to show the message flow from one object to another but activity diagram is used to show message flow from one activity to another.  Activity is a particular operation of the system. Activity diagrams are not only used for visualizing dynamic nature of a system but they are also used to construct the executable system by using forward and reverse engineering techniques. The only missing thing in activity diagram is the message part.  It does not show any message flow from one activity to another. Activity diagram is some time considered as the flow chart.  Although the diagrams looks like a flow chart but it is not. It shows different flow like parallel, branched, concurrent and single. So the purposes can be described as: o Draw the activity flow of a system. o Describe the sequence from one activity to another. o Describe the parallel, branched and concurrent flow of the system.  How to draw Activity Diagram?  Activity diagrams are mainly used as a flow chart consists of activities performed by the system. But activity diagram are not exactly a flow chart as they have some additional capabilities.  These additional capabilities include branching, parallel flow, swimlane etc.  Before drawing an activity diagram we must have a clear understanding about the elements used in activity diagram.  The main element of an activity diagram is the activity itself. An activity is a function performed by the system. After identifying the activities we need to understand how they are associated with constraints and conditions. So before drawing an activity diagram we should identify the following elements: o Activities o Association o Conditions o Constraints  Once the above mentioned parameters are identified we need to make a mental layout of the entire flow. This mental layout is then transformed into an activity diagram.  The following is an example of an activity diagram for order management system. In the diagram four activities are identified which are associated with conditions.  One important point should be clearly understood that an activity diagram cannot be exactly matched with the code. The activity diagram is made to understand the flow of activities and mainly used by the business users. The following diagram is drawn with the four main activities: o Send order by the customer o Receipt of the order o Confirm order o Dispatch order  After receiving the order request condition checks are performed to check if it is normal or special order. After the type of order is identified dispatch activity is performed and that is marked as the termination of the process. Fig : Activity Diagram  Where to use Activity Diagrams?  The basic usage of activity diagram is similar to other four UML diagrams. The specific usage is to model the control flow from one activity to another. This control flow does not include messages.  The activity diagram is suitable for modeling the activity flow of the system. An application can have multiple systems.  Activity diagram also captures these systems and describes flow from one system to another. This specific usage is not available in other diagrams. These systems can be database, external queues or any other system.  From the above discussion it is clear that an activity diagram is drawn from a very high level. So it gives high level view of a system.  This high level view is mainly for business users or any other person who is not a technical person.  This diagram is used to model the activities which are nothing but business requirements. So the diagram has more impact on business understanding rather implementation details. Following are the main usages of activity diagram: o Modeling work flow by using activities. o Modeling business requirements. o High level understanding of the system's functionalities. o Investigate business requirements at a later stage.  REQUIREMENTS FOR ATM  The software to be designed will control a simulated automated teller machine (ATM) having a magnetic stripe reader for reading an ATM card, a keyboard and display for interaction with the customer, a slot for depositing envelopes, a dispenser for cash, a printer for printing customer receipts, and a key-operated switch to allow an operator to start or stop the machine.  The ATM will communicate with the bank's computer over an appropriate communication link.  The ATM will service one customer at a time. A customer will be required to insert an ATM card and enter a personal identification number (PIN) - both of which will be sent to the bank for validation as part of each transaction.  The customer will then be able to perform one or more transactions. The card will be retained in the machine until the customer indicates that he/she desires no further transactions, at which point it will be returned - except as noted below.  The ATM must be able to provide the following services to the customer: o A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed. o A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope. o A customer must be able to make a transfer of money between any two accounts linked to the card. o A customer must be able to make a balance inquiry of any account linked to the card.  The ATM will communicate each transaction to the bank and obtain verification that it was allowed by the bank. In the case of a cash withdrawal or deposit, a second message will be sent after the transaction has been physically completed (cash dispensed or envelope accepted).  If the bank determines that the customer's PIN is invalid, the customer will be required to re-enter the PIN before a transaction can proceed. If the customer is unable to successfully enter the PIN after three tries, the card will be permanently retained by the machine, and the customer will have to contact the bank to get it back.  If a transaction fails for any reason other than an invalid PIN, the ATM will display an explanation of the problem, and will then ask the customer whether he/she wants to do another transaction.  The ATM will provide the customer with a printed receipt for each successful transaction, showing the date, time, machine location, type of transaction, account(s), amount, and ending and available balance(s) of the affected account ("to" account for tranfers).  The ATM will have a an operator panel with a key-operated switch (located on the "inside the bank" side) that will allow an operator to start and stop the servicing of customers.  When the switch is moved to the "off" position, the machine will shut down, so that the operator may remove deposit envelopes and reload the machine with cash, blank receipts, etc.  The operator will be required to verify and enter the total cash on hand before starting the system from this panel.  Functional Requirements o Insert ATM card o Validate ATM card o Enter Product task o Enter PIN o Validate PIN o Validate for the account type if the task is banking o Ask for amount to be withdrawn o Amount is debited if sufficient balance is available o Error message is displayed otherwise o Ask for printing advice if the task is balance enquiry  Non Functional Requirements o Performance Requirements:  Error message should be displayed at least 6 seconds  If there is no response from the bank computer after a request is rejected within minutes the card is rejected with an error message  The ATM dispenses money if and only if the withdrawal from the account is processed and accepted by the bank  Each bank may be processing transactions from several ATM’s at the same time. o Security Requirements  User accessibility is censured at all the times.  Users are advised to change their on first use  Users are advised not to tell their PIN to anyone  The maximum number of attempts to enter the PIN will be three o Safety Requirements  Must be safe kept in a physical aspects , say in a cabin.  Must be bolted to ground to avoid theft  Must have emergency phone outside the cabin  The ATM door must have an ATM card swipe slot

Use Quizgecko on...
Browser
Browser