480 likes | 840 Views
5. Advanced Structural Modeling. Interfaces, Types, and Roles. Overview. Interfaces, types, roles, and realization Modeling the seams in a system Making interfaces understandable and approachable. Terms & Concepts.
E N D
5. Advanced Structural Modeling Interfaces, Types, and Roles
Overview • Interfaces, types, roles, and realization • Modeling the seams in a system • Making interfaces understandable and approachable CS6359 Chapter 11
Terms & Concepts • Interface: a collection of operations that are used to specify a service of a class or a component • Type: a stereotype of a class used to specify a domain of objects, together with the operations applicable to the object • Role: the behavior of an entity participating in a particular context. CS6359 Chapter 11
Interfaces ISpell IThesaurus interfaces wordsmith.dll IUnknown component CS6359 Chapter 11
Interfaces • Name: simple names, path names • Operations: unlike classes, interfaces do not specify any structure (no attributes), nor do they specify any implementation (no methods, which provide the implementation of operations). • Relationships: like a class, an interface may participate in generalization, association, and dependency relationships. CS6359 Chapter 11
Interface vs. Abstract Class • An abstract class may have attributes, but an interface may not. • Interfaces span model boundaries. The same interface may be realized by both a class (a logical abstraction) and a component (a physical abstraction that provides a manifestation of the class). CS6359 Chapter 11
Modeling the Seams in a System • Group those that tend to be tightly coupled relative to other sets of classes and components. • Refine your grouping by considering the impact of change • Package logically related sets of cross-boundary operations and signals as interfaces CS6359 Chapter 11
Hints and Tips • A well-structured interface: • Is simple yet complete. Providing all the operations necessary yet sufficient to specify a single service. • Is understandable, providing sufficient information. • Is approachable, providing information to guide the user to its key properties without being overwhelmed by the details of a pile of operations. CS6359 Chapter 11
Summary • Interfaces, types, & roles • Interface vs. Abstract Class • Modeling the Seams of a System • Well-Structured Interface CS6359 Chapter 11
5. Advanced Structural Modeling Packages
Overview • Packages • Visibility • Importing • Exporting • Standard Elements • Modeling groups of elements CS6359 Chapter 12
Packages • Package—general-purpose mechanism for organizing elements into groups. • Names • Simple name—textual string distinguishing one package from others. • Path name—simple name prefixed by any enclosing package. CS6359 Chapter 12
Packages Depicted simple names Client + OrderForm + TrackingForm Business rules - Order extended packages enclosing package name package name path names Sensors::Vision { version = 2.24 } CS6359 Chapter 12
Client + OrderForm + TrackingForm - Order Owned Elements • Composite relationship • Destroyed if enclosing package is destroyed graphical nesting visibility Client +OrderForm -Order textual nesting +TrackingForm CS6359 Chapter 12
Visibility • You can control the visibility of the elements owned by a package just as you can control the visibility of the attributes and operations owned by a class. • Packages that are friends to another may see all the elements of that package, no matter what their visibility. • If an element is visible within a package, it is visible within all packages nested inside the package. CS6359 Chapter 12
Importing & Exporting • Importing • Grants a one-way permission for elements in one package to access the elements in another package. • Dependency with stereotype <<import>> • Exporting • Public parts of a package. CS6359 Chapter 12
Importing & Exporting Depicted CS6359 Chapter 12
Standard Elements • facade—only a view on some other package. • framework—package consisting mainly of patterns. • stub—a package that serves as a proxy for the public contents of another package. • subsystem—a package representing an independent part of the system being modeled. • system—a package representing the entire system being modeled. CS6359 Chapter 12
Modeling Groups of Elements (steps) • Look for “clumps” of elements that are semantically close to one another. • Surround “clumps” with a package. • Identify public elements of each package. • Identify import dependencies. CS6359 Chapter 12
Summary • Packages • Owned Elements • Visibility • Importing & exporting • Standard package elements • Modeling groups of elements CS6359 Chapter 12
5. Advanced Structural Modeling Instances, Object Diagrams
Overview • Instances and Objects • Modeling Concrete Instances • Modeling Prototypical Instances • Modeling Object Structures • Forward and Reverse Engineering CS6359 Chapter 12
Instances • The terms “instance” and “object” are largely synonymous; for most part, they may be used interchangeably. • Use instances to model concrete or prototypical things that live in the real world. • Transient: specifies that an instance is created during execution of the enclosing interaction but is destroyed before completion of execution (a standard constraint that applied to objects). CS6359 Chapter 12
Abstractions & Instances • Instances don’t stand alone: they are almost always tied to an abstraction. • Instances of: • Classes (objects) • Components, nodes, use cases, and associations • To indicate an instance, you underline its name. CS6359 Chapter 12
myCustomer id : SSN = “432-89-1738” active = True agent : Other Concepts anonymous instance named instance myCustomer : Multimedia :: AudioStream t : Transaction : keyCode c : Phone [WaitingForAnswer] orphan instance multiobject instance with attribute values r : FrameRenderThread active object instance with explicit state CS6359 Chapter 12
Modeling Concrete Instances (steps) • Identify the instances necessary and sufficient to model the system. • Render these objects in the UML as instances; give meaningful names if possible or render it as an anonymous object. • Expose the stereotypes, tagged values, and attributes. • Show these instances and their relationships in an object diagram. CS6359 Chapter 12
Modeling Prototypical Instances (steps) • Identify those prototypical instances necessary and sufficient to model the system. • Render these objects in the UML as instances; give meaningful names if possible or render it as an anonymous object. • Expose the properties of each instance. • Show these instances and their relationships in an interaction diagram or an activity diagram. CS6359 Chapter 12
Object Diagrams • Object diagrams model the instances of things contained in class diagrams. • Shows a set of objects and their relationships at a point in time. • Used to model the static design view or static process view of a system. • Shows a snapshot of the system at a moment in time and rendering a set of objects, their state, and their relationships. CS6359 Chapter 12
d1 : Department name = “Sales” d2 : Department name = “R&D” d3 : Department name = “US Sales” : ContactInfomation address = “1472 Miller St.” p : Person name = “Erin” employeeID = 4362 title = “VP of Sales” An Object Diagram c : Company link attribute value object anonymous object manager CS6359 Chapter 12
Modeling Object Structures (steps) • Identify the mechanism. • For each mechanism, identify classes, interfaces, and other elements that participate in this collaboration; identify the relationships among these things. • Consider one scenario that walks through this mechanism. Freeze that scenario at a moment in time and render each object that participate in the mechanism. • Expose the state and attribute values of each object. • Expose the links among these objects CS6359 Chapter 12
Forward & Reverse Engineering • Forward engineering an object diagram: possible but limited value. • Reverse engineering an object diagram: very useful in debugging process. • Choose the target and walk through a scenario • Identify the set of objects that collaborate in that context. • Expose these object’s states attribute values and links among these objects. CS6359 Chapter 12
Summary • Instances • Abstractions & Instances • Modeling Concrete Instances • Modeling Prototypical Instances • Object Diagram • Modeling Object Structures • Forward and Reverse Engineering CS6359 Chapter 12