Appendix A: Quick Reference to Object- Oriented Design (OOD) and the Unified Modeling Language (UML)
Total Page:16
File Type:pdf, Size:1020Kb
Appendix A: Quick Reference to Object- Oriented Design (OOD) and the Unified Modeling Language (UML) General Fundamental Concepts of Object Orientation • Abstraction—capture the essential, shared characteristics of an entity or group of entities. • Hierarchy—rank or order abstractions to capture common and unique features among entities. • Modularity—decompose complexity to enable understanding; localize effects of changes. • Generalization/Inheritance—define elements such as Classes whose characteristics apply to multiple more specialized elements; child elements inherit the characteristics of the parent. • Encapsulation—conceal information that does not need to be exposed to an outside entity; bundle-related information and functionality within an entity. • Interfaces—clearly define interactions among entities and with the external envi- ronment; allow entities to interact by exchanging messages or other information across controlled boundaries. • Polymorphism—hide details of implementation behind an interface; allow the same service invocation to yield different results depending on circumstances (e.g., the data type of a passed parameter). © Springer International Publishing AG, part of Springer Nature 2019 533 J. M. Borky, T. H. Bradley, Effective Model-Based Systems Engineering, https://doi.org/10.1007/978-3-319-95669-5 534 Appendix A: Quick Reference to Object-Oriented Design (OOD)… Dealing with Complexity Using OOD • Abstraction focuses on the most important aspects of complex entities (Objects) and identifies common or shared characteristics; objects correspond to real-world entities that have defined “state” and “behavior” (data and functions or operations). • OOD facilitates decomposition of complex entities into simpler ones that can be more readily specified, implemented, tested, and used. • Interface definition is inherent and natural; captures real-world interactions of a system. • Polymorphism allows tailored functionality with common interfaces. • Facilitates open, loosely coupled, service-oriented, and component-based (“plug and play”) architectures. • Encapsulation facilitates localization and confinement of the effects of design changes or system failures. • Inheritance minimizes the difficulty of handling variations among related infor- mation and actors. • OOD facilitates understanding of system states and transitions via the attributes and associations of objects. UML Basics Classes and Objects • An Object is a basic entity of a system, providing an identifying label and encap- sulating the information and operations associated with that entity; it is the phys- ical entity that can hold information, perform functions, and provide services to other Objects or external entities. • An Object is the instantiation of a Class; the Class is the primary type of “classi- fier” that abstracts the shared characteristics of its Objects. • An Association between Classes represents the ability to exchange messages and to request and deliver services; a Link is a semantic relationship between Objects and the instantiation of an Association. • Class and Object Diagrams capture the identity and interactions of Classes and Objects. UML Metamodel • Type specifies a domain of values and a set of operations on those values. • Class implements a Type by representing the Attributes and implementing the Operations. • Type Class includes as subclasses: –– Primitive Type—not implemented by a Class (e.g., integers, strings) –– Class—implements the Type –– Use Case—sequence of actions performed by a system and actors Appendix A: Quick Reference to Object-Oriented Design (OOD)… 535 • Class comprises as subclasses: –– Active Class—anchors one or more execution flows; a Task Diagram is a Class Diagram showing only active Classes, used to describe multitasking. –– Signal—named event. –– Component—reusable element containing physical constituents of model elements. –– Node—physical device on which artifacts are deployed to execute. Fig. A.1 UML Type/Class Metamodel, defining the Model Element dichotomy Basic Constructs of the Language Instance of > Instance Type 0..* 0..1 Definition Domain Type/Instance Operations Implements dichotomy 1 Method Class 0..* UML Common Elements Instance of 1 0..* * Class Clas Object Object 1..* s* 1..* * * 1 Links Links 1 * * Association Link Instance of Association Link * * * * * * * * Class Diagram * Object Diagram Class Diagram Object Diagram 1 0..1 Contains or references model elements Package Model Abstraction of the system 0..1 0..* Includes References 0..* 0..* Abstraction of Text or an element of Element graphical the modeled projection system Model Element Visual Element 1..* 0..* Projection Fig. A.2 UML Common Elements 536 Appendix A: Quick Reference to Object-Oriented Design (OOD)… UML Structural Metamodel Association Classifier DataType 0..1 1..* Behavior StateMachine BehavioredClassifier * 0..1 * * 0..1 Activity Action 0..1 0..* UseCase Collaboration Structured Classifier * 0..1 0..1 * * Feature BehavioralFeature Implementation Interface * * * 0..1 0..1 Encapsulated * Classifier 0..1 0..1 Attribute * * Class Connector StructuralFeature Operation * 0..1 1 2..* * Part Component ConnectorEnd * provided Port * required Artifact Node Subsystem source Deployment Fig. A.3 UML Structural Metamodel UML Diagrams UML consists of Structural and Behavioral specifications: • Structural Diagrams—model the static aspects of a system or enterprise. • Behavioral Diagrams—model the dynamic aspects, how the structural aspects change over time. Supplementary Diagrams and Artifacts* Artifacts not defined in the UML standard are often very useful in communicating key aspects of architecture and design; examples include: Appendix A: Quick Reference to Object-Oriented Design (OOD)… 537 Class Diagram Component Diagram Composite Structure Structure Diagram Diagram Deployment Diagram Object Diagram Package Diagram Diagram Activity Diagram Sequence Diagram Use Case Communication Diagram Diagram Behavior Diagram State Interaction Machine Overview Diagram Diagram Interaction Timing Diagram Diagram Fig. A.4 UML Diagrams • Hardware Block Diagrams—the conventional way to show hardware items and interconnects • Entity-Relation Diagrams—used to show data relationships that may not be obvious in Class Diagrams. • Decision Tables—used to show concisely complicated logical conditions and decision alternatives. • Tabular Data and Taxonomies—used to identify, define, and describe activities, services, information exchanges, interfaces, performance parameters, procedures, rules, and many other details; a common example is a Data Dictionary. *NOTE: This does not refer to the UML Artifact model element that represents a physical element of a system. 538 Appendix A: Quick Reference to Object-Oriented Design (OOD)… Structural Diagram Elements Package Diagrams Class and Object Diagrams <<interface>> Class Table Object Interface Package Package Association Composite Structure Diagrams Component Diagrams <<interface>> Class Class Interface Object Part Component Port Class Collaboration Collaboration Instance Package Deployment Diagrams <<artifact>> <<deployment spec>> Node Artifact DeploymentSpecification Component Interface Fig. A.5 UML Structural Elements UML Common Mechanisms • Keyword—a predefined term used to categorize or describe a model element; notated as <<import>> or {abstract} depending on the term (generalizes and replaces the Stereotype construct from UML 1, but Stereotype is still fre- quently used as the generic term). • Stereotype—a class, usually associated with a profile, that extends another class or stereotype and can have properties whose values become tagged values of the element to which the stereotype is applied; notated as <<stereotype>>. • Tagged Value—an extension of a UML element that allows creation of new infor- mation in the element’s specification; a (name, value) pair that describes a prop- erty of a model element. • Note—a comment attached to one or more model elements; a stereotyped Note can be a Constraint. • Constraint—any kind of semantic relationship between model elements; may be expressed in a formal language such as the Object Constraint Language (OCL); extends the semantics of an element to add or modify rules; semantics are: <constraint> ::= ‘{‘ [ <name> ‘:’ ] <Boolean-expression> ‘ }’ • Dependency—defines a unidirectional use relationship between model elements, referred to as source and target, client and server, etc.; a change to the dependent element may affect the semantics of the independent element. • Type/Instance and Type/Class Dichotomies—the split between the essence or speci- fication of an element (Type) and its realization/implementation (Instance or Class); Appendix A: Quick Reference to Object-Oriented Design (OOD)… 539 a Type is a stereotype of a Class that specifies a domain of objects with their Operations (but not Methods); Data types do not have Stereotypes, Tagged Values, or Constraints. • Responsibility—a concise statement of what a model element, usually a class, must do for the system to function as designed; can be shown as comments on a Class Diagram, documented in a Class Specification, etc. • Realization—the source implements/realizes the destination; shows traceability. Behavioral Diagram Elements Use Case Diagrams Activity Diagrams Sub-Activity Use Case Collaboration Activity Actor Actor Complex set Pointer to Child of behaviors Activity Diagram BoundaryPackage Action Object Atomic unit Partition of Activity <<datastore>> Send State Machine Diagrams