350 likes | 525 Views
Specializing and extending the UML. Extending the UML. Stereotype Profiles (Specializing) Constraint Tagged value. Stereotypes.
E N D
Extending the UML • Stereotype • Profiles (Specializing) • Constraint • Tagged value
Stereotypes • A class that defines how an existing metaclass (or other stereotype) may be extended, and enables the use of platform or domain specific terminology or notation in addition to the ones used for the extended metaclass. Certain stereotypes are predefined in the UML, others may be user defined.
Stereotypes • Stereotypes are one of the extensibility mechanisms in UML. Example <<include>><<extend>> distinguish dependencies in use case diagrams. A stereotype may be associated with a Class or Association (or other model element) in the definition of a profile. The main aspects in which a stereotype can modify the metaclass definition are:
Stereotypes • 1) Presentation such as, first character of stereotype in lower case in front of elements name enclosed in guillmets; icon or display • 2) Additional properties for classes and attributes. The most important properties for an attribute (in addition to the name) are Type, Default Value, Multiplicity, and Unique.
Stereotypes • 2) Additional constraints: In a profile only stereotypes can own constraints. The constraint can be named. In the CASE tool Rational Rose the constraints can be written in Java or OCL syntax. • 3) Stereotypes can specialize or generalize other stereotypes.
Stereotypes • Stereotypes can be text or a graphic icon • The icon can replace the normal class box
What is a UML profile? • A UML Profile is a predefined set of Stereotypes, Tagged Values, Constraints, and notation icons that collectively specialize and tailor the UML for a specific domain or process (e.g. Unified Process profile). A profile does not extend UML by adding any new basic concepts. Instead, it provides conventions for applying and specializing standard UML to a particular environment or domain.
What is a UML profile? • The UML profile was designed to structure and group together standard (extension) specialization to the UML model. The UML profile is at the heart of a strategic plan to formalize and handle the application development process using UML. This is called the Model Driven Architecture (MDA). • A UML package is analogous to a folder used to organize a large diagram into several smaller ones. Packages are used to construct profiles.
What is a UML profile? • The purpose of a UML profile is to allow the construction and interchange of UML models that require semantic specifications that express semantic detail beyond what can be expressed with standard UML.
What is a UML profile? • Specializing UML for technology implementations (“language mappings”) Every technical target, such as programming language, or middleware or library or database is a natural candidate for defining a dedicated UML profile. • UML profile for CORBA • UML profile for EJB (Enterprise Java Beans) • UML profiles for C++, or for Java, • UML profiles for specific RDB such as “ORACLE”. • UML for GIS see hand out and http://www.isima.fr/~kang/pinet/kang.pdf
What is a UML profile? • Specializing UML for specific application domains : • Domain specialists in e.g. the finance or manufacturing domains have to use profiles cautiously. Very often, application domains only require predefined model libraries or template libraries. Using profiles in this context might be overkill. • However, there are some needs for specializing UML which originate in “horizontal” application domains. For example, geographic applications need to express a specific way of defining geographic constraints between elements, that do not exist in other development areas.
Part of a GIS profile from Kang et al. http://www.isima.fr/~kang/pinet/kang.pdf
UML Extensions • UML has the following extension mechanisms. • Stereotypes • Tagged Values • Constraint • A stereotype defines how an existing metaclass may be extended, and enables the use of platform or domain specific terminology or notation in place of or in addition to the ones used for the extended metaclass.
What is a UML profile? • Profiles generically extend the UML through the use of stereotypes that are most often language-specific, provide a common graphical notation and vocabulary, and define a subset of the UML metamodel (MOF).
What is a UML profile? • Profiles available in CASE tools such a Poseidon, ArgoUML, Rational Rose.
What is a UML profile? • A profile is an extension to the core UML that keeps the UML metamodel intact, in other word it obeys the rules of UML. A UML profile is a subset of UML that is necessary and sufficient for a given development effort (e.g. Testing, WAP, or GIS). For example, UML Testing Profile defines a language for designing, visualizing, specifying, analyzing, constructing and documenting the artifacts of test systems. UML profiles are defined in the UML infrastructure volume of UML 2.0. Profiles are packages that are linked to other packages in a model by using the <<apply>> dependency. Model elements in the model package can then use the features that are in the profile, typically stereotypes.
UML example GIS profile • The following is part of a description of a car sharing system: • Each member of the car sharing pool has an address that consists of neighborhood and a region. It is required to construct a class for the car sharer, the address, the neighborhood, and the region. • In order to handle location information it has been decided to attach a Geographical Information System (GIS) system to the car sharing system. The GIS has been modeled as a UML profile called GIS. • The UML profile mechanism was used to construct the profile in the next slide. This profile extends Class with Point and Region stereotypes. It also extends the UML association with an association stereotype called LocatedIn which associates Point with Region.
UML example GIS profile The UML profile mechanism was used to construct the profile above. This profile extends Class with Point and Region stereotypes. It also extends the UML association with an association stereotype called LocatedIn which associates Point with Region. Draw a UML diagram that applies the GIS profile to the car sharing package.
Profile WML Example • The Wireless Markup Language (WML) is used to describe content for wireless applications. The Wireless Access Protocol (WAP) is a standard used to deliver Internet content to wireless devices such as mobile phones and Personal Digital Assistants (PDAs). WML uses the metaphor of decks of cards. Assume that a WAP/WML application consists of a single deck. Each deck contains a number of cards; each card displays a screen-full of information on a mobile device. When cards from a deck are transferred to a mobile device, the user can move between cards using a simple next and previous command. The UML profile on the next slide represents WAP/WML functionality.
Part of UML’s core MOF Part of the application domain
Profile WML Example • We will describe the roles of the stereotypes used in the WAP package tab, the Application class, and in the Next association. We will also describe the relevant UML extension mechanism.
Profile WML Example • The <<profile>> stereotype in the package tab indicates that the package is a profile and package name is WAP. • Black arrows indicate that a new class extends the UML metaclasses Class and Association. We do not describe details of higher order UML or MOF. • The figure indicates the following stereotypes for classes have been created <<application>>, <<deck>> , <<card>> and the following stereotypes for association have been created <<delivers>> , <<next>> , <<previous>> .
Profile WML Example • The next slide shows part of a car sharing system. The semantics of the diagram are as follows. The CarMatchDatabase class represents the complete car sharing database. The CarMatchInformation represents a result set from a database query. Each result set consists of one or more CarMatch objects representing actual car sharing records. CarMatch objects are linked together with two associations called previous and next.
Profile WML Example • We will draw a diagram showing the application of the WAP profile to the CarSharer package using the following mappings.
Profile WML Example • Description: Each new stereotype in the WAP profile is applied as appropriate to each class or association in the CarSharer package, as per mapping. The <<apply>> dependency is used to indicate the application of the profile to the package.
Profile Example • The extension mechanism extends the metaclass definition of one or more metaclasses Class and Accociation (the original metaclass definitions are still available for normal use). Then when the profile is applied new classes with the new stereotype have the newly defined features. Hence, the CarMatch class has whatever was defined in Card. The stereotypes Application, Deck, and Card are all extensions of the metaclass Class. The stereotypes Delivers, Next and Previous are all extensions to the metaclass Association. The application allows the UML user to avail of previously defined specifications (usually domain specific).
Constraints • Constraints are a semantic condition or restriction. They are standard UML feature. They can be expressed in natural language text, mathematically (FOPL + SETS) formal notation, or in a machine-readable language e.g. OCL for the purpose of declaring some of the semantics of a model element. They are used in combination with tagged definitions to define the characteristic of stereotypes in profiles. A constraint defines a relationship between model elements that must be true {subset}{xor} (multiplicity not enough for xor). Constraints can be on attributes, derived attributes, associations and classes.
Tagged values • Many stereotyped model elements have properties that cannot be represented graphically. These can defined in the profile as tagged definitions and are shown in the model as tagged values. Tagged values consist of a tag or name and an associated value (e.g. {CoordSystem = LatLong} or Boolean tagged value {abstract}{isPropertyName}). Tagged definitions are the attributes of the stereotypes in the profile and are typically shown in comments attached to the stereotyped model elements.
Tagged values • Persistence is shown using a tagged value
Constraints as a tagged Boolean assertion • This constraints is represented as a togged Boolean assertions attached to a model element. • they are attached to one or more model element • this shows a note containing a class constraint