12-CRS-0106 REVISED 8 FEB 2013 CSG2H3 Object Oriented Programming.

Slides:



Advertisements
Similar presentations
UML and Classes, Objects and Relationships [1]
Advertisements

Modeling Main issues: What do we want to build How do we write this down ©2008 John Wiley & Sons Ltd. vliet.
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.
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.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
UML Class Diagram and Packages
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Unified Modeling Language (UML)
Class Diagram & Object Diagram
7M822 UML Class Diagrams advanced concepts 15 September 2008.
Programming With Java ICS201 University Of Hail1 Chapter 12 UML and Patterns.
7M822 UML Class Diagrams advanced concepts 14 October 2010.
1 Object-Oriented Modeling Using UML CS 3331 Fall 2009.
© SERG Software Design (UML) Software Design Static Modeling using the Unified Modeling Language (UML) Material based on [Booch99, Rambaugh99, Jacobson99,
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
Unified Modeling Language
Object-Oriented Analysis and Design
UML Unified Modeling Language. What is UML? Unified Modeling Language (UML) is a standardized, general-purpose modeling language in the field of software.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
Software Construction Lecture 5 Class Diagrams. Agenda 2  Topics:  Examples of class diagrams  Navigation, visibility, named associations, and multiplicity.
© SERG Software Design (UML) Software Design Static Modeling using the Unified Modeling Language (UML) Material based on [Booch99, Rambaugh99, Jacobson99,
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.
12-CRS-0106 REVISED 8 FEB 2013 CSG2H3 Object Oriented Programming.
Programming in Java Unit 3. Learning outcome:  LO2:Be able to design Java solutions  LO3:Be able to implement Java solutions Assessment criteria: 
DOMAIN MODEL CLASS DIAGRAM Prepared by: Fatimah Alakeel November, 2011.
1 UML Basic Training. UML Basic training2 Agenda  Definitions: requirements, design  Basics of Unified Modeling Language 1.4  SysML.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
بسم الله الرحمن الرحيم ” اللهم أنت ربي لا إله إلا أنت خلقتني و أنا عبدك وأنا على عهدك ووعدك ما استطعت ، أعوذ بك من شر ما صنعت ، أبوء لك بنعمتك على و أبوء.
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.
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.
Software Design Software Design (UML) Static Modeling using the Unified Modeling Language (UML) Material based on [Booch99, Rambaugh99, Jacobson99, Fowler97,
An Introduction to the Unified Modeling Language
BCS 2143 Object Oriented Design Using UML. Objectives Objects Interactions Finding Classes Relationship Between Classes Attribute and Operation Class.
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
Lecture 1: UML Class Diagram September 12, UML Class Diagrams2 What is a Class Diagram? A class diagram describes the types of objects in the system.
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 5 System Modeling Sommerville, "software engineering ", 9 th Ed., 2011.
Design Model Lecture p6 T120B pavasario sem.
Object Oriented Analysis: Associations. 2 Object Oriented Modeling BUAD/American University Class Relationships u Classes have relationships between each.
Software Engineering Lecture 8 Object-Oriented Analysis.
CSE 219 Computer Science III UML. UML Diagrams UML - Unified Modeling Language UML diagrams are used to design object-oriented software systems –represent.
Class Diagram Chapter 21 Applying UML and Patterns Craig Larman.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
Association Association represents a general binary relationship that describes an activity between two classes. The relationship allows objects to call.
12-CRS-0106 REVISED 8 FEB 2013 CSG2H3 Object Oriented Programming.
12-CRS-0106 REVISED 8 FEB 2013 CSG2H3 Object Oriented Programming.
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.
© SERG Software Design Static Modeling using the Unified Modeling Language (UML) Material based on [Booch99, Rambaugh99, Jacobson99, Fowler97, Brown99]
Class Diagrams Revisited. Parameterized Classes Parameterized Classes - are used to represent relationships between templates.
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.
12-CRS-0106 REVISED 8 FEB 2013 CSG2H3 Object Oriented Programming.
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.
Unified Modeling Language (UML)
COMP 2710 Software Construction Class Diagrams
Lec-4 : Unified Modeling Language (UML)
Unified Modeling Language
Main issues: • What do we want to build • How do we write this down
Unified Modeling Language (UML)
Introduction to UML Introduction to UML Shiyuan Jin September,23,2002
UML Class Diagrams: Basic Concepts
Object Oriented Analysis and Design
UML Class Diagram.
Understand and Use Object Oriented Methods
Class Diagram.
Static Modeling using the Unified Modeling Language (UML)
Object Oriented System Design Class Diagrams
Presentation transcript:

12-CRS-0106 REVISED 8 FEB 2013 CSG2H3 Object Oriented Programming

12-CRS-0106 REVISED 8 FEB 2013 Unified Modeling Language Unified Modeling Language (UML) is a standardized general-purpose modeling language in the field of software engineering. The standard is managed, and was created by, the Object Management Group. UML includes a set of graphic notation techniques to create visual models of software-intensive systems.

12-CRS-0106 REVISED 8 FEB 2013 What is UML? And why we use UML? Language: express idea, not a methodology Modeling: Describing a software system at a high level of abstraction Unified: UML has become a world standard –Object Management Group (OMG):

12-CRS-0106 REVISED 8 FEB 2013 Class A class is a description of a set of objects that share the same attributes, operations, relationships, and semantics. ClassName attributes operations

12-CRS-0106 REVISED 8 FEB 2013 ClassName 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. Person attributes operations

12-CRS-0106 REVISED 8 FEB 2013 Class Attributes An attribute is a named property of a class that describes the object being modeled. In the class diagram, attributes appear in the second compartment just below the name-compartment. Attributes are usually listed in the form: attributeName : Type Person name : String address : String birthdate : Date Id : integer operations

12-CRS-0106 REVISED 8 FEB 2013 Class Attributes Attributes can be: + (public) # (protected) - (private) Normally use private for field Person + name: String # address: String - birthdate: Date age : integer - id: integer operations

12-CRS-0106 REVISED 8 FEB 2013 Class Attributes A derived attribute is one that can be computed from other attributes, but doesn’t actually exist. For example, a Person’s age can be computed from his birth date. A derived attribute is designated by a preceding ‘/’ as in: / age : Date Person - name: String - address: String - birthdate: Date / age : integer - id: integer operations

12-CRS-0106 REVISED 8 FEB 2013 Class Operations Operations describe the class behavior and appear in the third compartment You can specify an operation by stating its signature: –listing the name, type, and default value of all parameters, and, in the case of functions, a return type. Person - name: String - address: String - birthdate: Date / age : integer - id: integer eat(food : String) sleep(hour : int) work() : String play()

12-CRS-0106 REVISED 8 FEB 2013 Depicting Classes When drawing a class, you needn’t show attributes and operation in every diagram Person name : String birthdate : Date ssn : Id eat() sleep() work() play() Person name address birthdate Person eat play Person

12-CRS-0106 REVISED 8 FEB 2013 Question?

12-CRS-0106 REVISED 8 FEB 2013 CSG2H3 Object Oriented Programming

12-CRS-0106 REVISED 8 FEB 2013 Class Association

12-CRS-0106 REVISED 8 FEB 2013 Basic Relationship Association Aggregation Composition

12-CRS-0106 REVISED 8 FEB 2013 Association

12-CRS-0106 REVISED 8 FEB 2013 If two classes in a model need to communicate with each other, there must be link between them. An association denotes that link. An association between two classes indicates that objects at one end of an association “recognize” objects at the other end and may send messages to them. Association Relationships Instructor Student

12-CRS-0106 REVISED 8 FEB 2013 Example public class Student{ private String name; private String assignment; public Student(String name){ this.name = name; } public void setName(String name){ this.name = name; } public String getName(){ return name; } public void setAssignment(String assignment){ this.assignment = assignment; } public String getAssignment(){ return assignment; }

12-CRS-0106 REVISED 8 FEB 2013 Example public class Instructor{ private String name; public Instructor(String name){ this.name = name; } public void giveAssignment(Student s, String assignment){ s.setAssignment(assignment); } public class Driver{ public static void main(String args[]){ Student s1 = new Student("andi"); Instructor i1 = new Instructor("budi"); i1.giveAssignment(s1,"code java OOP"); System.out.println(s1.getAssignment()); }

12-CRS-0106 REVISED 8 FEB Association Relationships Message passing –Object sends data to another object Method calling –Use or ask the object to invoke a method

12-CRS-0106 REVISED 8 FEB 2013 We can indicate the multiplicity of an association by adding multiplicity adornments to the line denoting the association. The example indicates that a Student has one or more Instructors: Association Relationships Instructor Student 1..*

12-CRS-0106 REVISED 8 FEB 2013 The example indicates that every Instructor has one or more Students: Association Relationships Instructor Student 1..*

12-CRS-0106 REVISED 8 FEB 2013 We can also indicate the behavior of an object in an association (i.e., the role of an object) using role names. Association Relationships Instructor Student 1..* learns fromteaches

12-CRS-0106 REVISED 8 FEB 2013 We can also name the association. Association Relationships Team Student membership 1..*

12-CRS-0106 REVISED 8 FEB 2013 We can specify dual associations. Association Relationships Team Student member of 1..* president of11..*

12-CRS-0106 REVISED 8 FEB 2013 We can constrain the association relationship by defining the navigability of the association. –Here, a Router object requests services from a DNS object by sending messages to (invoking the operations of) the server. –The direction of the association indicates that the server has no knowledge of the Router. Association Relationships Router DomainNameServer

12-CRS-0106 REVISED 8 FEB 2013 Associations can also be objects themselves, called link classes or an association classes. Association Relationships Warranty ProductRegistration modelNumber serialNumber warrentyCode

12-CRS-0106 REVISED 8 FEB 2013 A class can have a self association. Association Relationships LinkedListNode next previous

12-CRS-0106 REVISED 8 FEB 2013 Aggregation

12-CRS-0106 REVISED 8 FEB 2013 We can model objects that contain other objects by way of special associations called aggregations and compositions. An aggregation specifies a whole-part relationship between an aggregate (a whole) and a constituent part, where the part can exist independently from the aggregate. Aggregation Relationships

12-CRS-0106 REVISED 8 FEB 2013 Aggregation is a variant of the "has a" or association relationship. Aggregations are denoted by a hollow-diamond adornment on the association. Aggregation Relationships Car EngineTransmission

12-CRS-0106 REVISED 8 FEB 2013 Example public class Engine { private String name; private int horsePower; public Engine(String name){ this.name = name; } public int getHorsePower() { return horsePower; } public void setHorsePower(int hp) { this.horsePower = hp; } public class Transmission { private String type; public String getType() { return type; } public void setType(String type) { this.type = type; }

12-CRS-0106 REVISED 8 FEB 2013 Example public class Car { private String name; private Engine engine; private Transmission transmission; public Car(String name){ this.name = name; } public void addEngine(Engine e){ engine = e; } public void addTransmission(Transmission t){ transmission = t; }

12-CRS-0106 REVISED 8 FEB 2013 Example public class Driver { public static void main(String[] args) { Car c = new Car("honda"); Engine v1000 = new Engine("v1000"); Transmisson auto = new Transmisson(); auto.setType("Automatic"); c.addEngine(v1000); c.addTransmission(auto); }

12-CRS-0106 REVISED 8 FEB 2013 Composition

12-CRS-0106 REVISED 8 FEB 2013 Composition is a stronger variant of the "owns a" or association relationship A composition indicates a strong ownership and coincident lifetime of parts by the whole (i.e., they live and die as a whole). Composition Relationships

12-CRS-0106 REVISED 8 FEB 2013 Compositions are denoted by a filled-diamond adornment on the association. Composition Relationships Window ScrollbarTitlebarMenu *

12-CRS-0106 REVISED 8 FEB 2013 Example public class Scrollbar { public String type; public Scrollbar(String type){ this.type = type; } public class Titlebar { public String title; public Titlebar(String title){ this.title = title; } public class Menu { private String title; private String type; public Menu(String title, String type){ this.title = title; this.type = type; }

12-CRS-0106 REVISED 8 FEB 2013 Example public class Window { private Scrollbar scBar; private Titlebar tlBar; private Menu[] menu; public Window(String title, String scrollType, int numMenu){ scBar = new Scrollbar(scrollType); tlBar = new Titlebar(title); menu = new Menu[numMenu]; } public class Driver { public static void main(String[] args) { Window w = new Window("OOP Window", "vertical", 5); }

12-CRS-0106 REVISED 8 FEB 2013 A person and a car that he wants to buy A car in a parking lot A mall and its basement Wheels in a car A department and a company A department and an employee A canteen and a department A pond and fishes Example Specify the appropriate relation to each case:

12-CRS-0106 REVISED 8 FEB 2013 Question?

12-CRS-0106 REVISED 8 FEB 2013 THANK YOU Credits M usic : Yonezawa Madoka - Oui! Ai Kotoba (Instrumental)