Applying 4+1 View Architecture with UML 2 White Paper Copyright ©2007 FCGSS, All Rights Reserved
Total Page:16
File Type:pdf, Size:1020Kb
Applying 4+1 View Architecture with UML 2 White Paper Copyright ©2007 FCGSS, all rights reserved. www.fcgss.com Introduction Unified Modeling Language (UML) has been available since 1997, and UML 2 was released in 2004, building on an already successful UML 1.x standard. UML 2 comes with 13 basic diagram types to support Model Driven Architecture (MDA) and Model Driven Development (MDD). Philippe Kruchten originally presented the 4+1 View Model to describe the architecture of software-intensive systems. This approach uses multiple views to separate stakeholders’ concerns. The 4+1 View Approach is widely accepted by the software industry to represent application architecture blueprints. However, the industry has not yet completely embraced UML 2. IT architects are continuing with UML 1.x artifacts to represent architecture and are consequently missing out on the powerful benefits of the improvements made in UML 2. This article presents the approach for 4+1 View Architecture using UML 2 diagrams. It enhances the original concept of the approach using the current modeling standards and techniques, and aims to encourage Application Architects to adapt relevant UML 2 artifacts. This article discusses each of the views and allocates the UML 2 diagrams to these views. It does not, however, teach semantics and modeling using UML 2 notations. The audience is expected to have a basic understanding of UML and to be able to refer to UML 2 for further details. UML 2 Diagrams Let us briefly review the diagrams available in UML 2 Specification. UML 2 Superstructure Specification divides the 13 basic diagram types into two key categories: • Part I – Structural Diagrams: These diagrams are used to define static architecture. They comprise static constructs such as classes, objects, and components, and the relationships between these elements. There are six structural diagrams: Package Diagrams, Class Diagrams, Object Diagrams, Composite Structure Diagrams, Component Diagrams and Deployment Diagrams. • Part II – Behavioral Diagrams: These diagrams are used to represent dynamic architecture. They comprise behavioral constructs such as activities, states, timelines and the messages that run between different objects. These diagrams are used to represent the interactions among various model elements and instantaneous states over a time period. There are seven behavioral diagrams: Use Case Diagrams, Activity Diagrams, State Machine Diagrams, Communication Diagrams, Sequence Diagrams, Timing Diagrams and Interaction Overview Diagrams. UML 2 has introduced Composite Structure, Object, Timing and Interaction Overview diagrams. The remaining diagrams were borrowed from UML 1.x, although some of them were changed significantly. 4+1 View Architecture The fundamental organization of a software system can be represented by: • Structural elements and their interfaces that comprise or form a system • Behavior represented by collaboration among the structural elements • Composition of Structural and Behavioral elements into larger subsystems Such compositions are guided by desired abilities (non-functional requirements) like usability, resilience, performance, re-use, comprehensibility, economic and technology constraints and trade-offs etc. Also, there are cross-cutting concerns (like security and transaction management) that apply across all the functional elements 1 Architecture also means different things to different stakeholders. For example, a Network Engineer would only be interested in the hardware and network configuration of the system; a Project Manager in the key components to be developed and their timelines; a Developer in classes that make up a component; and a Tester in scenarios. So we need multiple view points for distinct stakeholders’ needs, showing what is relevant while masking the details that are irrelevant. The 4+1 View Approach is an ‘architecture style’ to organize an application’s architecture representations into views to meet individual stakeholder’s needs. Figure 1 shows the views in the 4+1 View Architecture. Software Architecture is the fundamental organization of CONCEPTUAL PHYSICAL a system, embodied in its components, their relationships to each other Logical View Implementation View “and the environment, and the principles governing its design and evolution. Configuration Functionality Management Use Case View — The definition of Scenarios Software Architecture as per IEEE Recommended Practice for Architectural Process View Deployment View Description of Software- Performance Intensive Systems (IEEE Scalability Throughput 1471-2000) Figure 1: 4+1 View Model Logical View (Object Oriented Decomposition) This view focuses on realizing an application’s functionality in terms of structural elements, key abstractions and mechanisms, separation of concerns and distribution of responsibilities. Architects use this view for functional analysis. ” The logical architecture is represented at different levels of abstraction and progressively evolves in iterations. 1. Vertical and horizontal divisions – The application can be vertically divided into significant functional areas (i.e., order capture subsystems, order processing subsystems). – Or, it can be horizontally divided into a layered architecture distributing responsibilities among these layers (i.e., presentation layers, services layers, business logic layers, and data access layers). 2. Representation of structural elements as classes or objects and their relationships. 2 UML 2 provides an elaborate set of diagrams to create a Logical View: 1. Class Diagrams or Structural Diagrams: These diagrams define the basic building blocks of a model. They focus on each individual class, the main operations and relationships to other classes’ associations, usage, composition, inheritance etc. 2. Object Diagrams: These diagrams show how instances of structural elements are related. They help understand the class diagrams when the relationships are complex. The object diagrams were informally used in the UML 1.x world; in UML 2 they are formal artifacts. 3. Package Diagrams: These diagrams are used to divide the model into logical containers or ‘packages’. They can be used to represent vertical and horizontal divisions as packages. 4. Composite Structure Diagrams: These diagrams help in modeling the parts contained by a class and the relationships between the parts. When parts are related, such diagrams significantly simplify the relationships between the classes. Ports are used to represent how a class hooks into the environment. These diagrams support collaborations that can be used to represent design patterns of cooperating objects. UML 2 has introduced these diagrams as a major improvement over earlier structural constructs. 5. State Machine Diagrams: These diagrams are necessary to understand the instant states of an object defined by a class. These diagrams are optionally used when there is a need to understand the possible states of a class. The diagram notations are intentionally kept out of the scope of this document. Please refer to Sparx Systems’ online tutorial to understand the notations (http://sparxsystems.com/resources/uml2_tutorial/). While modeling for the Logical View, start with the Class and Package diagrams and expand as necessary. Figure 2 shows the modeling approach for the Logical View. UML also provides profiles for data modeling using Entity Relationship (ER) Diagrams. ER Diagrams can also be considered as another form of Logical View. Some Architects prefer to capture ER Diagrams in a separate view called Data View. MODELING LOGICAL VIEW WITH UML2 Composite Package Structure 1. Start with class diagrams to model the system Diagrams Diagrams 2. Use package diagrams to logically group diagrams Optional use Class 3. Object diagrams when relationships between Diagrams classes need to be explained through instances 4. State Charts when internal states of a specific class are to be explained 5. Composite Structures when parts of a class and relationships between parts are to be modeled Object State Diagrams Diagrams Figure 2: Modeling Logical View 3 Process View (Process Decomposition) This view considers non-functional aspects such as performance, scalability and throughput. It addresses the issues of concurrency, distribution and fault tolerance. It shows the main abstractions from the Logical View executing over a thread as an operation. A process is a group of tasks that form an executable unit; a software system is partitioned into sets of tasks. Each task is a thread of control that executes with collaboration among different structural elements (from the Logical View). Process View also encompasses re-usable interaction patterns to solve recurring problems and to meet non-functional service levels. The process architecture can be represented at various levels of abstraction such as interactions between systems, subsystems and objects etc. based on the need. The Process view can be represented by the following UML 2 diagrams: 1. Sequence Diagrams: These diagrams show the sequence of messages passed between the objects on a vertical timeline. UML 2 has made significant improvements on Sequence diagram notations to aid Model Driven Development. The fragment types such as loop, assert, break and alt help in diagramming to the level of detail that keeps code and models in sync – not just in terms of structure, but also in behavior. Today’s modeling tools are yet to catch up on utilizing the power of UML 2 Sequence diagrams. 2. Communication Diagrams: These