UML Class Diagrams. Lesson Objectives



Similar documents
11 November

History OOP languages Year Language 1967 Simula Smalltalk

Structural Modeling and Analysis

Chapter 13 - Inheritance

The UML Class Diagram

Object Oriented Software Models

LAB 3: Introduction to Domain Modeling and Class Diagram

Chapter 5: Requirements Analysis and Validation Organizational Requirements Engineering

ATM Case Study OBJECTIVES Pearson Education, Inc. All rights reserved Pearson Education, Inc. All rights reserved.

Java: overview by example

Object Oriented Design

An Introduction To UML Class Diagrams Classes

UML basics. Part III: The class diagram. by Donald Bell IBM Global Services

Lectures 2 & 3: Introduction to Modeling & UML. Getting started

Case studies: Outline. Requirement Engineering. Case Study: Automated Banking System. UML and Case Studies ITNP090 - Object Oriented Software Design

How To Design Software

D06 PROGRAMMING with JAVA

III. Class and Object Diagrams

Lecture 12: Entity Relationship Modelling

Using UML Part One Structural Modeling Diagrams

Design and UML Class Diagrams

Abstract Classes. Suppose we want write a program that manipulates various types of bank accounts. An Account typically has following features;

Software Development: An Introduction

Object Oriented Analysis and Design and Software Development Process Phases

Java (12 Weeks) Introduction to Java Programming Language

Entity-Relationship Model. Purpose of E/R Model. Entity Sets

Construction Principles and Design Patterns. Flyweight, Bridge, Builder

USING UML FOR OBJECT-RELATIONAL DATABASE SYSTEMS DEVELOPMENT: A FRAMEWORK

III. Class and Object Diagrams

Data Modeling Basics

How to Make a Domain Model. Tutorial

Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page:

BCS HIGHER EDUCATION QUALIFICATIONS Level 6 Professional Graduate Diploma in IT. March 2013 EXAMINERS REPORT. Software Engineering 2

Lab Manual: Using Rational Rose

Design and UML Class Diagrams. Suggested reading: Practical UML: A hands on introduction for developers

CS 111 Classes I 1. Software Organization View to this point:

Chapter 1 Java Program Design and Development

System Modeling / Class Diagra Diagr m a Week 6

Software Project Management and UML

SysML Modelling Language explained

D06 PROGRAMMING with JAVA. Ch3 Implementing Classes

Programming Language Constructs as Basis for Software Architectures

Contents. Introduction and System Engineering 1. Introduction 2. Software Process and Methodology 16. System Engineering 53

Masters of Science in Software & Information Systems

2. Analysis. The goal of this is to understand the problem. The key question is What?.

Database Modelling in UML

ATM Case Study Part 1

Umbrello UML Modeller Handbook

Introduction to Object-Oriented Programming

Architecture. Reda Bendraou

Inheritance, overloading and overriding

Requirements engineering

Database Design Methodology

Graphical Systems Modeling with UML / SysML Class diagrams

Decomposition into Parts. Software Engineering, Lecture 4. Data and Function Cohesion. Allocation of Functions and Data. Component Interfaces

Chapter 2: Entity-Relationship Model. Entity Sets. " Example: specific person, company, event, plant

a. Inheritance b. Abstraction 1. Explain the following OOPS concepts with an example

Engineering Process Software Qualities Software Architectural Design

Data Analysis 1. SET08104 Database Systems. Napier University

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.

International Journal of Advanced Research in Computer Science and Software Engineering

Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is

Domain Modeling. Domain Modeling

Part 7: Object Oriented Databases

Object Oriented Programming. Risk Management

Chapter 2: Entity-Relationship Model. E-R R Diagrams

Lecture 7 Notes: Object-Oriented Programming (OOP) and Inheritance

Unit 2.1. Data Analysis 1 - V Data Analysis 1. Dr Gordon Russell, Napier University

OOP? What is OOP? Why? OOP in a nutshell. Stéphane Ducasse 2.1

Writing Use Case Scenarios for Model Driven Development

CPS211 Lecture: Class Diagrams in UML

Programming by Contract. Programming by Contract: Motivation. Programming by Contract: Preconditions and Postconditions

Database Design Overview. Conceptual Design ER Model. Entities and Entity Sets. Entity Set Representation. Keys

Questions? Assignment. Techniques for Gathering Requirements. Gathering and Analysing Requirements

An Approach towards Automation of Requirements Analysis

CompuScholar, Inc. Alignment to Utah's Computer Programming II Standards

Moving from CS 61A Scheme to CS 61B Java

Lesson 8: Introduction to Databases E-R Data Modeling

SYSML PLUGIN. version user guide

ICOM 4015: Advanced Programming

More on Objects and Classes

1 Class Diagrams and Entity Relationship Diagrams (ERD)

Tutorial - Building a Use Case Diagram

LESSON 12 ALL SAVINGS CHOICES INVOLVE RISK: GRANDMA S GIFT

Programming and Software Development CTAG Alignments

UML Diagram Types. Use Cases do the Following. Use Case Diagram

Building Java Programs

Communication Diagrams

Programming to Interfaces

How To Draw A Cell Phone Into A Cellphone In Unminimal Diagram (Uml)

Chap 4. Using Metrics To Manage Software Risks

3 Pillars of Object-oriented Programming. Industrial Programming Systems Programming & Scripting. Extending the Example.

Transcription:

UML Class Diagrams 1 Lesson Objectives Understand UML class diagrams and object modelling Be able to identify the components needed to produce a class diagram from a specification Be able to produce class diagrams and document them using Eclipse/Together 2

UML Class BankAccount Name balance iratecharge deposit withdraw Attributes Methods/ operations 3 UML Class: Different levels of detail BankAccount BankAccount - balance: int - iratecharge: float +deposit:int +withdraw:int balance iratecharge deposit withdraw signature BankAccount BankAccount balance iratecharge 4

Objects and Classes anobject: ClassName attribute1 = value1 attribute2 = value2 ClassName attribute1 attribute2: data_type attribute3: type = init_val... operation1() operation2(arg_list) operation3() : returntype... Object (instance).. is instantiated from... Class 5 Objects and Classes: Example Car spacewagon: Car manufacturer = Mitsubishi registrationnumber = R637GNU driver = Naomi manufacturer registrationnumber: Integer driver: String = Unspecified... register() drive (Integer speed) getdriver() : String... 6

Class Diagrams BankAccount Customer 9 Associations: Multiplicity Student Module * * Many-to-many relationship Student Module 10..* 0..12 A student takes between 0 and 12 modules A module is taken by at least 10 students 10

1-to-1 and 1-to-many Associations Country name:string 1 Has-capital 1 City name:string 1-to-1 association draw() Polygon 1 * Point x:integer y:integer 1-to-many association 11 Association Notation Family 0..1 parentage offspring child 0..* Individual 0..1 wife 0..1 husband married to 12

Aggregation An aggregation is a special case of association denoting a consists of hierarchy. The aggregate is the parent class, the components are the children class. Exhaust System is a part of Muffler 1 0..2 Tailpipe 13 Aggregation Example Engine horsepower volume on off 1 Car serial number year manufacturer model colour weight drive purchase 3,4,5 * 2,4 1 Wheel Brakelight Door Battery diameter number of bolts on off 14 open close amps volts charge discharge

Composition A solid diamond denotes composition, a strong form of aggregation where components cannot exist without the aggregate. TicketMachine 3 ZoneButton 15 Assembly or Composition? Assembly: component can exist on its own Composition: component cannot exist on its own Football Club * Footballer * Fixtures to play 16

Generalization/Inheritance Account Balance AccountId Deposit() Withdraw() GetBalance() Is a kind of SavingsAccount ChequeAccount Withdraw() Withdraw() 17 Inheritance Classes inherit the attributes and operations of their parents i.e. from the generalization to the specialization Operations and attributes may be re-defined Additional operations or attributes must be defined Operations and attributes may not be removed in the specialization 18

Associations: which type? If in doubt use simple association Use aggregation or composition for has a relationships Use inheritance for is a relationships 19 Visibility and Scope... Public.... + Visible to using classes Protected.. # Visible to subclasses Private... - Visible only within this class -size : Rectangle Window -xptr : Xwindow * -visibility : Boolean +Window () +display () : void +hide () : void #attachxwindow (Xwindow * xwin) : void 20

Finding Classes Study use case descriptions Grammatical analysis Nouns Adjectives Verbs Brainstorm Use CRC cards 21 Example: Scenario From Problem Statement Jim enters a store with the intention of buying a toy for his 3 year old child. Help must be available within less than one minute. The store owner gives advice to the customer. The advice depends on the age range of the child and the attributes of the toy. Jim selects a dangerous toy which is unsuitable for the child. The store owner recommends a more suitable toy - a doll. 22

Mapping Parts of Speech to Object Model Components Part of speech Model component Example Proper noun object Jim Smith Improper noun class Toy, doll Doing verb method Buy, recommend being verb inheritance is-a (kind-of) having verb aggregation has an modal verb constraint must be adjective attribute 3 years old transitive verb method enter intransitive verb method (event) depends on 23 Identifying Inappropriate Classes Redundant Vague An event or an operation Meta-language Outside the scope of the system An attribute Only operations are Set() and Get(). 24

CRC Card 25 Two OO Design Camps Data driven design Responsibility driven design 26

Package It All Up Pack up design into discrete physical units that can be edited, compiled, linked, reused Construct physical modules Ideally use one package for each subsystem System decomposition might not be good for implementation Two design principles for packaging Minimize coupling Maximize cohesiveness 27 UML Packages General mechanism for grouping modeling elements Package owns its contents Defines a nested name space e.g. PackageName::ClassName c.f. Java Style: PackageName.ClassName Elements belong to one and only one Package Packages can be nested. 29

Packages with Dependencies Dependencies should be one-way Avoid cyclic dependencies! Less stable components depend on more stable (reusable) ones Packages reflect development responsibility The art of large scale design is minimising dependencies. 30 Summary Class diagrams are the central feature of UML Class diagrams enable us to model objects, classes and associations between classes. At more detailed level you may need to consider special types of association like aggregation and composition Inheritance is an especially important type of association Finding classes is difficult - techniques like noun identification and CRC cards are helpful 32