Unified Modeling Language

Slides:



Advertisements
Similar presentations
CS 340 UML Class Diagrams. A model is an abstraction of a system, specifying the modeled system from a certain viewpoint and at a certain level of abstraction.
Advertisements

Slides 4/22 COP Topics Final Exam Review Final Exam The final exam is Friday, April 29 th at 10:00 AM in the usual room No notes, books, calculators,
UML Class and Sequence Diagrams Violet Slides adapted from Marty Stepp, CSE 403, Winter 2012 CSE 403 Spring 2012 Anton Osobov.
UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
UML – Class Diagrams.
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,
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
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.
Unified Modeling Language (UML)
UML a crash course Alex Lo Brian Kiefer. Overview Classes Class Relationships Interfaces Objects States Worksheet.
1 Object-Oriented Modeling Using UML CS 3331 Fall 2009.
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
COMS W4156: Advanced Software Engineering
UML Diagrams Computer Science I.
CS 2511 Fall UML Diagram Types  2 Main Types Structure Diagrams ○ Class Diagrams ○ Component Diagrams ○ Object Diagrams Behavior Diagrams ○
Object-Oriented Analysis and Design An Introduction.
Programming in Java Unit 3. Learning outcome:  LO2:Be able to design Java solutions  LO3:Be able to implement Java solutions Assessment criteria: 
CSC 395 – Software Engineering Lecture 13: Object-Oriented Analysis –or– Let the Pain Begin (At Least I’m Honest!)
1 UML Basic Training. UML Basic training2 Agenda  Definitions: requirements, design  Basics of Unified Modeling Language 1.4  SysML.
Distributed Java Programming Distributed Java Programming Class #2 August 22, 2002.
Systems Analysis & Design 7 th Edition Chapter 5.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 15 System Modeling with the UML.
Unit 1 INTRODUCTION TO MODELING AND CLASS MODEL Ref : L7-UML.PDF.
Introduction to Rational Rose 2000 v6.5 Copyright © 1999 Rational Software, all rights reserved 1 Rational Rose 2000 Class Diagrams.
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 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.
NJIT UML Class Diagrams Chapter 16 Applying UML and Patterns Craig Larman.
Introduction to Unified Modeling Language (UML) By Rick Mercer with help from The Unified Modeling Language User Guide, Grady Booch, James Rumbaugh, Ivar.
UML Class Diagrams 1 These lecture slides are copyright (C) Marty Stepp, They may not be rehosted, sold, or modified without expressed permission.
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
Design Jon Walker. More UML ● What is UML again?
Design Model Lecture p6 T120B pavasario sem.
Object Oriented Analysis and Design Class and Object Diagrams.
CSE 403, Spring 2008, Alverson Using UML to express Software Architecture.
Introduction to UML CS A470. What is UML? Unified Modeling Language –OMG Standard, Object Management Group –Based on work from Booch, Rumbaugh, Jacobson.
ITEC324 Principle of CS III Chapter 2 (Horstmann’s Book) – Part 1 The Object-Oriented Design Process Hwajung Lee.
Lecture 9-1 : Intro. to UML (Unified Modeling Language)
Chapter 3 Class Diagrams. 2 Outline Class Basics Class Basics Classes Classes Association Association Multiplicity Multiplicity Inheritance Inheritance.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
UML Part 1: Class Diagrams. Introduction UML stands for Unified Modeling Language. It represents a unification of the concepts and notations presented.
Chapter 3: Introducing the UML
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.
Object Oriented Programming and Data Abstraction Earl Huff Rowan University.
Unified Modeling Language (UML)
UML Fundamental Elements. Structural Elements Represent abstractions in our system. Elements that encapsulate the system's set of behaviors. Structural.
Introduction to Unified Modeling Language (UML) By Rick Mercer with help from The Unified Modeling Language User Guide, Grady Booch, James Rumbaugh, Ivar.
COP 3330 Notes 4/13. Today’s Topics UML Class Diagrams.
UNIT-IV Designing Classes – Access Layer ‐ Object Storage ‐ Object Interoperability.
Object-Orientated Analysis, Design and Programming
Unified Modeling Language
Course Outcomes of Object Oriented Modeling Design (17630,C604)
Object-Oriented Analysis and Design
Unified Modeling Language—UML A Very Brief Introduction
Introduction to Unified Modeling Language (UML)
Software Engineering Lecture #11.
UML Class Diagram.
Introduction to Unified Modeling Language (UML)
Unified Modelling Language
Software Design Lecture : 15.
Copyright 2007 Oxford Consulting, Ltd
Introduction to UML Sources:
Object Oriented System Design Class Diagrams
UML  UML stands for Unified Modeling Language. It is a standard which is mainly used for creating object- oriented, meaningful documentation models for.
ITEC324 Principle of CS III
Presentation transcript:

Unified Modeling Language UML Much of the information in this presentation is adapted from Wikipedia

Open Source Software DIA can be used to create UML diagrams http://dia-installer.de/download.html You may want to start the program, if you like to follow along.

Example

Example

Example

Questions you may ask… SO, you need to get up to speed in a hurry on an existing system. OR, you want to quickly communicate the overall design of a system (i.e., the system architecture*) to other programmers. What’s important to know? What classes are involved? What’s the purpose of each class? (what methods can I call so the class “works” for me) What’s the relationship between classes? * covered in more detail during field session

What is UML? The Unified Modeling Language (UML) is an open method used to specify, visualize, modify, construct and document the artifacts of an OO software project. UML 1.0 Spec proposed in January 1997 UML 1.1 adopted in November 1997 UML 2.0 adopted in 2005

What is UML (continued) UML is not a development method. It is compatible with leading OO software development methods. System model includes diagrams + “semantic backplane” – written use cases etc. UML diagrams represent two views of system model: Static structure of the system using objects, attributes, operations and relationships. The structural view includes class diagrams and composite structure diagrams. Dynamic (behavioral) behavior. Shows collaboration among objects and changes to system state, represented via sequence diagrams, activity diagrams and state machine diagrams.

UML – How? UML 2.0 has 13 types of diagrams divided into 2 categories We’ll only study Class Diagrams, State Machine Diagram also useful.

Let’s try DIA Be sure you’re in UML mode Use tool tips to identify buttons Select Class icon Click to place on diagram Double-click to edit details We’ll primarily use Attributes and Operations (you think of these as variables and methods) switch to UML

Class Diagram Shows system classes, attributes, relationships among classes Class diagrams are static -- they display what interacts but not what happens when they do interact. Class name at top of diagram Attributes in next section. # indicates protected, - indicates private + indicates public, ~ indicates package Methods (operations) in bottom section. + indicates public., - indicates private. Common to omit getters/setters

Another class Attributes may specify a type Class variables (i.e., static) are underlined Accessibility is indicated with +, -, # Parameters (with optional types) can be specified

Translating to code public class Student { protected String name; // type not in UML private String address; // make reasonable private String email; // assumptions public boolean isEnrolled() { return true; } // body not specified, return needed to compile } public class GamePanel { public static final int CELL_SIZE = 20; private int whoseTurn; public void drawBoard (Graphics g) { } } final is a low-level detail, no consensus on whether/how to represent in UML How do we know it’s final? Class convention of ALL_CAPS

Why are we doing this again? It’s good to think about the high-level structure of your program before you begin to code. If only two classes in your system, probably not needed. What if you have 20 interacting classes? How am I supposed to figure this out??!!

But how do these classes work together? Need to specify relationships between classes Inheritance. Also called generalization and specialization. Association. Means an instance of one class can send a message to an instance of another. Class sending the message must have access to the receiver (e.g., via a pointer, reference etc). Aggregation. Whole/part relationship. (e.g., car has 4 wheels; wheels may outlive car). May be called a “has-a” relationship. Composition. Like Aggregation except lifetime of ‘part’ must match lifetime of ‘whole’ (e.g., car has a carburetor) Dependency One class relies on another, but doesn’t contain a variable. Composition and Aggregation are types of associations; distinction is not that critical.

Inheritance in UML Called a generalization relationship General Open triangle, points to parent Specific HINT: To remember direction, think that a child has only one parent, a parent may have many children. Our diagram has only one arrow – must point to parent.

Translate to Code public class Book { private String title; private String author; } public class Textbook extends Book { private String course; public class Dictionary extends Book { private int numWords; NOTE: We do not repeat Title and Author in the child classes… instance variables are all inherited – GENERAL RULE: Don’t clutter the diagram!

Here’s an association in code public class Student { private String name; private Dog dog; public Student(String name){ dog = new Dog(); } public void takeAWalk() { dog.bark(); public class Dog { public void bark() { System.out.println("Woof"); } Note that Student has a variable of type Dog – but it does not appear in the UML as an attribute. Why? How does this help us design? Functions are put in various classes. Where does the functionality live? How can our classes work together to create a solution?

UML relationships Association. Arrow indicates navigability. Include arrow if unidirectional If no arrows, indicates bidirectional May have multiplicity (e.g., 0 .. *) May have role (e.g., subscriber)

Here’s an aggregation in code public class Car { private ArrayList<Wheel> wheels; } public class Wheel { Note the open diamond attached to the owner. We will not make the distinction between aggregation and composition – these look no different in code.

Enumerated type + code + dependency Dotted line is a dependency. Weaker association. Notice WeekendDays is a parameter, but not an attribute. public enum WeekendDays { SATURDAY, SUNDAY } public class Event { public void addParty(String name, WeekendDays day) { … } }

Abstract Classes, Interfaces and Static Abstract class and method names are normally italicized (must set the Properties -> Style in DIA) An interface is a stereotype, show inside << …>> Indicate static methods/variables with a $ or underline

Translate to Code public abstract class Shape { private int x, y; public abstract void draw(); } public interface Comparable { public int compareTo(Object o); } public class Book implements Comparable { private String title, author; public int compareTo(Object o) { …. }

Bookstore Example

Package Example Note that sometimes we just want class names – in DIA, uncheck Attributes visible and Operations visible

Another Example