CHAPTER 4 Topic: Static View After reading this Chapter, students should appreciate the following: Understand the class, object and data types. Understand the concepts of generalization, inheritance and multiple inheritances. Discuss the Realization, dependencies and constraints Instructor Notes This chapter discusses in detail the static view and the components of static view. The static view captures the object structure i.e. traditional data structure as well as the organization of the operations of data. The static view describes behavioral entities as discrete modeling elements but does not contain the details of a dynamic behavior. The key elements in static view are classifiers and relationships. Classifiers: A classifier is a discrete concept in the model, having identity, state, behavior and relationships. Different types of classifiers are classes, interfaces, and data types. Please refer to Table 4.1 on page 43 to learn about different types of classifiers and their functions. Class: A class represents a discrete concept within the application modeled – a physical thing, a business thing, a logical thing, an application thing , a computer thing or a behavioral thing. A class is the descriptor for a set of objects with similar structure, behavior and relationships. All attributes and operations are attached to classes or other classifiers. Interface: An interface is the description of behavior of objects without giving their implementation or state; an interface contains operations but no attributes. Data Type: A data type is the description of primitive values that lack identity. Data type includes numbers, strings and enumerated values. Relationships Relationships among classifiers are association, generalization, flow and various kind of dependency including realization and usage. (refer to table 4.2 on page 46) Associations: An association describes discrete connections among objects or other instances in a system. - An association relates an ordered list of two or more classifiers, with repitiions permitted. - The most common kind of association is a binary association between a pair of classifiers. - An instance of an association is a link. - A link comprises a tuple of objects, each drawn from its corresponding class. - A binary link comprises a pair of objects. - Associations carry information about relationships among objects in a system. - Without associations there are nothing but isolated classes that do not work together. - Each connection of an association to a class is called an association end. - The most important property os association end is multiplicity i.e. how many instances of one class can be related to one instance of the other class. - Multiplicity is most useful for binary associations because its definition for nary associations is complicated. - - An association can also have attributes of its own, in which case it is both an association and a class – an association class. Aggregation and composition o An aggregation is an association that represents a part-whole relationship. o A composition is a stronger form of association in which the composite has sole responsibility for managing its parts – such as their allocation and deallocation. Links o An instance of an association is a link. o A link is an ordered list of object references, each of which must be an instance of the corresponding class in the association or an instance of a descendant of a class. Bidirectionality The different ends of an association are distinguishable, even if two of them involve the same class. - An association is sometimes said to be bi-directional i.e. logical relationships work both ways. Generalization - - The generalization relationship is a taxonomical relationship between a more general description and a more specific description that builds on it and extends it. Generalization has two purposes o To define the condition under which an instance of one class can be used when a variable is declared as holding values of a given class. This is called substitutability principle Generalization enables polymorphic operations i.e. operations whose implementation is determined by the class of object they are applied to rather than explicitly stated by the caller. o To permit the incremental description of an element by sharing the descriptions of its ancestors. This is called inheritance. Inheritance Inheritance is the mechanism by which a description of the objects of a class is assembled out of declaration fragments from the class and its ancestors. Inheritance permits shared parts of the description to be declared once and shared by many classes, rather than be repeated in class. Multiple Inheritance: If a classifier has more than one parent, it inherits from each one. Its features are union of both parents. Static and Dynamic Classification - When multiple classifications are combined with dynamic classification an object can gain and lose classes during its life. - The dynamic classes are called roles or types. - The requirement is that there should be a single static inherent class plus zero or more role classes that may be added or removed over the lifetime of the object. Realization - The realization relationship connects a model element, such as a class to another model element such as an interface, that supplies its behavioral specification but not its structure or implementation. - Realization can be used with specification elements such as interfaces as well as with concrete implementation element. Both generalization and realization relate a more general description to more detailed versions of it. Dependencies - A dependency indicates a semantic relationship between teo or more model elements. - It relates the model elements themselves and does not require a set of instances for its meaning. - It indicates a situation in which a change to the supplier element may require a change to or indicate a change in meaning of the client element in dependency. (Please refer to table 4.3 on page 57 for knowledge of all dependencies) Constraint - A constraint is a Boolean expression represented as a string to be interpreted in a designated language. - Natural language, set theoretic notation, constraint languages or various programming languages may be used to express constraints. - The UML includes the language of constraints called OCL. - Constraints can be used to state various nonlocal relationships, such as restrictions on paths of associations etc. Instances - An instance is a run-time entity with identity i.e. something hat can be distinguished from other run-time entities. - It has a value at any moment of time.