1 / 115

UNIT-III

UNIT-III. Class Diagram and Composite Structure Diagram (08 Hrs, 16 Marks) Object Diagram: a. Terms and Concepts: Common Properties, Contents, Common Uses b. Common Modeling Techniques: Modeling Object Structures Class Diagram: c. Classes, Attributes, Operations, Abstract Classes

alexis
Download Presentation

UNIT-III

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UNIT-III

  2. Class Diagram and Composite Structure Diagram (08 Hrs, 16 Marks) Object Diagram: a. Terms and Concepts: Common Properties, Contents, Common Uses b. Common Modeling Techniques: Modeling Object Structures Class Diagram: c. Classes, Attributes, Operations, Abstract Classes d. Relationships: Dependency, Association, Aggregation, Composition, Generalization, Association Classes, Association Qualifiers e. Advanced Relationships: Stereotypes on Dependency, Stereotypes and Constraints on Generalization, Constraints on Association, Realization f. Interfaces g. Templates h. Class Diagram: Common Properties, Contents, Common Uses i. Common Modeling Techniques : Modeling Simple Collaborations, Modeling a Logical Database Schema j. Forward and Reverse Engineering Composite Structures Diagram: k. Connectors, Ports, Structured classes and Properties

  3. OBJECT DIAGRAM • Object diag. is a diagram that shows a set of object & their relationships at a point in time • Graphically it is a collection of vertices & edges • It’s a structural model & construct static aspect of system through forward & reverse engineering • template for describing how a particular set of objects relate to each other Instance diagram describes object instances

  4. Properties of object diagram • Show set of objects & their relationships • Content of object diagram • Object diagram contain • Object • Links • It may also contain notes & constraint ,package or subsystem • Use of object diagram :- • Model static view • Support functional requirement of system i.e. service system should provide to end user • Model object structure

  5. Identify mechanism like to model • Identify classes ,interfaces • Expose state & attribute value of each object as necessary to understand scenario • Expose link among objects representing instance of association • object interaction • Interaction is a behavior that comprises a set of message exchanged among object • Interaction model dynamic aspect of collaboration • 2 –way of interaction • Emphasizing it’s time ordering of messages • Emphasizing it’s sequence of message

  6. Link: • A link is a physical or conceptual (semantic) connection between object instances. • Messages : • It is a specification of communication among objects that convey information with expectation that activity will ensure • Model actions like:- • Call – invoke operation on an object 3. send • return:- return value to caller 4. create 5. destroy

  7. sequencing :- - Sequence is formed by stream of messages

  8. Advanced structural modeling • Instances:- • It is concrete manifestation of abstraction to which set of operation may be applied & have state to store effect of operation • Abstraction & instances:- • Instances are always tied to abstraction • Names:- • every instance must have name that distinguish from other • Name is a textual string

  9. Standard element: • Standard stereotype that apply to dependency relationship among object & classes • instanceof: • specifies that client object is an instance of the specifier classifier 2. Instantiate : • specifies that client class create instanceof supplier class • 2 –stereotype relate to object that apply to message & transitions • become: - specifies that same object as the supplier but at later time & with possibly different value ,state & rules 2. Copy : - specifies that client object is an exact but independent copy of supplier

  10. ACTIVE OBJECT • They are part of process or thread & represent root of flow of control • We can declare instance of active objects as • active objects is an object that own process / thread & can initiate control activity • Denoted as rectangle with thick lines

  11. When u draw active class or object in UML • Show only those attribute,opeartion & signal that are important in understanding that abstraction in context • Explicitly show all operation synchronization properties

  12. Class diagrams • Class is an abstraction of system that are part of your vocabulary • Attributes and operations are specified for classes.

  13. Class :- • A class describes a group of objects with similar properties (attributes), common behavior(operations), common relationships to other objects, and common semantics • Attributes and operations are specified for classes. • Class membership can be defined in two ways: implicitly by rule or explicitly • A class can have class attributes and class operations • Attribute: - An attribute is (represents) a data value which is held by the objects in a class. An attribute should be a pure data value, not an object.

  14. Operation & methods:- • An operation is a function or transformation that may be applied to or by objects in a class. The same operation may be defined for several different classes. • Ex: open,close,hide operation on window • Same operation may apply to different classes ,it is known as polymorphic • An operation is the implementation of a service that can be requested from any object of the class to affect behavior • Graphically, operations are listed in a compartment just below the class attributes. Operations may be drawn showing only their names

  15. - Method: A method is the implementation of an operation for a class. The choice of which method is invoked it solely determined by the target object. • Link & association :- - A link is a physical or conceptual connection between object instances. Links are order tuples Ex:- john works for a company • An association describes a group of links with common structure and common semantics. • Attributes and operations can be specified for associations. Basically, this allows one to treat an association as a class • Associations can have role names associated each class connection. • links in an association can be ordered

  16. Association Relationships If two classes in a model need to communicate with each other, there must be link between them. An association denotes that link. Student Instructor Software Design (UML)

  17. Association Relationships (Cont’d) We can indicate the multiplicity of an association by adding multiplicity adornments to the line denoting the association. The example indicates that a Student has one or more Instructors: Student Instructor 1..* Software Design (UML)

  18. Association Relationships (Cont’d) The example indicates that every Instructor has one or more Students: Student Instructor 1..* Software Design (UML)

  19. Association Relationships (Cont’d) We can also indicate the behavior of an object in an association (i.e., the role of an object) using rolenames. teaches learns from Student Instructor 1..* 1..* Software Design (UML)

  20. Association Relationships (Cont’d) We can also name the association. membership Student Team 1..* 1..* Software Design (UML)

  21. Association Relationships (Cont’d) We can specify dual associations. member of Student Team 1..* 1..* 1 president of 1..* Software Design (UML)

  22. Association Relationships (Cont’d) We can constrain the association relationship by defining the navigability of the association. Here, a Router object requests services from a DNS object by sending messages to (invoking the operations of) the server. The direction of the association indicates that the server has no knowledge of the Router. Router DomainNameServer Software Design (UML)

  23. Registration modelNumber serialNumber warrentyCode Product Warranty Association Relationships (Cont’d) Associations can also be objects themselves, called linkclasses or an association classes. Software Design (UML)

  24. next LinkedListNode previous Association Relationships (Cont’d) A class can have a self association. Software Design (UML)

  25. Car Engine Transmission Association Relationships (Cont’d) We can model objects that contain other objects by way of special associations called aggregations and compositions. An aggregation specifies a whole-part relationship between an aggregate (a whole) and a constituent part, where the part can exist independently from the aggregate. Aggregations are denoted by a hollow-diamond adornment on the association. Software Design (UML)

  26. Scrollbar Titlebar Menu Association Relationships (Cont’d) A composition indicates a strong ownership and coincident lifetime of parts by the whole (i.e., they live and die as a whole). Compositions are denoted by a filled-diamond adornment on the association. Window 1 1 1 1 1 1 .. * Software Design (UML)

  27. Dependency Relationships A dependency indicates a semantic relationship between two or more elements. The dependency from CourseSchedule to Course exists because Course is used in both the add and remove operations of CourseSchedule. CourseSchedule Course add(c : Course) remove(c : Course) Software Design (UML)

  28. Instance • An instance represents a phenomenon. • The name of an instance is underlined and can contain the class of the instance. • The attributes are represented with their values.

  29. Multiplicity:- • Multiplicity specifies how many instances of one class may relate to a single instance of an associated class • Multiplicity constraints can only be used with binary associations. Candidate keys have to be used in n-ary relationships. -"how many" is called the multiplicity of an association's role, and is written as an expression that evaluates to a range of values or an explicit value -You can show a multiplicity of exactly one (1), zero or one (0..1), many (0..*), or one or more (1..*). You can even state an exact number (for example, 3).

  30. Link attribute:- • It is a property of link in an association Ex:- access permission is an attribute of accessible by . - Symbol is box attached to association link by loop • accessible by • Role name:- - A role names is a behavior of an entity participating in a particular context. file user

  31. Ordering:- • Ordering is an inherent part of association • Ordered set of object on the “many” end of association is indicated by writing {ordered} next to multiplicity dot for the role • it’s a special type of constraint • Qualification:- • It is an association attribute whose values partition the set of objects related to an object across an association. • We denote a qualifier as a small rectangle attached to the end of an association, placing the attributes in the rectangle, as the figure shows

  32. Aggregation • An aggregation is special type of association that represents a "part-of" relationship. Aggregations are transitivity and anti-symmetric • An aggregation is a special case of association denoting a “consists of” hierarchy. • The aggregate is the parent class, the components are the children class. • We want to model a "whole/part" relationship, in which one class represents a larger thing (the "whole"), which consists of smaller things (the "parts"). This kind of relationship is called aggregation, which represents a "has-a" relationship • an object of the whole has objects of the part.

  33. A line joins a whole to a component, with an open diamond on the line near the whole. • GENERALIZATION & INHERITANCE • A generalization is a relationship between a class and one or more refined versions of that class. • generalization is a specialization/generalization relationship in which objects of the specialized element (the child) are substitutable for objects of the generalized element (the parent). • Graphically, a generalization relationship is denoted as a solid line with a hollow arrowhead pointing to the parent, • Generalization is sometimes called an "is-a-kind-of" relationship

  34. Generalization Relationships A generalization connects a subclass to its superclass. It denotes an inheritance of attributes and behavior from the superclass to the subclass and indicates a specialization in the subclass of the more general superclass. Person Student Software Design (UML)

  35. Generalization Relationships (Cont’d) UML permits a class to inherit from multiple superclasses, although some programming languages (e.g., Java) do not permit multiple inheritance. Student Employee TeachingAssistant Software Design (UML)

  36. Button CancelButton ZoneButton Generalization

  37. Inheritance: - inheritance is a mechanism for sharing attributes and operations using a generalization relationship. • The dynamic model of a superclass is inherited by its subclasses. A subclass can have its own states.

  38. The inheritance relationship helps in managing the complexity by ordering objects within trees of classes with increasing levels of abstraction. Notation used is solid line with arrowhead, shown below. • Generalization and specialization are points of view that are based on inheritance hierarchies.

  39. Composition • A solid diamond denote composition, • A strong form of aggregation • Components cannot exist without the aggregate.

  40. TicketMachine 3 ZoneButton Composition

  41. COMPOSITION: This is a strong form of aggregation • It expresses the stronger coupling between the classes • The owner is explicitly responsible for creation and deletion of the part • Any deletion of whole is considered to cascade its part • The aggregate has a filled diamond at its end Window Client Area

  42. Client Server DEPENDENCY: • Dependency is semantic connection between dependent and independent model elements. • This association is unidirectional and is shown with dotted arrowhead line. • In the following example it shows the dependency relationship between client and server. • The client avails services provided by server so it should have semantic knowledge of server. • The server need not know about client.

  43. Interfaces An interface is a named set of operations that specifies the behavior of objects without showing their inner structure. It can be rendered in the model by a one- or two-compartment rectangle, with the stereotype <<interface>> above the interface name. <<interface>> ControlPanel Software Design (UML)

  44. <<interface>> ControlPanel getChoices : Choice[] makeChoice (c : Choice) getSelection : Selection Interface Services Interfaces do not get instantiated. They have no attributes or state. Rather, they specify the services offered by a related class. Software Design (UML)

  45. Interface Realization Relationship A realization relationship connects a class with an interface that supplies its behavioral specification. It is rendered by a dashed line with a hollow triangle towards the specifier. <<interface>> ControlPanel specifier implementation VendingMachine Software Design (UML)

  46. What is Cardinality? : Definition: Number of instances of each class involved in the dialogue is specified by cardinality. • Common multiplicity values: • Symbol Meaning • 1 One and only one • 0..1 Zero or one • M…N From M to N (natural integer) • 0..* From zero to any positive integer • 1..* From one to any positive integer • Also thought can be given about navigability to every applicable relationship.

More Related