1. Trang chủ
  2. » Công Nghệ Thông Tin

Chương 1: Giới thiệu UML

36 7 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 36
Dung lượng 1,11 MB

Nội dung

OOAD là một kỹ thuật để phân tích các yêu cầu và tạo ra các thiết kế cho một hệ thống phần mềm. Phân tích được thực hiện bằng cách sử dụng OOAD cần được mô tả trong một hình thức đồ họa. Phương pháp này hiển thị thông tin đồ họa được gọi là mô hình trực quan. Các mô hình hình ảnh của một hệ thống phần mềm có thể được tạo ra bằng cách sử dụng Unified Modeling Language (UML). UML cung cấp một loạt các biểu đồ để đại diện cho cấu trúc và thiết kế...

OOAD is a technique for analyzing the requirements and creating the design for a software system The analysis done using OOAD needs to be depicted in a graphical form This method of displaying the information graphically is known as visual modeling The visual models of a software system can be created by using Unified Modeling Language (UML) UML provides a variety of diagrams to represent the structure and design of a software system It helps project teams to communicate, explore potential designs, and validate the architectural design of the software This chapter discusses the need, scope, and building blocks of UML It explains the types of UML diagrams and the various views of software systems In addition, the chapter provides an overview of Microsoft Visio as a UML tool Finally, it discusses the benefits, the life cycle, and the best practices of Rational Unified Process (RUP) Objectives In this chapter, you will learn to:  Identify the evolution, scope, and building blocks of UML  Identify the types of UML diagrams  Use Microsoft Visio to create UML diagrams  Identify the benefits, lifecycle, and best practices of RUP Chapter Introducing UML Overview of UML Consider an architect who has acquired a contract of a building The architect needs to work out the blueprint of the building on paper and get it approved from the client before the construction of the building actually begins The same analogy applies to software systems You need to create a blueprint that depicts the structure and design of the software system before the development of the software system begins At the onset, if you model the blueprint of the software system, it prevents the occurrence of any design faults This reduces the rework and development time of the system in the later phases of SDLC Unified Modeling Language (UML) is a standard language for creating blueprints that depict the structure and design of the software system You can use UML for modeling systems that can range between enterprise information systems to distributed Web-based applications UML is a notational language that enables the stakeholders to view the architecture of the system from various perspectives There are several tools available, such as Rational Rose, Jude, AgroUML, Visio and Poseidon, which you can use to design software systems by using UML Evolution of UML The evolution of UML began with the need for a modeling language in which you can develop models of object-oriented software systems During the mid 1970s and late 1980s, object-oriented modeling languages were developed for the analysis and design of software Of these modeling languages, the most prominently used languages were Booch’s Booch’93, Jacobson’s Object Oriented Software Engineering (OOSE), and Rumbaugh’s Object Modeling Technique-2 (OMT) Each of these languages was complete in itself and was recognized as having certain strengths and weaknesses For example, Booch’93 was efficient in projecting the software system during the design and construction phases of the projects OOSE was more helpful in the requirements capturing and analysis phases OMT was used for the analysis of data-intensive information systems Because several modeling languages were being used in the industry, there was a need for a standard language for modeling In October 1994, Grady Booch, Ivor Jacobson, and Jim Rumbaugh of Rational Software Corporation began the unification of Booch’93, OMT, and OOSE They developed a unified language and released version 0.9 and 0.91 of UML To standardize UML, Object Management Group (OMG), a non-profit organization for standardizing specifications, issued a Request for Proposal (RFP) in 1996 In response to the RFP issued by OMG, a UML consortium was established with the support of major ÔNIIT Introducing UML 2.3 software organizations such as HP, I-Logix, IBM, Microsoft, Oracle, Rational Software, and Unisys The UML consortium prepared and presented the revised version of UML 1.1 to OMG Finally, OMG accepted UML as a standard modeling language and took over the responsibility for overseeing the maintenance of UML Many versions of UML were released with more additions and modifications This course discusses UML 2.0 Scope of UML Rational Software Corporation, which has now been acquired by IBM, defines UML as follows: “The Unified Modeling Language (UML) is a language for specifying, constructing, visualizing, and documenting the artifacts of a software-intensive system.” The artifacts might include requirements, architecture, design in terms of classes, objects or interfaces, source code, tests, prototypes, and the software releases of a software system For a better understanding, you can further divide the definition of UML into the following sub-parts: „ UML is a language for specifying artifacts: This means that UML provides the notations for classes, objects, and interfaces, which enable the development team to define the scope and content of a software system „ UML is a language for visualizing artifacts: This means that UML allows you to create diagrams to visualize a software system Creating diagrams provides a better understanding of the structure and content of the software system For example, a diagram depicts the hierarchical arrangement of classes more clearly than code Another benefit is that even if the code is lost, the logical structure of the system remains intact in the form of diagrams The use of predefined notations for developing diagrams enables one development team to interpret the models created by other teams „ UML is a language for constructing artifacts: This means that UML allows code generation from a UML model Generating code from a UML model is called forward engineering In addition, UML enables reverse engineering, which means it allows you to reconstruct a model from code „ UML is a language for documenting artifacts: This means that you can use the diagrams as input documents for the subsequent phases of SDLC Building Blocks of UML The building blocks of UML include the components that are necessary for creating models of the software systems The three types of UML building blocks are: „ Basic UML constituents: Include the static, dynamic, grouping, and annotational constituents of UML 2.4 Introducing UML ÔNIIT Relationships: Depict the relations between the various constituents of a UML model Diagrams: Represent the various artifacts of a system graphically Diagrams enable you to visualize a system from all the aspects of software development To understand the basic UML constituents, let us revisit the analogy of constructing a building You require bricks, sand, cement, plastic, and iron bars as the base constituents to begin the construction of a building These constituents not change when you are giving shape to the building Similarly, to begin the design of a software system, you need to identify classes, interfaces, objects, use cases, collaborations, components, and nodes These form the static constituents of the software system because they not change even while you identify the interactions or change of state of these constituents Again going back to the analogy of the building, you need to identify which door leads to which room and which window is opening in which direction This will give a shape to the building You may also refer to it as the behavior of the building Similarly, the static constituents, such as classes, need to interact to depict their response to the other objects and classes You can depict such responses and relations between classes by using messages at the design phase Messages and states form the dynamic constituents of the software system The walls, doors, windows, ceiling, and floor make up a room of the building Going into more detail, the rooms, kitchen, and wash rooms form the complete apartment Similarly, the classes and interfaces need to be grouped in packages, which in turn, can be grouped together to form a complete software system A package is the grouping constituent used in UML Each apartment in the building has an owner and a name plate of its owner Similarly, to provide more explanation on each structural or grouping constituent, such as classes and packages, you should provide an explanation on the role of each constituent in the model The UML annotational constituent, note, provides an explanation on the structural, behavioral, and grouping constituents ÔNIIT Introducing UML 2.5 Identifying the Types of UML Diagrams UML provides the following thirteen diagrams to represent the structure and design of a software system: „ Use case diagrams „ Class diagrams „ Object diagrams „ Communication diagrams „ Sequence diagrams „ State Machine diagrams „ Activity diagrams „ Package Diagrams „ Component diagrams „ Deployment diagrams „ Timing Diagrams „ Composite Structure Diagrams „ Interaction Overview Diagrams Note UML diagrams use various notations to specify the syntax of the constructs used for creating the diagrams For example, UML notations specify how to depict the user or the classes and interfaces of the system Defining Use Case Diagrams A use case diagram depicts the various operations that a system performs It contains use cases, actors, and their relationships Use cases are the sequence of actions that form a single unit of work for an actor An actor represents a user who is external to the system and interacts with the use case 2.6 Introducing UML ÔNIIT The following figure depicts the graphical notation for a use case diagram Relationship Use Case Actor Graphical Notation for a Use Case Diagram A use case diagram can be drawn for any given software system For example, in an order processing system, the inventory department places a request for the machine parts that are out of stock In this case, the inventory department is an actor that uses the system to place an order for the parts Similarly, the inventory department also receives the supply to update the stocks The use cases for the actor, Inventory Department, are Order Parts and Accept Supply The following figure shows the use case diagram for the order processing system Order Parts Inventory Department Accept Supply Use Case Diagram for the Order Processing System Defining Class Diagrams A class diagram represents a set of classes, interfaces, and their relationships You can represent a class in a rectangular box with three compartments The first compartment shows the class name The second compartment shows the attributes of the class and the third compartment shows the methods associated with the class ÔNIIT Introducing UML 2.7 The following figure shows the graphical notation for classes along with their attributes, methods, and relationships Class1 Class2 Attributes Attributes Methods Methods Class3 Attributes Methods Graphical Notation for Classes You can draw a class diagram by identifying the classes in the system For example, the classes identified in the order processing system are Supplier and Parts The various attributes of the Supplier class are scode, name, and city, and the methods of the Supplier class are supply() and receivepayment() The various attributes for the Parts class are pcode, name, qty_ordered, qty_received, and qty_rejected, and the methods of the Parts class are order(), received(), and updateinventory() The following figure shows the class diagram for the order processing system Parts Supplier scode name city supply() receivepayment() pcode name qty_ordered qty_received qty_rejected order() received() updateinventory() Class Diagram for the Order Processing System 2.8 Introducing UML ÔNIIT Defining Object Diagrams An object diagram represents instances of a class diagram You represent an object in a rectangular box with two compartments The object name appears before the class name in the first compartment The second compartment shows the attributes of the objects The following figure shows the graphical notation for objects along with their attributes and relationships Graphical Notation for an Object Diagram You can draw an object diagram by identifying the classes in the system The following figure shows the object diagram for the order processing system Object Diagram for the Order Processing System Defining Communication Diagrams Communication diagrams represent an interaction between objects in the form of messages For example, the following figure depicts the interaction between the Inventory Department and an object of the supplier class of the order processing system Places Order supp1: Supplier Supplies Order Inventory Department Communication Diagram for the Order Processing System Communication diagrams are also called as collaboration diagrams ÔNIIT Introducing UML 2.9 Defining Sequence Diagrams Sequence diagrams represent an interaction between objects in the form of messages ordered in a sequence by time The difference between the sequence and communication diagrams is that communication diagrams emphasize on the structural organization of objects as opposed to sequence diagrams that show the messages exchanged between objects ordered in a sequence by time You can draw a sequence diagram for any given system by using the classes and use cases identified for the system The following diagram shows the sequence of messages in the order processing system Inventory Department supp1: Supplier Places Order Supplies Order Sequence Diagram for the Order Processing System In the order processing system, the Inventory Department places the order with the supplier, supp1 The supplier, supp1, supplies these parts to the Inventory Department Defining State Machine Diagrams A state machine diagram shows how a class reacts when an event occurs You can draw a state machine diagram by using the classes and the use cases identified for the system For example, in the order processing system, the Parts class has an attribute, re-order An order is placed when the stock reaches a particular level In this case, the re-order attribute is set to true After the supplier supplies the parts, the re-order level is changed to false 2.10 Introducing UML ÔNIIT The following figure shows the multiple views that together represent the model of a software system designed using UML Design View Process View Use Case View Implementation View Deployment View Multiple Views of a Software System Each of the five views are interlinked For example, the deployment view includes the classes, interfaces, and collaborations of the design view In addition, the use case view is placed in the center because it is used to capture and represent the system requirements from the perspective of other views Just a minute: Which of the following views of a software system focuses on the static and dynamic representation of the system? Use Case view Deployment view Design view Implementation view Answer: Design view 2.22 Introducing UML ¤NIIT Identifying the Role of UML in SDLC The diagrams developed using UML serve as key documents in each phase of SDLC In addition, you can use UML to develop software systems based on any SDLC model For example, you can use UML to design a software system that follows the linear, prototyping, or iterative approach to system modeling You can map each of the UML diagrams with the various phases of SDLC The requirement analysis phase of SDLC involves identifying the end users’ expectations from a software system The following table lists the UML diagrams that can be used in the requirement analysis phase Diagram Role in the Requirements Analysis Phase Use case Depicts the various users of the system and how they are going to use the system to meet the requirement objectives Class Depicts the classes and their dependencies for the primary requirements of the system Sequence and Communication Depicts the sequence of steps performed in a process Activity Depicts the specific activities that are required to understand the functional requirements of the system Interaction Overview Depicts how the various processes interact with each other UML Diagrams and their Role in the Requirement Analysis Phase In the design phase, the analysts and architects can be more specific in depicting the details of the system through the UML diagrams The following table lists various UML diagrams that you can use in the design phase Diagram Role in the Design Phase Class Depicts the classes, their attributes and operations, and the relationship between classes Sequence and Communication Depicts the sequence of interactions between the various objects of the system Package Depicts the various classes that are grouped together depending on their functionality Deployment Depicts the layout of the software components over the network State Depicts the state of an object on the occurrence of an event ÔNIIT Introducing UML 2.23 Diagram Role in the Design Phase Component Depicts the components required for executing the system Composite Structure Depicts the internal structure and interaction points of the various classes, objects, and interfaces Interaction Overview Depicts the interactions between the various interaction diagrams UML Diagrams and their Role in the Design Phase In the testing phase, you test the system to detect whether the software system works according to the requirements You use the use case diagram in the test phase to check whether the system meets the requirements specified in the use case diagrams 2.24 Introducing UML ÔNIIT Introducing Visio as a UML Tool Visio is a Microsoft tool that facilitates object-oriented design using UML This tool runs efficiently on Windows XP, Windows 2000, Windows NT, and Mac operating systems It helps to create UML diagrams It also helps in generating C#, C++, or Visual Basic code for the UML diagrams Using Visio to Create UML Diagrams To create a simple use case diagram using Visio, you need to perform the following steps: Select StartỈAll ProgramsỈMicrosoft OfficMicrosoft Office Visio for Enterprise Architects The Microsoft Visio window appears Select FilNewỈChoose Drawing Type The Choose Drawing Type window appears, as shown in the following figure Microsoft Visio Window ÔNIIT Introducing UML 2.25 Click Software from Category section in the Choose Drawing Type window All the templates will appear in the Template section, as shown in the following figure Visio Window Displaying the Software Templates 2.26 Introducing UML ÔNIIT Select UML Model Diagram (Metric) from the list of templates The Drawing1Microsoft Visio window with a blank drawing page appears, as shown in the following figure Shapes Window Stencils Drawing Page Model Explorer Window Visio Drawing Window The stencils contain the shapes you need to create your diagrams Note The English-language version of Microsoft Office Visio comes with two sets of templates: those that use US units and those that use metric units US units are the units used in the US measurement system, such as inches, feet, yards, and miles If you want to create some drawings that use metric and some that use US units, you need to install both sets of templates You can choose which units you want to use when you start a new drawing ¤NIIT Introducing UML 2.27 Select the UML Use Case (Metric) stencil in the Shapes window to view the shapes it contains, as shown in the following figure UML Drawing Window Drag the Actor symbol ( stencil, to draw an actor ) on the drawing page from the UML Use Case (Metric) ) on the drawing page from the UML Use Case Drag the Use case symbol ( (Metric) stencil, to draw a use case ) on the drawing page from the UML Use Drag the Communication symbol ( Case (Metric) stencil, to represent the interaction between the actor and the use case Drag one end of the Communication symbol and drop it on a cross symbol known as Connection Point on the actor so that one end of the Communication symbol gets connected to the actor Now drag the other end of the Communication symbol and drop it on the use case 2.28 Introducing UML ÔNIIT Note Actor and use case need to be connected through an association In Visio an association is represented by using the Communication symbol This connects the actor with the use case to create a simple use case diagram, as shown in the following figure Simple Use Case Diagram Created Using Visio Note The cross symbols on a shape represent the connection points Two symbols will connect with each other only if they are connected at these connection points If the connection points are not visible, select ViewỈConnection Points to make connection points visible with each symbol on the drawing page If you not want to view the connection points, you can hide them by again selecting ViewặConnection Points ÔNIIT Introducing UML 2.29 Identifying Rational Unified Process (RUP) RUP is a software development methodology developed by Rational Software Corporation, which is now a division of IBM It is a process framework that helps you create and deploy software designed using OOAD RUP provides templates, examples, and tools that act as mentors for all the activities performed in the different phases of the software development process It includes a hyperlinked knowledge base with sample artifacts and detailed descriptions for many different types of activities Using RUP, the development team has a common knowledge base, language, process, and view on how to develop the software RUP is completely compatible with UML and is integrated with the Rational suite of software development tools RUP is included in the IBM Rational Method Composer (RMC) product, which allows customization of the process RUP utilizes Rational tools to generate development components, such as documents, manuals, and code Benefits of Using RUP RUP is a process that helps manage the quality and risks in a software project The benefits of using RUP are: „ Provides team members with easy access to a knowledge base and, as a result, enhances team productivity „ Provides a guideline on how to effectively use UML „ Supports the tools that automate large parts of the development process „ Supports the iterative process for software development This allows you to identify and resolve the risks in a software project that are identified during the various iterations of the software development process „ Supports an architecture-centric development process In addition, RUP focuses on the early development of software architecture, which facilitates parallel development, minimizes rework, and increases the probability of component reuse and eventual system maintainability „ Allows customization of the process This means that RUP can be tailored to the needs of small development teams as well as large development organizations „ Allows you to systematically control the changes in the software during the development life cycle „ Allows you to execute test cases 2.30 Introducing UML ÔNIIT Life Cycle of RUP RUP defines the following four phases of the life cycle of a project: „ Inception: Includes establishing the business model and the scope for the project In addition, it also involves planning for the type of development process model „ Elaboration: Includes analyzing the problem domain, developing project plan, and eliminating highest possible risks This phase also includes development of architectural plan after the analysis of the entire system is complete In addition, the phase includes implementing use cases to demonstrate the architecture of the software system „ Construction: Includes developing software product iteratively and incrementally At the end of iteration, the product is released for customer evaluation The activities of the phase include design, implementation, and testing of the software „ Transition: Includes deploying software at the customer site This phase also includes maintaining the software if faults or errors occur in the software after its deployment Note Business modeling describes the working of the existing processes of the organization and the role of each person involved in the process RUP Best Practices RUP has defined the following six best practices that you should follow in the software development process: „ Develop software iteratively „ Manage requirements effectively „ Use a component-based development approach „ Visually model the software „ Verify the software quality „ Control any changes to the software ÔNIIT Introducing UML 2.31 Just a minute: Which of the following phases of RUP includes analyzing the problem domain, developing project plan, and eliminating highest possible risks? Inception Elaboration Construction Transition Answer: Elaboration 2.32 Introducing UML ÔNIIT Practice Questions Which of the following diagrams is a part of dynamic modeling? a Deployment diagram b Sequence diagram c Class diagram d Component diagram Which of the following views of a software system represents the physical system including the files and components required to assemble the system? a Use case view b Design view c Implementation view d Deployment view Which Rational Unified Process phase implements use cases to demonstrate the architecture of the software system? a Inception b Elaboration c Construction d Transition UML stands for: a Unified Modeling Language b Unified Markup Language c Undefined Modeling Language d Undefined Markup Language In a use case diagram, an actor can be linked to: a A single use case b Multiple use cases c Maximum of two use cases d Minimum of two use cases ÔNIIT Introducing UML 2.33 Summary In this chapter, you learned that: „ Unified Modeling Language (UML) is a standard language for creating blueprints that depict the structure and design of the software system It is used to specify, visualize, construct, and document the artifacts of a software system „ The building blocks of UML consist of basic constituents, relationships, and diagrams The basic constituents include the structural, behavioral, grouping, and annotational constituents „ UML diagrams enable you to visualize the software system by graphical representation of the various constituents „ The thirteen UML diagrams are use case, class, object, communication, sequence, state machine, activity, package, component, deployment, timing, composite structure, and Interaction overview „ The architecture of a software system can be viewed from the different perspectives of the stakeholders „ UML diagrams are used in the analysis and design phases of SDLC „ Visio is a tool that can be used to draw UML diagrams „ Rational Unified Process (RUP) is a software development methodology developed by Rationale Software Corporation, which is now a division of IBM It is a process framework that helps you to create and deploy software designed using UML 2.34 Introducing UML ÔNIIT Exercises Exercise Technology Systems Inc decided to create a new computer to provide simulation environment for developing real-time systems Technology System Inc would require advanced hardware and operating system to manufacture the new computer System programs, which provide the interface between the operating system and the hardware, also need to be developed The company has experienced Java programmers and, therefore, it decides to write the system programs in Java The Project Manager is aware of the limitations of Java in system programming The programming team identifies some of the additional features or extensions that need to be embedded in the existing Java compiler for system programming It is also known that requirements can evolve during the development phase of the project Other team members are also developing software for the new computer and need the Java compiler to compile the software Most of these software requirements require few extensions in the Java language to run on a new Operating System Identify the approach to be used to create the computer ÔNIIT Introducing UML 2.35 2.36 Introducing UML ÔNIIT ... teams „ UML is a language for constructing artifacts: This means that UML allows code generation from a UML model Generating code from a UML model is called forward engineering In addition, UML enables... revised version of UML 1.1 to OMG Finally, OMG accepted UML as a standard modeling language and took over the responsibility for overseeing the maintenance of UML Many versions of UML were released... modifications This course discusses UML 2.0 Scope of UML Rational Software Corporation, which has now been acquired by IBM, defines UML as follows: “The Unified Modeling Language (UML) is a language for specifying,

Ngày đăng: 11/05/2021, 00:15