Programming With Java ICS201 University Of Hail1 Chapter 12 UML and Patterns.

Slides:



Advertisements
Similar presentations
Module 8 “Polymorphism and Inheritance”. Outline Understanding Inheritance Inheritance Diagrams Constructors in Derived Classes Type Compatibility Polymorphism.
Advertisements

Object-Oriented Analysis and Design CHAPTERS 15: UML INTERACTION DIAGRAMS 1.
CIT731: Database Development Object Oriented Modeling (OOM)
Object-Oriented Application Development Using VB.NET 1 Chapter 5 Object-Oriented Analysis and Design.
7M822 UML Class Diagrams 7 October 2010.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 8 Slide 1 System modeling 2.
Inheritance Inheritance Reserved word protected Reserved word super
UML Class and Sequence Diagrams Violet Slides adapted from Marty Stepp, CSE 403, Winter 2012 CSE 403 Spring 2012 Anton Osobov.
Informatics 43 – May 7, Restatement of Goals for Testing Want to verify software’s correctness  Need to test  Need to decide on test cases  No.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
1 Chapter 7 l Inheritance Basics l Programming with Inheritance l Dynamic Binding and Polymorphism Inheritance.
25-Jun-15 Starting Classes and Methods. Objects have behaviors In old style programming, you had: data, which was completely passive functions, which.
Chapter Chapter 1 Introduction to Object-Oriented Programming and Software Development.
© 2003 Walter Savitch These slides are for the exclusive use of students in CSE 11 at UCSD, Winter quarter They may not be copied or used for any.
UML a crash course Alex Lo Brian Kiefer. Overview Classes Class Relationships Interfaces Objects States Worksheet.
Unit 221 UML Back Ground Class Diagrams Inheritance Hierarchy UML Patterns.
Chapter 10: Inheritance 1. Inheritance  Inheritance allows a software developer to derive a new class from an existing one  The existing class is called.
Unified Modeling Language
UML for Java Programmers Object Mentor, Inc. Copyright  by Object Mentor, Inc All Rights Reserved
UML Basics & Access Modifier
Chapter 12 UML and Patterns.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 1 Introduction to Object-Oriented Programming and.
1 Announcements Research Paper due Friday November 19 For Wednesday read
12-CRS-0106 REVISED 8 FEB 2013 CSG2H3 Object Oriented Programming.
Object-Oriented Analysis and Design An Introduction.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Chapter 8. About the Midterm Exam.. Exam on March 12 Monday (Tentatively) Review on March 7 Wednesday Cover from Chapter 6 Grades will be out before spring.
1 UML Basic Training. UML Basic training2 Agenda  Definitions: requirements, design  Basics of Unified Modeling Language 1.4  SysML.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Topic 5 Introduction to UML Diagrams. 1-2 Objectives To introduce UML Diagrams A diagrammatic way of showing the relationships among classes This will.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Modeling system requirements. Purpose of Models Models help an analyst clarify and refine a design. Models help simplify the complexity of information.
Software Design Software Design (UML) Static Modeling using the Unified Modeling Language (UML) Material based on [Booch99, Rambaugh99, Jacobson99, Fowler97,
UML (U NIFIED M ODELING LANGUAGE ) Prepared by Miss Simab Shahid Lecturer computer Science and Software Engineering department, University.
Designing Classes Chapter 3. 2 Chapter Contents Encapsulation Specifying Methods Java Interfaces Writing an Interface Implementing an Interface An Interface.
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 8 Inheritance. 2  Review of class relationships  Uses – One class uses the services of another class, either by making objects of that class.
CSE 219 Computer Science III UML. UML Diagrams UML - Unified Modeling Language UML diagrams are used to design object-oriented software systems –represent.
Chapter 12 UML and Patterns Slides prepared by Rose Williams, Binghamton University Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Class Diagram Chapter 21 Applying UML and Patterns Craig Larman.
UML Part 1: Class Diagrams. Introduction UML stands for Unified Modeling Language. It represents a unification of the concepts and notations presented.
Programming With Java ICS201 University Of Hail1 Chapter 12 UML and Patterns.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Object-Oriented Programming (OOP) What we did was: (Procedural Programming) a logical procedure that takes input data, processes it, and produces output.
Object Modeling THETOPPERSWAY.COM. Object Modelling Technique(OMT)  Building a model of an application domain and then adding implementation.
Sub-Phase Low Level Design (cont)
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
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.
© 2004 Pearson Addison-Wesley. All rights reserved April 10, 2006 Inheritance (part 2) ComS 207: Programming I (in Java) Iowa State University, SPRING.
Unified Modeling Language (UML)
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
A means of graphically displaying a complicated programs 18-Mar-16 UML Thanks to Dave Matuczek, UPenn.
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.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley The Unified Modeling Language
Informatics 43 – May 5, Restatement of Goals for Testing Want to verify software’s correctness  Need to test  Need to decide on test cases  No.
CSCI 51 Introduction to Programming Dr. Joshua Stough February 26, 2009.
CS16: UML’s Unified Modeling Language. UML Class Diagram A UML class diagram is a graphical tool that can aid in the design of a class. The diagram has.
CS 350 – Software Design UML – The Unified Modeling Language – Chapter 2 The Unified Modeling Language is a visual language used to create models of programs.
Inheritance Chapter 7 Inheritance Basics Programming with Inheritance
Lec-4 : Unified Modeling Language (UML)
Unified Modeling Language
Advanced Programming in Java
Inheritance Chapter 7 Inheritance Basics Programming with Inheritance
Chapter 12 UML and Patterns
Chapter 12 UML and Patterns
Inheritance Chapter 7 Inheritance Basics Programming with Inheritance
Inheritance Chapter 7 Inheritance Basics Programming with Inheritance
Class Diagram.
2.1 Introduction to Object-Oriented Programming
Presentation transcript:

Programming With Java ICS201 University Of Hail1 Chapter 12 UML and Patterns

Programming With Java ICS201 University Of Hail2 Introduction to UML oUML (Unified Modeling Language) is a graphical language used for designing and documenting OOP software. oUML is a software design tools that can be used within the context of any OOP (Object-Oriented programming) language.

Programming With Java ICS201 University Of Hail3 UML oPseudocode is a way of representing a program in a linear and algebraic manner.  It simplifies design by eliminating the details of programming language syntax. oGraphical representation systems for program design have also been used:  Flowcharts and structure diagrams for example. oUnified Modeling Language (UML) is yet another graphical representation formalism.  UML is designed to reflect and be used with the OOP philosophy.

Programming With Java ICS201 Types of UML Diagrams Use Case Diagram Class Diagram Sequence Diagram Collaboration Diagram State Diagram ….

Programming With Java ICS201 5 Classes A class is simply represented as a box with the name of the class inside –The diagram may also show the attributes and operations –The complete signature of an operation is: operationName(parameterName: parameterType …): returnType Rectangle height width getArea resize Rectangle height width Rectangle getArea resize Rectangle height: int width: int getArea(): int resize(int,int)

Programming With Java ICS201 University Of Hail6 UML Class Diagram oA class diagram is divided up into three sections: 1.The top section contains the class name. 2.The middle section contains the data specification for the class (attributes). 3.The bottom section contains the actions or methods of the class (operations). ClassName attributes operations

Programming With Java ICS201 Class Names ClassName attributes operations The name of the class is the only required tag in the graphical representation of a class. It always appears in the top-most compartment.

Programming With Java ICS201 Software Design (UML) Class Attributes (Cont’d) Person + name : String # address : Address # birthdate : Date / age : Date - ssn : Id Attributes can be: + public # protected - private / derived Attributes are usually listed in the form: attributeName : Type A derived attribute is one that can be computed from other attributes. For example, a Person’s age can be computed from his birth date. / age : Date

Programming With Java ICS201 Software Design (UML) Class Operations Person name : String address : Address birthdate : Date ssn : Id eat sleep work play Operations describe the class behavior and appear in the third compartment. oEach method in a UML diagram is indicated by the name of the method, followed by its parameter list, a colon (:), and its returned type.

Programming With Java ICS201 University Of Hail10 UML Class Diagram oA class diagram need not give a complete description of the class. oIf a given analysis does not require that all the class members be represented, then those members are not listed in the class diagram. oMissing members are indicated with an ellipsis (three dots).

Programming With Java ICS201 University Of Hail11 Example (UML Class Diagram) Square - Side : double - xCoordinate : double - yCoordinate : double + resize (double newSide) : void + move (double newx, double newy ) : void # erase ( ) : void … attributes Class methods Class name

Programming With Java ICS201 University Of Hail12 Inheritance Diagrams ( Generalization) oAn inheritance diagram shows the relationship between a base class and its derived class(es).  Normally, only as much of the class diagram is shown as is needed.  Note that each derived class may serve as the base class of its derived class(es). oEach base class is drawn above its derived class(es)  An upward pointing arrow is drawn between them to indicate the inheritance relationship.

Programming With Java ICS201 University Of Hail13 Inheritance Diagrams oThe arrows also help in locating method definitions. oTo look for a method definition for a class:  Examine the class definition first.  If the method is not found, the path of connecting arrows will show the order and direction in which to search.  Examine the parent class indicated by the connecting arrow.  If the method is still not found, then examine this parent's parent class indicated by the connecting arrow.  Continue until the method is found, or until the top base class is reached.

Programming With Java ICS201 University Of Hail14 A Class Hierarchy in UML Notation StudentEmployee StaffUndergraduate Person GraduateFaculty Arrows go from a derived class to its base class.

Programming With Java ICS201 University Of Hail15 Some Details of a Class Hierarchy + setName(String newName): void + getName( ): String + toString( ): String + sameName(Person otherPerson): boolean - name: String Person + set(String newName, int newStudentNumber): void + getStudentNumber( ): int + setStudentNumber(int newStudentNumber ): void + toString( ): String + equals(Object otherObject): boolean - studentNumber: int Student

Programming With Java ICS201 Example Consider the class named Book that contains: –A private String variable called title; –A private integer variable called nbpages; –A public double variable called price ; –Two public methods SetTitle() and SetNbpages(); –Two public methods getTitle() and getNbpages(); Class TextBook is a derived class from the class Book. It contains: –A protected integer variable called gradeLevel; –A public method toString() that returns a description of a textBook; –A public method PriceAfterDiscount() that returns the price of a book after applying a discount of 10%. Question: Establish the UML diagram for this problem.

Programming With Java ICS201 Book - title : String - nbpages : int + price : double + SetTitle (String t) : void + SetNbpages (int nb) : void + getTitle ( ) : String + getNbpages ( ) : int TextBook # gradeLevel : int + toString ( ) : String + PriceAfterDiscount() : double