1 / 51

CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS

CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS. A Simplified Object-Oriented Systems Analysis & Conceptual Design Methodology. Activities. Identify the information system’s purpose Identify the information system’s actors and features Identify Use Cases and create a Use Case Diagram

unity
Télécharger la présentation

CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS

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. CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS

  2. A Simplified Object-Oriented Systems Analysis & Conceptual Design Methodology Activities • Identify the information system’s purpose • Identify the information system’s actors and features • Identify Use Cases and create a Use Case Diagram • Identify Objects and their Classes and create a Class Diagram • Create Interaction/Scenario Diagrams • Create Detail Logic for Operations • Repeat activities 1-6 as required to refine the “blueprints”

  3. UML Class Diagrams The class diagram provides a static structure of all the classes that exist within the system. Classes are arranged in hierarchies sharing common structure and behavior and are associated with other classes. Class diagrams are used in: • Analysis To build a conceptual domain model with semantic associations between concepts • Design Structural model of a design in terms of class interfaces • Implementation Source code documentation, exposing the implementation

  4. Reality Domain Model Domain bus models vehicle car models cup models Object-Oriented Approach • Objects are abstractions of real-world or system entities Intro | Classes | Relations | Generalization | Guidelines

  5. Objects • The purpose of class modeling is to describe objects. • An object is a concept, abstraction or thing that has meaning for a domain/application. • Some objects have real world counterparts while others are conceptual entities. • The choice of objects depends on judgment and the nature of problem. • All objects have identity and are distinguishable.

  6. Classes • An object is an instance – occurrence – of a class • A class describes a group of objects with the same properties (attributes), behavior (operations), kinds of relationships, and semantics. • The objects in a class share a common semantic purpose, above and beyond the requirement of common attributes and behavior. • By grouping objects onto classes we abstract a problem.

  7. UML representation of classes/objects: • UML: Unified Modeling Language (OMG Standard): O.O Visual Modeling language • Class/object representation

  8. Values and attributes • Value : piece of data. • Attribute: a named property of a class that describes a value held by each object of the class. • Attributes may be discovered by looking for adjectives or by abstracting typical values. • Don’t confuse values with objects: • An attribute should describe values, not objects.

  9. UML representation

  10. Operations and Methods • An operation is a function or procedure that may be applied to or by objects in a class. • Each operation has a target object as an implicit parameter. • All objects in a class share the same operations.

  11. UML representation

  12. Objects • Objects have three responsibilities: • What they know about themselves – (e.g., Attributes) • What they do – (e.g., Operations) • What they know about other objects – (e.g., Relationships)

  13. Defining Class A CLASS is a template (specification, blueprint) for a collection of objects that share a common set of attributes and operations. HealthClubMember attributes operations Class Objects

  14. { Member memberNumber firstName lastName telephone address city etc... Expanded view of a Class into its three sections: Top: Class Name Middle: attributes Bottom: operations attributes { checkOutVideo checkInVideo buyItem etc... operations UML Class Diagram Notation 1 of 2 Class

  15. Class diagram Name Account_Name - Customer_Name - Balance Attributes +addFunds( ) +withDraw( ) +transfer( ) Operations

  16. Class diagram • Each class is represented by a rectangle subdivided into three compartments • Name • Attributes • Operations • Modifiers are used to indicate visibility of attributes and operations. • ‘+’ is used to denote Public visibility (everyone) • ‘#’ is used to denote Protected visibility (friends and derived) • ‘-’ is used to denote Private visibility (no one) • By default, attributes are hidden and operations are visible.

  17. Relationships A RELATIONSHIP is what a class or an object knows about another class or object. • Generalization (Class-to-Class) (Superclass/Subclass) • Inheritance • Ex: Person - FacultyPerson, StudentPerson, Staff... • Ex: ModesOfTravel - Airplane, Train, Auto, Cycle, Boat... • [Object] Associations • FacultyInformation - CourseInformation • StudentInformation - CourseInformation • [Object]Aggregations & Composition(Whole-Part) • Assembly - Parts • Group - Members • Container - Contents F o u r T y p e s

  18. Object Aggregation Association Object Composition Association Object Association n n 1 1..* 0..* 0..* UML Class Diagram Notation 2 of 2 Class Generalization Relationship Will always be “1”

  19. Class Diagram Relationships • Class • Generalization • Object • Association • Aggregation • Composition

  20. Generalization (Class-to-Class) (superclass – subclass; supertype – subtype) • A Generalization follows a “is a” or “is a kind of” heuristic from a specialization class to the generalization class. (e.g., student “is a” person, video “is a kind of” inventory). • Common attributes, operations and relationships are located in the generalization class and are inherited by the specialization classes • Unique attributes, operations and relationships are located in the specialization classes. • Inherited attributes and operations may be overridden or enhanced in the specialization class depending on programming language support.

  21. Generalization Example • Others: • Transactions • Things • Places • Etc... <<abstract>> Role attributes operations Staff Student Visitor Faculty attributes attributes attributes attributes operations operations operations operations Note: <<abstract>> = no objects

  22. Poor Generalization Example (violates the “is a” or “is a kind of” heuristic) Person attributes operations Head Leg Arm attributes attributes attributes operations operations operations

  23. Generalization Inheritance Generalization a1 a2 a3 Generalization a1 a2 a3 o1 o2 o3 One-Way Inheritance from the Generalization to the Specialization Common o1 o2 o3 Specialization a1 a2 a3 a4 a5 a6 Specialization a4 a5 a6 Unique o1 o2 o3 o4 o5 o6 o4 o5 o6 (a = attribute; o = operation)

  24. UML Generalization Notation Supertype discriminator Subtype 1 Subtype 2 Note: Supertype = Superclass; Subtype = Subclass

  25. Generalization - Multiple Classification Discriminator Doctor Female role Nurse <<abstract>> Person Gender {complete} Male patient Physical- therapist #1 Patient #3 #2

  26. Rational Rose Class Diagram Example

  27. Example tools • Argo UML– http://argouml.tigris.org • Object Domain – http://www.objectdomain.com/domain/evaluationIntro.html • Rational Rose – http://www.rational.com • Microsoft Visio

  28. Associations • Relationships between instances (objects) of classes • Conceptual: • associations can have two roles (bi-directional): • source --> target • target --> source • roles have multiplicity (e.g., cardinality, constraints) • To restrict navigation to one direction only, an arrowhead is used to indicate the navigation direction • No inheritance as in generalizations

  29. Object Association Relationship Patterns Class A attributes operations Whole Whole attributes operations attributes operations Class B Class B attributes operations attributes operations Part2 Part2 Part1 Part1 PartN PartN attributes operations attributes operations attributes operations attributes operations attributes operations attributes operations Class A attributes operations b) Object Aggregation Associations x x x x x x x x c) Object Composition Associations (y may not be “1”) x 1 1 x 1 y y y a) Object Associations

  30. Associations role B Class A Class B role A Example: Employee Company Person Employer

  31. Multiplicities 1 Class exactly one many (zero or more) 0..* Class 0..1 optional (zero or one) Class m..n numerically specified Class Example: 0..* Course CourseOffering 1

  32. Aggregation & Composition • Aggregation (shared aggregation): • is a specialized form of ASSOCIATION in which a whole is related to its part(s). • is known as a “part of” or containment relationship and follows the “has a” heuristic • three ways to think about aggregations: • whole-parts • container-contents • group-members

  33. Aggregation & Composition • Composition (composite aggregation): • is a stronger version of AGGREGATION • the “part(s)” may belong to only ONE whole • the part(s) are usually expected to “live” and “die” with the whole (“cascading delete”) • Aggregation vs. Composition vs. Association???

  34. Aggregation Composition Faculty SalesOrder 1..* 1 (team-teaching is possible) 0..* 1..* Course SalesOrderLineItem (another: hand --> finger) (another: assembly --> part)

  35. OO Relationships:Composition • Composition • Every part may belong to only one whole, and If the whole is deleted, so are the parts • Example: • A number of different chess boards: Each square belongs to only one board. If a chess board is thrown away, all 64 squares on that board go as well. Class W Whole Class ClassP2 ClassP1 Part Classes [From Dr.David A. Workman] Example Figure 16.7 The McGraw-Hill Companies, 2005

  36. OO Relationships: Aggregation Container Class Aggregation: expresses a relationship among instances of related classes. It is a specific kind of Container-Containee relationship. express a more informal relationship than composition expresses. Aggregation is appropriate when Container and Containees have no special access privileges to each other. ClassC AGGREGATION Class E2 Class E1 Containee Classes Example Bag Milk Apples [From Dr.David A. Workman]

  37. Association, Aggregation and Composition Template/Pattern Example w 1 w 2 Whole Whole w 3 w 4 0..* p 6 p 5 p 4 0..* p 3 p 2 p 1 Part Part (association, aggregation & composition look the same)

  38. Multiplicity Example #1 P P P W P P Whole 3 1 5 2 Part1 PartN • One Whole is associated with 5 Part1 • One Part1 is associated with 1 Whole • One Whole is associated with 2 PartN • One PartN is associated with 3 Whole W P W P P W P W W

  39. Multiplicity Example #2 Class1 max. 2..5 1 min. 1..n 0..* Class2 Class3 2..5 C1 * 1..n 1 C3 C1 C2 C1 C3 C2 C1 C3 C3 C1 C2 C2 C1 C1 C3 C2 C1 C3 C2 etc... etc...

  40. Multiplicity Example #3 FacultyInformation StudentInformation 1 1 1 0..* 1 0..* 1..* 0..* CommitteeAssign DegreeHeld CourseCompleted 0..* 0..* Course ClubMember

  41. “many-to-many” multiplicity StudentInformation CourseInformation 0..* attributes attributes 0..* operations operations Becomes either StudentInformation CourseInformation CourseInformation StudentInformation 0..* attributes attributes attributes attributes 0..* operations operations operations operations 1 1 0..* 0..* StudentCourseInformation Attributes that represent the “union” of the two classes are located in this “association” class. StudentCourseInformation SemesterTaken GradeEarned SemesterTaken GradeEarned operations operations

  42. Association class

  43. Reflexive Association Relationships Objects within the same class have a relationship with each other. Course 0..* is pre-requisite for 0..* has pre-requisite of

  44. Association class

  45. Video Store – UML Class Diagram 1 1 Inventory RentalItem SaleItem Video ConcessionItem Game VCR 0..* 0..* StoreLocation Transaction Employee 1 1 SaleTransaction RentalTransaction Supplier 0..* 1 1 0..* 1 1 0..1 0..* Member PurchaseOrder 1 1..* 1..* 1..* SaleRentalLineItem 0..* 0..* PurchaseOrderLineItem

More Related