Structural Modeling with UML 2 Jacques Robin Ontologies
Structural Modeling with UML 2 Jacques Robin Ontologies Reasoning Components Agents Simulations
Outline E E E UML 2 x UML 1 UML 2 meta-model package structure UML 2 Diagrams Classes Associations Objects and links Interfaces Ports and components Packages Templates Active classes, objects and parts
UML 2: What is new? E New purposes: E E Model-driven development Whole life-cycle component based development Real-time systems engineering Fully refined modeling with semi-formal notation (OCL) E New diagrams: E Component diagram E Composite structure diagram E Timing diagram E New design: ESeparates: E Abstract syntax, a MOF meta-model E Visual syntax, the Diagram Interchange (DI) standard E Semantics E Decomposes each part for reuse in a hierarchy of MOF packages linked by embedding and merge relationships
UML 2: New uses E UML 2 is so comprehensive that it can be used for new purposes not initially envisioned by OMG E Agent-oriented software engineering and intelligent system development E Engineering semantic web ontologies and services E Teaching course in any field through modeling and meta-modeling the presented concepts to visually and precisely structure them
UML 2: Internal Structure UML 2 Infrastructure Over 30 Sub-packages defining: • Classifiers (Classes, Interfaces, etc. ) • Types • Associations • Packages • Properties • Constraints UML 2 Superstructure merge Over 50 Sub-packages defining: • Components • Composite structures • Deployments merge • Common behaviors (Times, Durations, Events, Signals, etc. ) • Actions • Activities • Interactions • State machines • Use cases merge • Profiles • Templates MOF 2 merge EMOF CMOF OCL 2 6 Sub-packages defining: • Types • Expressions • Type value semantic domains • Expression evaluation semantic do mains • Type value semantic mapping • Expression value semantic mapping Diagram Interchange Defines diagrams’ visual layout
UML 2: Internal Structure UML 2 Superstructure Structure Behavior Classes Common. Behaviors Composite. Stuctures Activities Components Actions Interactions Supplement Deployments Profiles Auxiliary. Constructs State. Machines Use. Cases
UML 2 Diagrams Requirements Structur al Modelin g Behavio ral Modelin g Analysis Design Testing Class (OCL) Object Component (OCL) Class Object Composite structure Component Class (OCL) Object Component (OCL) Use-case Activity Protocol state machine Activity State machine EBehavioral EProtocol Interaction ESequence ECommunication EInteraction overview Timing Use-case Timing Deployme nt
Simplified MOF Meta-Model of itself Named. Element * Behaviorall. Feature Property Parameter Structural. Feature Operation Feature Type Classifier Typed. Element Value. Specification 1. . * Redefinable. Element Named. Element * * Instance. Specification. Constraint Classifier Generalization Relationship Interface Association * Data. Type Class Primitive. Type Enumeration * Association. Class * Relationship
Classes: Attributes E Common characteristics of the class members E Fields: E Base or derived (is. Derived) E Visibility (public, protected, private, package) E Name E Type (Primitive Built-In or Used -Defined Enumerations) E Initial default value E Properties: E is. Read. Only E Object attributes: different value for each object E Class attributes: same value for all objects E Attributes for MDA: as many fields as possible!
Classes: Operations E Common signature of services provided by the class members E Fields: E Visibility E Name E Return type E Properties: is. Query, is. Ordered, is. Unique E Input parameter E E E Direction Name Type Multiplicity Default value Properties E Object operations: called on objects E Class operations: called to manipulate class attributes E Operations for MDA: as many fields as possible!
Associations EAssociation: E Generic relation between N classifiers E Fields: E One or two Names E Navigation direction E Two Ends, each with: E One Multiplicity Range (default = 1) E Zero to One role E Zero to one Qualifier E Qualifier: needed to distinguish different instances of a one-tomany or many-to-many association E Navigation: E Role if present E Otherwise destination class name E Associations for MDA: as many fields as possible!
Association Classes E Class connected to an association and not to any of its ends E Allows associating properties and behaviors to an association E One object of the association class for each link of the connected association E A one-to-many or many-to-many association class cannot be substituted by a simple class and a pair of simple associations E Example: E Ca has objects A 1, A 2, A 3, A 4 E Cb has objects B 1, B 2, B 3, B 4 E Extent of association class Cc between Ca and Cb with * multiplicity at both ends has necessarily 16 instances E Class Cc associated to Ca through association Aca and to Cb through association Acb could have only 4 instances Difference with: ? 4 Elevator control Queue Elevator
N-ary Associations E Single association between N classes E Different from N-1 binary associations E Example: E E Ca has objects A 1, A 2 Cb has objects B 1, B 2 Cc has objects C 1, C 2 No link in the ternary association Ca-Cb-Cc corresponding to pair of links A 1 -B 1, B 2 -C 1
Aggregation Associations E Association with “part-whole” semantics E Associate composite class to its building blocks E Static, definitional characteristic of the “whole” class E In contrast to composite structure diagrams that model dynamic, configuration characteristic of the containing class E Shared aggregation: E Many-to-many aggregation
Composition Associations E Special case of one-to-one or one-to-many aggregation where part(s) cannot exist(s) without the unique whole E Deletion of the whole must therefore always be followed by automatic deletion of the parts
Class generalizations E Taxonomic relation between a class and one of its more general direct superclass E Special case of generalization between any two classifiers E Several generalizations form a taxonomic tree free of generalization cycles E Sub-classifier inherits the features from all its direct super-classifiers E Private attributes and operations not accessible from sub-classes E Protected attributes and operations accessible from sub-classes but not from associated classes E UML generalizations allow multiple inheritance and overriding E Instances of a sub-class must satisfy all the constraints on all its super-classes (principle of substituability)
Abstract Classes E Class that cannot be instantiated E Only purpose: factor gradual refinements of common and distinct structures and behaviors down a taxonomic hierarchy E Abstract operation: common signatures of distinct implementations specified in subclasses E Supports polymorphism: generic call signature to distinct operations, with automatic dispatch to the implementation appropriate to each specific call instance
Generalization Sets E Subclass set that can be labeled as: E complete or incomplete E overlapping or disjoint E Complete and disjoint generalization sets form a partition of the super-class E Sub-subclass can specialize members of two overlapping generalization sets
Power Types E Generalization set of a super-class defined in terms of a class associated to it E Subclasses of each power type inherits features from the associated class of the super-class that defines the power type E Allows separation of orthogonal concerns E Useful for MDA as a rich modeling element
Derived Attributes, Classes and Associations E Some class diagram elements can be entirely derived from other primitive ones E Derivation rules provided in { } near the derived element or as OCL constraint E Explicit derivable information key and rules for it are key for MDA
Constrained Associations E Properties and special graphical notation can express a limited set of constraints among associations E Other constraints expressed in OCL E Constraints key for MDA
Objects and Links E Object Diagram contains: E Specific (named) or generic (named after role, unnamed) instances of classes E Possibly several instances of the same class E Specific instances of associations (links) among objects E Possibly several instances of the same association E Illustrates specific instantiation patterns of associated class diagram
Interfaces E Classifier allowing to insulate classes, packages and components from one another for plug-and-play assembly and substitution E Concrete class: attributes + operation signatures + operation implementations + instantiation E Abstract class and Interface: attributes + operation signatures E But a concrete class realizes services specified in an interfaces, while it specializes the structure and behaviors whose signature they inherit from an abstract class E Other classifiers can use these services independently of how they are realized E Explicit, class-based notation more precise and thus preferred for MDA
UML 2. 0 Component Meta-Model * Packagable. Element Typed. Element Classifier Association Structural Feature part * Strcutured. Classifier Property * Connector. End Connector 2. . * Encapsulated. Classifier * Port Classifier Component provided * Interface required * * Connectable. Element
Ports E Feature of a classifier that links it to: E A provided interface which operations that the classifier realizes E A set of required interfaces to be provided by the deployment environment for the classifier to realize the provided interface E Fields: E E E Name Multiplicity Host classifier Provided interface Required interfaces
Composite Structures: Examples E Express dynamic, run-time whole-part relationships E Same class can be part of multiple wholes in multiple configurations E Different from unique, static composition aggregation
Packages E Group of elements creating a namespace E A pure design-time entity, that might not be reflected at run-time E Model element can only belong to a single package and is deleted whenever its package is deleted E Relations between packages: E Generalization E Dependencies: nesting (sub-package), import, access (private import) and merge
Packages
Package Merge E Integrate elements of two packages into a resulting “merged” package, collapsing common elements into a single one E Redundancy-free cut and paste
Templates E Partially specified class, refined by instantiation of parameters E Alternative way to define derived class E Key for parametric patterns
Active Classes, Objects and Parts E Active classes are associated to a thread E Active objects have proactive behavior, executing an operation not invoked by any other object E Active objects execute concurrently E Active classes/objects can be composite structures, containing both active and passive classes/objects as parts E What is an agent? E An active object that is also a component instance!
- Slides: 31