CET203 SOFTWARE DEVELOPMENT Session 1B Modelling and the Theory of Inheritance.

Slides:



Advertisements
Similar presentations
Inheritance Inheritance Reserved word protected Reserved word super
Advertisements

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.
UML – Class Diagrams.
Slide 1 Chapter 7 Structural Modeling. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
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 
IMS1805 Systems Analysis Topic 3: Doing Analysis (continued from previous weeks)
Data and Process Modeling
7M822 UML Class Diagrams advanced concepts 15 September 2008.
PRJ566: PROJECT PLANNING AND MANAGEMENT Class Diagrams.
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
1 TCSS 360, Spring 2005 Lecture Notes Design Phase and UML Class Diagrams Relevant Reading: UML Distilled, Third Edition M. Fowler.
Unified Modeling Language
The Unified Modeling Language (UML) Class Diagrams.
Object-Oriented Analysis and Design
Association & Aggregation Lecture-9. Vehicle Car Tyre Engine Bus Passenger.
CMSC 202 Interfaces. 11/20102 Classes and Methods When a class defines its methods as public, it describes how the class user interacts with the method.
ZEIT2301 Design of Information Systems Structural Design: Class Diagrams School of Engineering and Information Technology Dr Kathryn Merrick.
CET203 SOFTWARE DEVELOPMENT Session 3B Interfaces.
CSCI-383 Object-Oriented Programming & Design Lecture 9.
1 UML Basic Training. UML Basic training2 Agenda  Definitions: requirements, design  Basics of Unified Modeling Language 1.4  SysML.
Slide 1 Structural Modeling Chapter 7. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
Distributed Java Programming Distributed Java Programming Class #2 August 22, 2002.
Structural Modeling. Objectives O Understand the rules and style guidelines for creating CRC cards, class diagrams, and object diagrams. O Understand.
Programming With Java ICS201 University Of Hail1 Chapter 13 Interfaces.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
Today in OOAD  The Domain Model Artifact UML Classes  EU-Bid Domain Model Exercise  EU-Lease Domain Model Assignment Guest Speaker  Kate Cunningham,
CET203 SOFTWARE DEVELOPMENT Session 3A Abstract classes and Polymorphism.
Unified Modeling Language © 2002 by Dietrich and Urban1 ADVANCED DATABASE CONCEPTS Unified Modeling Language Susan D. Urban and Suzanne W. Dietrich Department.
Chapter 16 Applying UML and Patterns Craig Larman
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.
UML for OOADStefan Kluth 1 2UML for OOAD 2.1What is UML? 2.2Classes in UML 2.3Relations in UML 2.4Static and Dynamic Design with UML.
Modeling system requirements. Purpose of Models Models help an analyst clarify and refine a design. Models help simplify the complexity of information.
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.
Introduction to Unified Modeling Language (UML) By Rick Mercer with help from The Unified Modeling Language User Guide, Grady Booch, James Rumbaugh, Ivar.
Lecture 6: Structural Modeling
Object Oriented Software Development
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 Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
CET203 SOFTWARE DEVELOPMENT Session 2B Constructors, Overriding and Overloading.
UML Class Diagram. A class diagram shows 1.Classes 2.The relationships between them.
Class diagrams Terézia Mézešová.
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
Object Oriented Programming and Data Abstraction Earl Huff Rowan University.
UML Fundamental Elements. Structural Elements Represent abstractions in our system. Elements that encapsulate the system's set of behaviors. Structural.
WELCOME TO OUR PRESENTATION UNIFIED MODELING LANGUAGE (UML)
Introduction to Unified Modeling Language (UML) By Rick Mercer with help from The Unified Modeling Language User Guide, Grady Booch, James Rumbaugh, Ivar.
1 An Overview of UML. 2 The Unified Modeling Language UML is a graphical language used by software engineers to model software systems during development.
Unified Modeling Language
Lecture 12 Inheritance.
UML Class Diagrams (more notation)
Objects as a programming concept
Object-Oriented Analysis and Design
Object-Oriented Modeling with UML
UML Class Diagrams: Basic Concepts
CMSC 202 Interfaces.
Software Engineering Lecture #11.
UML Class Diagram.
Introduction to Unified Modeling Language (UML)
Object-Oriented Knowledge Representation
Understand and Use Object Oriented Methods
Class Diagrams Class diagram is basically a graphical representation of the static view of the system and represents different aspects of the application.
2 UML for OOAD 2.1 What is UML? 2.2 Classes in UML
CMSC 202 Interfaces.
Presentation transcript:

CET203 SOFTWARE DEVELOPMENT Session 1B Modelling and the Theory of Inheritance

Objectives Recognise the different elements and attributes that form a UML class diagram Identify and represent relationships on class diagrams Produce models which exhibit inheritance and know how to represent them on a class diagram

UML Class Diagrams Graphical representation of main concepts (except method implementation) Static representation of the members of, and relationships between, classes Can be used to – sketch outline of design – communicate design ideas – formally document design

UML Class diagrams UML class diagrams provide a precise visual representation of class design which can take us forward towards implementation. You may sometimes hear people speak erroneously about the ‘UML method’ or ‘methodology’ UML is simply a set of standardized notations which can be used with or without a formal methodology A methodology defines the process which the system developers go through, not simply the form in which the design is documented

Uses of Class Diagrams We have concentrated on UML models ‘one step away’ from concrete C# implementations We have thought of members in terms of their programming implementations (instance variables and methods) Class diagrams may also be used much earlier in the life cycle when analysing the requirements In such contexts the meaning will be more abstract and not necessarily map closely onto programming language constructs

Terminology Strictly UML talks about ‘properties’ and ‘operations’ rather than ‘instance variables’ and ‘methods’ Properties comprise ‘attributes’ and ‘associations’ Beware: In this context ‘properties’ are not equivalent to the C# properties discussed in the last lecture! ClassName attribute operation() ClassName attribute operation() association

Suppression UML allows us to show as much or as little detail as we wish on any particular diagram. This is convenient because we can tailor the diagram to focus on the things we are particularly interested in conveying. It can also be confusing, since we can never infer the absence of something in the design from its omission in a diagram – it might simply have been ‘suppressed’! The details which follow do not cover every aspect of the UML 2.0 class diagram notation but allow enough detail to be recorded to create a fairly rich model For more information read Martin Fowler, “UML Distilled” (3 rd Edn.), Addison Wesley, 2004.

Summary of Class Diagram Elements Classes Members – attributes – operations – visibility Relationships – navigability – multiplicity – dependency – aggregation – composition Generalization / specialization – inheritance – interfaces Keywords Notes and Comments

Attributes Syntax: visibility name : type multiplicity Visibility – ‘+’ public – ‘-’ private – ‘#’ protected – ‘~’ internal Multiplicity – ‘n’ exactly n – ‘*’ zero or more – ‘m..‘n’ between m and n Don’t worry about these for now

Exercise 1

Operations Syntax: visibility name (par1 : type1, par2 : type2) : type Visibility – ‘+’ public – ‘-’ private – ‘#’ protected – ‘~’ internal Example + AddName (newName : String) : boolean

Exercise 2

Associations Primitive types (int, boolean etc.) can only be attributes Associations are similar to attributes of Object types and use some of the same notation We use an association when we want to give two related classes, and their relationship, prominence on a diagram The following are equivalent: MyClass value : Other MyClass Other value

Describing Associations We can show multiplicity at both ends of an association: MyClass Other 1 1..* Sometimes a verb phrase may be used to name an association: Throttle Motor Controls

Types of Association Class A Class B Dependency Class A Class B Simple association (navigable from A to B) Class A Class B Aggregation Class A Class B Composition Class A Class B Bidirectional association

Dependency Most unspecific relationship between classes (not strictly an ‘association’) Class A in some way uses facilities defined by Class B Changes to Class B may affect Class A Class A Class B

Simple Association Class A ‘uses’ objects of Class B Typically Class A has an attribute of Class B Navigability A to B: – A Class A object can access the Class B object(s) with which it is associated – The reverse is not true – the Class B object doesn’t ‘know about’ the Class A object Class A Class B

Bidirectional Association Classes A and B have a two-way association Each refers to the other class Navigability A to B and B to A: – A Class A object can access the Class B object(s) with which it is associated – Also, a Class B object can access the Class A object(s) with which it is associated Class A Class B

Aggregation Object(s) of Class B ‘belong to’ Class A Implies reference from A to B Aggregation is rather controversial – In general objects of Class B retain an existence independent of Class A – Some designers believe there is no real distinction between aggregation and simple association Class A Class B

Composition Object(s) of Class B are ‘part of’ a Class A object Again implies reference from A to B Much ‘stronger’ than aggregation – Class B objects are an integral part of Class A – In general objects of Class B never exist other than as part of Class A, i.e. they have the same ‘lifetime’ Class A Class B

Notes We can add notes to comment on a diagram element: Publication Includes all items with an ISBN or an ISSN

Generalization Classes are a generalized form from which objects with differing details can be created. The objects are ‘instances’ of their class. Student no is an instance of class Student. More concisely, is a Student. Classes themselves can often be organised by a similar kind of relationship.

Example: Biological classification Kingdom(e.g. animals) Phylum(e.g. vertebrates) Class(e.g. mammal) Order(e.g. carnivore) Family(e.g. cat) Genus(e.g. felix) Species(e.g. felix leo) Fred the lion is a…

Hierarchy Organism Animal Vertebrate Mammal Carnivore Cat Felix Felix Leo Fred

Fred is a… Fred is a felix leo is a felix is a cat is a carnivore Carnivores eat meat So Fred has the characteristic ‘eats meat’. Fred is a felix leo is a felix is a cat is a carnivore is a mammal is a vertebrate Vertebrates have a backbone So Fred has the characteristic ‘has a backbone’.

Inheritance Specifying general characteristics high up in the hierarchy and more specific characteristics lower down. Important principle in OO – we call this generalization and specialization. All the characteristics from classes above a class/object in the hierarchy are automatically featured in it – we call this inheritance.

Publications Book title author price copies SellCopy() OrderCopies() Magazine title price orderQty currIssue copies SellCopy() AdjustQty() RecvNewIssue()

Exercise 3a

Inheritance in UML Aside from associations, the other main modelling relationship is inheritance: Class A ‘inherits’ both the interface and implementation of Class B, though it may override implementation details and supplement both Class A Class B

Exercise 3b