Software Construction Lecture 5 Class Diagrams. Agenda 2  Topics:  Examples of class diagrams  Navigation, visibility, named associations, and multiplicity.

Slides:



Advertisements
Similar presentations
1 CIS224 Software Projects: Software Engineering and Research Methods Lecture 9 Object, Package, Component and Deployment Diagrams (Based on Fowler, 2004,
Advertisements

Class Diagrams Version 1.1 of : added learning objectives and DuckTestApp Version 1.2 of : added slide 6 on default values in UML Version.
ESE Einführung in Software Engineering 6. Modeling Objects and Classes Prof. O. Nierstrasz.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Architectural Modeling Notations.
UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
Design Patterns in Java Appendix D UML at a Glance Summary prepared by Kirk Scott 1.
What is UML? A modeling language standardized by the OMG (Object Management Group), and widely used in OO analysis and design A modeling language is a.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Class Diagram & Object Diagram
ESE Einführung in Software Engineering 6. Modeling Objects and Classes Prof. O. Nierstrasz.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 Class and Object Diagrams PRACTICAL OBJECT-ORIENTED DESIGN WITH.
7M822 UML Class Diagrams advanced concepts 15 September 2008.
© SERG Software Design (UML) Software Design Static Modeling using the Unified Modeling Language (UML) Material based on [Booch99, Rambaugh99, Jacobson99,
Unified Modeling Language
The Unified Modeling Language (UML) Class Diagrams.
Object-Oriented Analysis and Design
12-CRS-0106 REVISED 8 FEB 2013 CSG2H3 Object Oriented Programming.
Generation and Implementation. More on classes Types Implementation classes Interfaces Templates Associations –Dependencies –Compositions.
UML Diagrams: Class Diagrams The Static Analysis Model Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Component Basics CS6961 – Lecture 6 Nathan Dykman.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
Unit 1 INTRODUCTION TO MODELING AND CLASS MODEL Ref : L7-UML.PDF.
Chapter 16 Applying UML and Patterns Craig Larman
® IBM Software Group © 2006 IBM Corporation Rational Software France Object-Oriented Analysis and Design with UML2 and Rational Software Modeler 03. Classes,
1 Class Diagrams: Advanced Concepts. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are the most commonly used diagrams.
The Static Analysis Model Class Diagrams Prof. Hany H. Ammar, CSEE, WVU, and Dept. of Computer Science, Faculty of Computers and Information, Cairo University.
Class diagram Used for describing structure and behaviour in the use cases Provide a conceptual model of the system in terms of entities and their relationships.
UML Diagrams: The Static Model Class Diagrams. The Static Model Define the static structure of the logical model Represent classes, class hierarchies.
UML Class Diagram Trisha Cummings. What we will be covering What is a Class Diagram? Essential Elements of a UML Class Diagram UML Packages Logical Distribution.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Advanced UML Class Diagrams.
NJIT UML Class Diagrams Chapter 16 Applying UML and Patterns Craig Larman.
Software Design Software Design (UML) Static Modeling using the Unified Modeling Language (UML) Material based on [Booch99, Rambaugh99, Jacobson99, Fowler97,
Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.
2007ACS-3913 Ron McFadyen1 Class Diagram See Schaum’s UML Outline, especially chapters 4, 5, 6, 7.
Class Diagram. Classes Software Design (UML) Class Name attributes operations A class is a description of a set of objects that share the same attributes,
Chapter 5 System Modeling Sommerville, "software engineering ", 9 th Ed., 2011.
Week III  Recap from Last Week Review Classes Review Domain Model for EU-Bid & EU-Lease Aggregation Example (Reservation) Attribute Properties.
Appendix D UML at a Glance Summary prepared by Kirk Scott 1.
Design Model Lecture p6 T120B pavasario sem.
Object Oriented Analysis: Associations. 2 Object Oriented Modeling BUAD/American University Class Relationships u Classes have relationships between each.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
UML Class Diagram. A class diagram shows 1.Classes 2.The relationships between them.
Class Diagram Chapter 21 Applying UML and Patterns Craig Larman.
Chapter 3 Class Diagrams. 2 Outline Class Basics Class Basics Classes Classes Association Association Multiplicity Multiplicity Inheritance Inheritance.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
UML Class Diagram notation Indicating relationships between classes SE-2030 Dr. Mark L. Hornick 1.
UML Part 1: Class Diagrams. Introduction UML stands for Unified Modeling Language. It represents a unification of the concepts and notations presented.
Chapter 16: UML Class Diagrams
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
INFO 620Lecture #71 Information Systems Analysis and Design Design Class Diagrams and others INFO 620 Glenn Booker.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Class Diagram Lecture # 1. Class diagram A Class Diagram is a diagram describing the structure of a system shows the system's classes Attributes operations.
UML Fundamental Elements. Structural Elements Represent abstractions in our system. Elements that encapsulate the system's set of behaviors. Structural.
25/2/16. Software Design (UML) ClassName attributes operations A class is a description of a set of objects that share the same attributes, Operations.
Unified Modeling Language (UML)
UML Diagrams: Class Diagrams The Static Analysis Model
Unified Modeling Language
Course Outcomes of Object Oriented Modeling Design (17630,C604)
UML Class & Object Diagram II
Unified Modeling Language (UML)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
UML Diagrams: The Static Model Class Diagrams
Software Engineering Lecture #11.
Static Modeling using the Unified Modeling Language (UML)
Object Oriented System Design Class Diagrams
Presentation transcript:

Software Construction Lecture 5 Class Diagrams

Agenda 2  Topics:  Examples of class diagrams  Navigation, visibility, named associations, and multiplicity in UML  Interfaces and implementation, in UML  If you actually want to learn this material…  Find your own examples of class diagrams on the web. Try to interpret them. Look for patterns.  Talk about it within your study group.

Learning Objectives 3  Students will have a strong conceptual foundation for their future uses of the OO features of Java  Interfaces  Students will be able to interpret a class diagram  Worked examples in this lecture  Students will be competent at the basic OO design patterns  Implementing interfaces, composing classes, extending classes

Example of Inheritance 4 Source:

Too much detail? 5 Source:

Simplify! (with a little more notation) 6  Multiplicity:  There is exactly one teacher per course, as indicated by the 1.  A lecturer can teach any number of courses, as indicated by 0..*.  We can also write 1..* in a UML diagram.  The arrowheads indicate that the taughtBy association is navigable in both directions, telling us that  Course has an instance variable teacher, of type Lecturer, and  Lecturer has the instance variable Vector course.

Simplify even more, with defaults 7  Associations have default multiplicity 1  Association endpoints have a default name.  Course has an instance variable myLecturer of type Lecturer  Lecturer has an instance variable myCourse of type Vector  Getters, setters may be implied.  Unimportant members might not be shown.  Defaults may be well-defined by an organisation’s stylesheet, or (more commonly) by their UML-drawing software package.  See e.g. us/library/dd aspx: “Properties of Attributes in UML Diagrams” for VS us/library/dd aspx

One-way Navigation 8  These courses have a Vector of their Lecturers and Students.  (They might have a List; they might have an array; these are implementation decisions.)  These lecturers don’t know what they are teaching!  These students have no idea of what course they are taking!

Creating new classes by generalising 9  Lecturers and students have some attributes in common.  A public name  An address that is revealed to everyone in our University  A secret password  We write these methods once for the Person class, and we can reuse them in the Lecturer and Student class.  But we have complicated our design by adding another class.  Do we really need so many classes?

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. Car Engine Transmission

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 ScrollbarTitlebarMenu *

Interfaces 12  Interfaces are a way to specify behaviour (a public contract) without data or implementation.  Interfaces are classed with an extra label next to their name: >  A dotted open-triangle arrow, from a class to an interface means that “the class implements this interface”.  We also say that “the class fulfils the contract specified by this interface ”, or that it “realizes the interface.”  Note that interfaces define methods but not attributes.  A password allows a secureLogin().

Interface Realization Relationship > ControlPanel VendingMachine 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. specifier implementation

Interfaces A class’ interface can also be rendered by a circle connected to a class by a solid line. File outputStream inputStream FileWriter {file must not be locked} FileReader {file must exist}

Parameterized Class LinkedList T T 1.. * A parameterized class or template defines a family of potential elements. To use it, the parameter must be bound. A template is rendered by a small dashed rectangle superimposed on the upper-right corner of the class rectangle. The dashed rectangle contains a list of formal parameters for the class.

Parameterized Class (Cont’d) LinkedList T T 1..* Binding is done with the > stereotype and a parameter to supply to the template. These are adornments to the dashed arrow denoting the realization relationship. Here we create a linked-list of names for the Dean’s List. DeansList >(Name )

Enumeration > Boolean false true An enumeration is a user-defined data type that consists of a name and an ordered list of enumeration literals.

Exceptions > KeyException > SQLException > Exception getMessage() printStackTrace() Exceptions can be modeled just like any other class. Notice the > stereotype in the name compartment.

Packages Compiler A package is a container-like element for organizing other elements into groups. A package can contain classes and other packages and diagrams. Packages can be used to provide controlled access between classes in different packages.

Packages (Cont’d) Classes in the FrontEnd package and classes in the BackEnd package cannot access each other in this diagram. FrontEndBackEnd Compiler

Packages (Cont’d) Classes in the BackEnd package now have access to the classes in the FrontEnd package. FrontEndBackEnd Compiler

Packages (Cont’d) JavaCompiler We can model generalizations and dependencies between packages. CompilerJava

Can you understand this design? 23 Adapted from

Can you understand this design? 24 Source: of_composition_over_inheritance.svg, available of_composition_over_inheritance.svg

Learning Objectives (review) 25  Students will have a strong conceptual foundation for their future uses of the OO features of Java  Interfaces  Students will be able to interpret a class diagram  Worked examples in this lecture  Students will be competent at the basic OO design patterns  Implementing interfaces, composing classes, extending classes