1 / 22

Structural Modeling: Class Diagrams

Structural Modeling: Class Diagrams. Class Diagrams. Provide static view of system Most common type of diagram in OOAD Forms basis for component and deployment diagrams Shows Classes Interfaces Collaboration And their relationships. Classes. Definition of the word “ class ”

maxim
Download Presentation

Structural Modeling: Class Diagrams

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. Structural Modeling: Class Diagrams

  2. Class Diagrams • Provide static view of system • Most common type of diagram in OOAD • Forms basis for component and deployment diagrams • Shows • Classes • Interfaces • Collaboration • And their relationships

  3. Classes • Definition of the word “class” • Oxford: “a number of individuals having a character or feature in common” • Webster: “a number of persons or things regarded as forming a group by reason of common attributes, characteristics, qualities or traits”

  4. Classes in everyday life… • Based on similar values for a particular, or group of attributes • All purple dinosaurs; all green apples; all Jesuits • Based on the range of an attribute • Everyone who is between 18-21 years of age • Based on similar behavior • Everyone who sleeps in class; everyone in the ECIS program

  5. All about Classes • Based on the notion of abstraction • Starts with identification of all common characteristics of a set of elements • All objects belong to a class • Objects represent an instance of a class • Software objects are built from a class through instantiation

  6. Representation of a Class CLASS NAME Attributes Operations ( )

  7. Representation of a Class MOTORCYCLE Color Maximum Speed Engine Start ( ) Brake ( )

  8. Purpose of Class Diagrams • To model the vocabulary of the system • What lies within and without the system • To model simple collaborations • To visualize the relationship between classes • To model a logical database schema • Three major types of constructs in class diagrams • Inheritance structure • Association structure • Aggregation structure

  9. Additional Concepts • Aggregation • A relationship between two classes where the instances of one class are, in some way, components, members , or contents of the instances of the other class (from Brown, 2002) • Types • Component (assembly) • Container (contents) • Collection (Member)

  10. Aggregation: Component Car Engine Transmission Body Consists of Car Part

  11. Class Hierarchies Vehicle Land Air Car Bike Plane Helicopter (referred to as “Generalization”)

  12. Problems with Classification Animal Two-legged Four-legged Herbivore Carnivore Herbivore Carnivore Why should I classify this way instead of…

  13. Class Hierarchies Animal Herbivore Carnivore 2 legs 4 legs 2 legs 4 legs This way?

  14. Multiple Generalization Animal Herbivore Carnivore Two Legged Four legged Dog

  15. Subclass Partitioning • Disjoint vs. Overlapping • Based on mutually exclusive subgroups • Incomplete vs. Complete • Coverage of the entire set Powered Vehicle ANIMAL Disjoint and incomplete Overlapping and complete Plane Car Truck Herbivore Carnivore

  16. Relationships Between Classes • Associations • Objects are linked • Classes are associated • Represented as (a link) SU: University David: Student University Student (an association)

  17. Multiplicity • Sometimes called the “cardinality”of a relationship • The number of instances of each class that are or can be involved in a given association 1 University Student *

  18. Other Examples * Driver Bus * * Customer Product * * Student Course * 1 Advisor Student *

  19. Roles and multiplicity 1 University Student * 0..1 University Teacher * May be replaced by.. teacher employer * 0..1 University Person 1 * student

  20. An example Aggregation (composed of..) COMPANY located OFFICES DEPARTMENT Address: Stringvoice: number Name: Name constraint association * * roles {subset} generalization member 1..* manager 1 PERSON HEADQUARTERS Name: NameempID: IntegerTitle: String interface Getphoto() Getsound() Getcontact() Getpersrec() PersonnelRecord taxId: string Salary: currency

  21. Generalization vs. Aggregation • Can sometimes be confusing • Distinction can be made based on verb used • Generalization • The phrase: “IS A KIND OF…” • “A car is a kind of vehicle” • Aggregation • The phrase: “HAS A/AN…” • A car has an engine

  22. An Example BURNING LAMP LAMP ELECTRIC LAMP BASE WIRE SWITCH INCANDESCENT FLOURESCENT SOCKET BULB

More Related