Unified Modeling Language (UML)

Slides:



Advertisements
Similar presentations
Based on Java Software Development, 5th Ed. By Lewis &Loftus
Advertisements

Chapter 2: Using Objects Part 1. To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about.
Written by: Dr. JJ Shepherd
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.
UML Class and Sequence Diagrams Violet Slides adapted from Marty Stepp, CSE 403, Winter 2012 CSE 403 Spring 2012 Anton Osobov.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Defining Your Own Classes.
The Unified Software Development Process - Workflows Ivar Jacobson, Grady Booch, James Rumbaugh Addison Wesley, 1999.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Defining Your Own Classes.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Defining Your Own Classes.
ACM/JETT Workshop - August 4-5, 2005 UML Modeling using MagicDraw UML for Java Programmers.
1 CSE 403 Design and UML Class Diagrams Reading: UML Distilled Ch. 3, by M. Fowler These lecture slides are copyright (C) Marty Stepp, They may not.
1 TCSS 360, Spring 2005 Lecture Notes Design Phase and UML Class Diagrams Relevant Reading: UML Distilled, Third Edition M. Fowler.
UML January 24, 2011 CSE 403, Winter 2011, Brun Design and UML Class Diagrams.
Unified Modeling Language
Ranga Rodrigo. Class is central to object oriented programming.
Object Oriented Software Development
Introduction to Object Oriented Design. Topics Designing Your Own Classes Attributes and Behaviors Class Diagrams.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Writing Classes (Chapter 4)
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
CSC 212 Object-Oriented Programming and Java Part 1.
Java Classes Using Java Classes Introduction to UML.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Introduction to Object Oriented Design Version 1.1.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
UML Review – class diagrams SE 2030 Dr. Rob Hasker 1 Based on slides written by Dr. Mark L. Hornick Used with permission.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
Introduction to UML: Unified Modeling Language Ric Holt U Waterloo, March 2009 CS246.
Centre for Computer Technology ICT214 Object Oriented Design and Programming Week 02 – Classes, Objects, Instances Richard Salomon and Umesh Patel Centre.
Fall 2010 CS4310 Requirements Engineering A Brief Review of UML & OO Dr. Guoqiang Hu Department of Computer Science UTEP 1.
UML Class Diagrams 1 These lecture slides are copyright (C) Marty Stepp, They may not be rehosted, sold, or modified without expressed permission.
Object-Oriented Paradigm and UML1 Introduction to the Object- Oriented Paradigm.
JAVA Classes Review. Definitions Class – a description of the attributes and behavior of a set of computational objects Constructor – a method that is.
Designing Classes Chapter 3. 2 Chapter Contents Encapsulation Specifying Methods Java Interfaces Writing an Interface Implementing an Interface An Interface.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
SE-1010 Dr. Mark L. Hornick 1 Java Programming Basics.
CSE 403, Spring 2008, Alverson Using UML to express Software Architecture.
CSE 403, Spring 2007, Alverson Using UML to express Software Architecture.
1 Class Diagrams. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are for visualizing, specifying and documenting.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Written by: Dr. JJ Shepherd
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
Object Oriented Programming and Data Abstraction Earl Huff Rowan University.
Copyright 2006 Pearson Addison-Wesley, 2008, 2012 Joey Paquet 1 Concordia University Department of Computer Science and Software Engineering SOEN6441 –
CS100Lecture 61 Announcements Homework P1 due on Thursday Homework P2 handed out.
ENCAPSULATION. WHY ENCAPSULATE? So far, the objects we have designed have all of their methods and variables visible to any part of the program that has.
UML Review – class diagrams SE-2030 Dr. Mark L. Hornick 1.
COP 3330 Notes 4/13. Today’s Topics UML Class Diagrams.
UNIT-IV Designing Classes – Access Layer ‐ Object Storage ‐ Object Interoperability.
Design and UML Class Diagrams
TCSS 305 (Stepp) OO Design with UML Class Diagrams
Introduction to OOP and UML
Unified Modeling Language
Object-Oriented Analysis and Design
Lecture on Design Phase and UML Class Diagrams
University of Central Florida COP 3330 Object Oriented Programming
Chapter 5 Classes.
CompSci 230 Software Construction
Chapter 4: Writing Classes
Inheritance "Question: What is the object oriented way of getting rich? Answer: Inheritance.“ “Inheritance is new code that reuses old code. Polymorphism.
Unified Modelling Language
Software Engineering System Modeling Extra examples Dr.Doaa Sami
Algorithms and Problem Solving
Outline Anatomy of a Class Encapsulation Anatomy of a Method
Introduction to UML Sources:
CIS 375 Bruce R. Maxim UM-Dearborn
Presentation transcript:

Unified Modeling Language (UML) AP Java Unified Modeling Language (UML)

Be able to model a single class using Unified Modeling Language (UML) Learning Objectives Be able to model a single class using Unified Modeling Language (UML) Use a UML diagram to help create a class.

Big questions What is UML? What is a UML class diagram? Why should I bother? Do people really use UML? What is a UML class diagram? What kind of information goes into it? How do I create it? When should I create it?

Design phase design: specifying the structure of how a software system will be written and function, without actually writing the complete implementation a transition from "what" the system must do, to "how" the system will do it What classes will we need to implement a system that meets our requirements? What fields and methods will each class have? How will the classes interact with each other?

How do we design classes? class identification from project spec / requirements nouns are potential classes, objects, fields verbs are potential methods or responsibilities of a class UML diagrams class diagrams (today) sequence diagrams ...

Introduction to UML UML: pictures of an Object Oriented (OO) system programming languages are not abstract enough for OO design UML is an open standard; lots of companies use it What is legal UML? a descriptive language: rigid formal syntax (like programming) a prescriptive language: shaped by usage and convention it's okay to omit things from UML diagrams if they aren't needed by team/supervisor/instructor

Uses for UML as a sketch: to communicate aspects of system forward design: doing UML before coding backward design: doing UML after coding as documentation often done on whiteboard or paper used to get rough selective ideas as a blueprint: a complete design to be implemented sometimes done with CASE (Computer-Aided Software Engineering) tools as a programming language: with the right tools, code can be auto-generated and executed from UML only good if this is faster than coding in a "real" language

UML class diagrams What is a UML class diagram? UML class diagram: a picture of the classes in an OO system, their fields and methods, and connections between the classes that interact or inherit from each other What are some things that are not represented in a UML class diagram? details of how the classes interact with each other algorithmic details; how a particular behavior is implemented

Diagram of one class class name in top of box attributes (Instance Variables) should include all fields of the object operations / methods may omit trivial (get/set) methods but don't omit any methods from an interface! should not include inherited methods

Class attributes/Variables attributes (fields, instance variables) visibility name : type [count] = default_value visibility: + public (all) # protected (family) - private (me) ~ package (default/Folder) / derived underline static attributes/class variables derived attribute: not stored, but can be computed from other attribute values attribute example: - balance : double = 0.00

Class operations / methods visibility name (parameters) : return_type visibility: + public # protected - private ~ package (default) underline static methods parameter types listed as (name: type) omit return_type on constructors and when return type is void method example: + distance(p1: Point, p2: Point): double

Practice: In your notes… Create a UML Diagram for a Fraction class Default Constructor Constructor given integer numerator/denominator Multiply by a Fraction object and return the product as a Fraction object Add to a Fraction object and return the sum as a Fraction object. toString. Return a String representation of the object.

Using the UML To Help with a Free Response Question In the next section you will create a UML Diagram for the Quiz Question Then we will go over creating the class as a class. Read over the Question and Create a UML diagram for the TextFormatter class.

Part A private int findString(String str,int start) Hands On: line = “aabaccb” Pseudo Code Find first occurrence of str in line (position). While there is an occurrence of str in line If it is a single occurrence (not a duplicate) Return this position Else //If it matches the letter before and/or after Find the next occurrence of str in line Return -1 (No single occurrences) Checking for Single Occurrence If it is the first letter (position = 0) check to make sure it does not match the next letter. Else If it is the last letter (position =line.length() -1) Check to make sure it does not match the previous letter. Else Check to make sure it does not match the previous or next letter TextFormatter - line : String + TestFormatter(lineToFormat:String) findString( str: String, start:int):int countStrings(str:String): int

Problem A More Refined Pseudo Code Find first occurrence of str in line (position). While there is an occurrence of str in line If it is the first letter (position = 0) if it does not match the next letter. Return this position Else If it is the last letter (position =line.length() -1) If it does not match the previous letter. Else //if it is not the first or last position in line If it does not match the previous or next letter Else //If it matches the letter before and/or after Find the next occurrence of str in line Return -1 (No single occurrences)

Modify the following Driver Class for Testing

Part b: countStrings This method will be sent a single character string (str) and will count the number of times single instances of the goal string appears in the String line.

Part b Pseudo Code Start a position 0 and count 0 While there is str in line from position Add to the count add one to position Return the count

Part c: convertItalics() If there are an even number of “_” then for each pair of “_” replace “<I>” marking the beginning of a section of “_” “</I>” marking the end of a section Returning the converted String

Pseudo Code If there are an odd number of “_” then Return the original ‘line’ Make a temporary String (answer) to add the modified String Make front and back variables for copying the parts of line into answer String For each pair of “_” Replace the first “_” with “<I>” Set back to findString(“_”, front) Add string from front to back and “<I>” to answer Set front to back + 1 Replace the second with “</I>” Add string from front to back and “</I>” to answer Add the rest of the String to the answer Return answer

Assignment Complete the TextFormatter class and driver class to test it.