Engineering Quality Software Week09
SYST30009 - Engineering Quality Systems Agenda This week Review last class Class Diagrams Sheridan SYST30009 - Engineering Quality Systems
Class Diagrams Learning Objectives Construct a class diagram from a narrative including relationships and multiplicities. Identify and represent inheritance hierarchies in a class diagram. Learn what is meant by a concrete and/or abstract class. How to determine and note the constraints for generalization / specialization relationships. Learn how to describe Whole-to-Part relationships on a class diagram. How to draw all these relationships using System Architect. Sheridan SYST30009 - Engineering Quality Systems
SYST30009 - Engineering Quality Systems Class Diagrams Document the static structure of the system They define what classes there are and how they are related The symbol on the right defines the data and behaviour encapsulated by a class. Objects “know things and know how to do things!” Sheridan SYST30009 - Engineering Quality Systems
Using System Architect Demo exercise Sheridan SYST30009 - Engineering Quality Systems
SYST30009 - Engineering Quality Systems Types of Objects From last class… Sheridan SYST30009 - Engineering Quality Systems
SYST30009 - Engineering Quality Systems Objects- Review We need to know what types of things the user works with routinely. Many types Tangible Intangible Important to include information from all types of users Sheridan SYST30009 - Engineering Quality Systems
SYST30009 - Engineering Quality Systems Jacobson’s Three Types Of Objects Entity Interface Control Sheridan SYST30009 - Engineering Quality Systems
Attributes & Behaviors Behavior (methods & operations) Real world Data world Sheridan SYST30009 - Engineering Quality Systems
SYST30009 - Engineering Quality Systems Class Diagram Showing Two Classes Object Diagram with Two Instances Sheridan SYST30009 - Engineering Quality Systems
Associations/Relationships relationship among object classes solid line connecting classes association is named i.e. drives where line connects to class is called “association role” Sheridan SYST30009 - Engineering Quality Systems
Associations with Multiplicity * * shows number of objects in an association lower..upper bound bounds are inclusive 2..5 0..1 = optional one 0..* = optional many 1..* = many 1 = exactly one * * * * * * Sheridan SYST30009 - Engineering Quality Systems
The complexity of the Many-to-many relationships Examples Sheridan SYST30009 - Engineering Quality Systems
SYST30009 - Engineering Quality Systems Your turn… SLATE – Lesson 08 Class Diagram Exercises Sheridan SYST30009 - Engineering Quality Systems
SYST30009 - Engineering Quality Systems Sheridan SYST30009 - Engineering Quality Systems
SYST30009 - Engineering Quality Systems Subclasses Some instances of a class (subclass) may be grouped together based on features not shared by the rest of the class. Attributes Behavior Relationships Key verb is “isakinda” (and inverse, “canbea”). Sheridan SYST30009 - Engineering Quality Systems
Subclasses and Inheritance A subclass is made up of selected instances from another class, the “Parent class” or “superclass.” A superclass includes all the instances of the subclass, plus possibly more as well. Sheridan SYST30009 - Engineering Quality Systems
Subclasses and Inheritance Each subclass then adds attributes and behaviors that it needs but the other one doesn’t. Inheritance is when a subclass instance, in addition to the attributes and behavior it has by virtue of being in the subclass, also has all the attributes and behavior that instances of the superclass have. Sheridan SYST30009 - Engineering Quality Systems
Subclasses and Inheritance The subclass relationship actually is a relationship in the way we have used that word. It requires a verb (one in each direction). “isakinda” “canbea” isakinda canbea Sheridan SYST30009 - Engineering Quality Systems
SYST30009 - Engineering Quality Systems Object-Oriented To be considered truly O-O, a language, database, etc. must support: Objects, Classes, Inheritance, and Polymorphism Sheridan SYST30009 - Engineering Quality Systems
SYST30009 - Engineering Quality Systems With subclasses, we can show more detail about relationships on our diagram. For instance, in most companies, only managers can hire and fire. In other words, only certain kindsa employees can do certain tasks. (only a baker can bake) We are able to show that some relationships affect only a subclass, not every instance. Subclasses Sheridan SYST30009 - Engineering Quality Systems
SYST30009 - Engineering Quality Systems Your turn… SLATE- Inheritance Exercise Sheridan SYST30009 - Engineering Quality Systems
Generalization, Inheritance & Constraints generalization path solid line with hollow arrowhead pointing from subclass to superclass indicate basis of generalization name the path for the attribute being removed = called the discriminator discriminator shows which property is abstracted by a generalization relationship Sheridan SYST30009 - Engineering Quality Systems
Constraints on Generalization constraints on the subclasses overlapping: descendent may be descended from more than one of the subclasses student can be both a research and teaching assistant disjoint: descendent may not be descended from more than one of the subclasses patient can not be both out and resident Sheridan SYST30009 - Engineering Quality Systems
Constraints on Generalization complete: all subclasses are listed only have out and resident patients incomplete: all subclasses are not listed more subclasses are available can have casual, part-time employees Sheridan SYST30009 - Engineering Quality Systems
Whole-to-Part Associations The UML provides ways to model two types of whole-to-part associations – aggregation and composition. Jerry Kotuba SYST30009-Engineering Quality Software
SYST30009-Engineering Quality Software Definitions aggregate: In an aggregation, the class representing the whole. aggregation: An association between classes representing a part-to-whole relationship in which the parts and the whole may exist independently and in which a single part may be associated with more than one whole at the same time. Jerry Kotuba SYST30009-Engineering Quality Software
SYST30009-Engineering Quality Software Definitions…cont’d composite: In a composition, a class representing the whole. composition: An association between classes representing a whole-to-part relationship in which the parts may belong to only one whole at a time and the whole does not exist without its parts. Jerry Kotuba SYST30009-Engineering Quality Software
Example of an Aggregation . Jerry Kotuba SYST30009-Engineering Quality Software
Example of a Composition . Jerry Kotuba SYST30009-Engineering Quality Software
Aggregation and Composition . Jerry Kotuba SYST30009-Engineering Quality Software
Categories of Whole-to-Part Associations There are three relationships that sometimes occur in an object model: Assemblies of parts Members of groups Containers and their contents You may find these useful for making your model a better tool for understanding and communication. The model can always be built without these. They do not really affect its use for system design, just for talking to the users. Jerry Kotuba SYST30009-Engineering Quality Software
SYST30009-Engineering Quality Software Assemblies of parts Taking something apart into its components is a technique we humans often use to understand how something works. Often we find it improves our understanding to model A product and its components A business consists of branches, departments, etc. A country consists of states, provinces, counties, boroughs, shires, towns, villages, cities, etc. Jerry Kotuba SYST30009-Engineering Quality Software
Containers and their contents Container-Contents is a different and less common relationship. In some situations we may find it helpful to view a relationship as one of these, e.g., Truck or Aircraft and the Products or Shipments that it carries An actual shipping container and the goods it holds A ship, bus or airplane and its passengers A building and the businesses it houses. Jerry Kotuba SYST30009-Engineering Quality Software
Assemblies of parts Vs Containers and their contents A Container, however, is still a perfectly good Container, even without its Contents The jar is still OK even without the “hunny.” And the Contents are perfectly OK without the Container (although the “hunny” might get all over one’s paws!) The essential difference between these relationships is that: With Assemblies of parts, if you take the component away, the assembly (whole) probably won’t work any more Take a wheel off a car Take a hand off a clock Take a leg off a table. Jerry Kotuba SYST30009-Engineering Quality Software
Collection-Member (members of groups) Collection-Member is also a different and relatively uncommon relationship. Sometimes we meet an actual collection: A library full of books An art gallery A stamp or jewelry collection A fleet of trucks, ships or aircraft Other times it may help to use this to describe: A place of worship, club or regiment and its members An inventory of furniture or equipment A herd, mob, flock, school or skein of animals. Jerry Kotuba SYST30009-Engineering Quality Software
SYST30009-Engineering Quality Software How to show it in SA… Draw the usual association link. The “edit” the Association link and under the “aggregation” column select “aggregate” for Basic or “composite” for Composition Jerry Kotuba SYST30009-Engineering Quality Software
SYST30009-Engineering Quality Software Your Turn… Think about a book, which consists of a cover, table of contents, chapters and an index. Chapters in turn have pages, paragraphs and words. Show the special case of association between classes described here including the multiplicity. Jerry Kotuba SYST30009-Engineering Quality Software
SYST30009 - Engineering Quality Systems Your turn… SLATE – ICE04 & ICE05 Vehicle Registration System Sheridan SYST30009 - Engineering Quality Systems
SYST30009 - Engineering Quality Systems What Comes Next? State Diagrams Sheridan SYST30009 - Engineering Quality Systems