Object Oriented Software Development 2009-2010 Class diagrams: Towards implementation OOSAD Booklet Chapter 4 Seminar: Week 4 Brian Farrimond.

Slides:



Advertisements
Similar presentations
1 CIS224 Software Projects: Software Engineering and Research Methods Lecture 9 Object, Package, Component and Deployment Diagrams (Based on Fowler, 2004,
Advertisements

Object-Oriented Analysis and Design CHAPTERS 15: UML INTERACTION DIAGRAMS 1.
Stereotypes Stereotypes provide the capability to create a new kind of modeling element. –They can be used to classify or mark modeling elements. –A type.
Abstract Data Types Data abstraction, or abstract data types, is a programming methodology where one defines not only the data structure to be used, but.
Object-Oriented Analysis and Design
Software Engineering COMP 201
Road Map Introduction to object oriented programming. Classes
University of British Columbia CPSC 111, Intro to Computation 2009W2: Jan-Apr 2010 Tamara Munzner 1 More Class Design Lecture 11, Fri Jan
1 CS 426 Senior Projects Chapter 9: Relationships Chapter 10: Inheritance and Polymorphism [Arlow and Neustadt, 2005] February 12, 2009.
© 2005 Prentice Hall8-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
Essentials of interaction diagrams Lecture Outline Collaborations Interaction on collaboration diagrams Sequence diagrams Messages from an object.
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
1 CS 426 Senior Projects Chapter 9: Relationships Chapter 10: Inheritance and Polymorphism [Arlow and Neustadt, 2002] February 27, 2007.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Object Oriented Software Development Modelling information systems OOSAD Booklet Chapter 4 Lecture: Week 3 Brian Farrimond.
Object Oriented Software Development Systems and Models Seminar: Week 1 Brian Farrimond.
CS 2511 Fall Features of Object Oriented Technology  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance.
Week 3 Recap CSE 115 – Spring Constructor Special capability of a class that sets up the initial state of the object. Constructor definitions are.
Object Oriented Software Development Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond.
Unified Modeling Language
Object-Oriented Analysis and Design
Relationships. In the Interaction diagrams, we began to look at how classes communicate with one another. Now, we'll focus on the relationships between.
UML for Java Programmers Object Mentor, Inc. Copyright  by Object Mentor, Inc All Rights Reserved
Object Oriented Software Development
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.
Classes and Class Members Chapter 3. 3 Public Interface Contract between class and its clients to fulfill certain responsibilities The client is an object.
UML Collaboration Diagram. Recap System Sequence Diagrams (SSD) UML for SSD Examples.
BCS 2143 Introduction to Object Oriented and Software Development.
Writing Classes (Chapter 4)
Chapter 5 - Writing a Problem Domain Class Definition1 Chapter 5 Writing a Problem Domain Class Definition.
Program Guide v25Q3. Overview » Concepts » Workflow  Press sheet  Linking product  Program guide  Publishing a program guide day » Layout configuration.
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.
1 SAD2 - UML 4 th Lecture Class Diagram in Construction Phase Patterns Case Study Lecturer: Dr Dimitrios Makris
Introduction to Object Oriented Design Version 1.1.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
CET203 SOFTWARE DEVELOPMENT Session 1A Revision of Classes.
Systems Analysis and Design in a Changing World, 3rd Edition
Chapter 16 Applying UML and Patterns Craig Larman
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
NJIT UML Class Diagrams Chapter 16 Applying UML and Patterns Craig Larman.
Dale Roberts Object Oriented Programming using Java - OOD to OOP: ATM Case Study Dale Roberts, Lecturer Computer Science, IUPUI
2007ACS-3913 Ron McFadyen1 Class Diagram See Schaum’s UML Outline, especially chapters 4, 5, 6, 7.
4-1 Topic 6 Linked Data Structures. 4-2 Objectives Describe linked structures Compare linked structures to array- based structures Explore the techniques.
More on Inheritance Chapter 11 Continued. Reminders Overloading – different signatures Overriding – same signatures Preventing overriding – use final.
Chapter 10 Classes and Objects In-Depth. Chapter 10 A class provides the foundation for creating specific objects, each of which shares the general attributes,
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Chapter 10: Introduction to Inheritance. Objectives Learn about the concept of inheritance Extend classes Override superclass methods Call constructors.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
McGraw-Hill/Irwin© 2008 The McGraw-Hill Companies, All Rights Reserved Chapter 17 Object-Oriented Design and Modeling Using the UML.
BTS430 Systems Analysis and Design using UML Design Class Diagrams (ref=chapter 16 of Applying UML and Patterns)
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Chapter 9: Relationships Chapter 10: Inheritance and Polymorphism [Arlow and Neustadt, 2005] CS 426 Senior Projects in Computer Science University of Nevada,
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Object Based Programming Chapter 8. 2 Contrast ____________________ Languages –Action oriented –Concentrate on writing ________________ –Data supports.
Object-Orientated Analysis, Design and Programming
Unified Modeling Language
Chapter 3: Using Methods, Classes, and Objects
The Object Oriented Approach to Design
Introduction to Classes and Objects
CS 426 Senior Projects Chapter 9: Relationships
C# Event Processing Model
Defining Your Own Classes Part 1
Requirements To Design In This Iteration
Corresponds with Chapter 7
CSCI 1260 – Lecture 2: Instantiation, Aggregation, and Composition
IMAT5205 Systems Analysis and Design
Object-Oriented Programming Using C++ Second Edition
SPL – PS3 C++ Classes.
Presentation transcript:

Object Oriented Software Development Class diagrams: Towards implementation OOSAD Booklet Chapter 4 Seminar: Week 4 Brian Farrimond

2 Session Topics Object diagrams – snapshots for before and after Role names Implementing classes in Java Implementing associations

3 Object diagram Object diagrams represent actual objects and the links between them They give useful snapshots of the state of the system to help understand what changes to the system the functionality will cause

4 Class diagram

5 Object diagram

6 Object diagram after Fred borrows “Sing with Bing”

7 What has happened between the two object diagrams A new LP object with name A416 has been created and given the attribute value “Sing with Bing”. This new object has been linked to the Fred object.

8 What has happened between the two object diagrams A new LP object with name A416 has been created and given the attribute value “Sing with Bing”. This new object has been linked to the Fred object... This is what the code for borrowing an LP must achieve

9 Object diagrams Objects are connected by links A link is an instance of an association just like an object is an instance of a class

10 Using role names Role names are an alternative to association names More useful when we come to implementation

11 Using role names

12 Using role names If only one association between two classes then some UML authors permit the role names to be omitted The convention is that if role name omitted then a default role name is the name of the class at this end of the association

13 Using role names If only one association between role names then some UML authors permit the role names to be omitted The convention is that if role name omitted then a default role name is the name of the class at the this end of the association

14 Using role names Exercise 4.2 on Page 56

15 Using role names Exercise 4.2 on Page 56

16 Attributes and operations in class diagrams - reminder Three layered cake Class name Attribute list Operations list

17 Attributes and operations in class diagrams - reminder Things we miss out Attributes to indicate association with other classes in the diagram … Because … the association line provides that information already so we avoid clutter by avoiding duplication

18 Attributes and operations in class diagrams - reminder Things we miss out Operations to set and retrieve attribute values … Because … we can take those for granted and so save clutter

19 Implementing the Member class in Java We leave implementation in C++ until later in the module – it needs knowledge of pointers - scary Java hides the presence of pointers from us. It was one of the design goals of the creators of Java

20 Implementing the Member class in Java

21 Implementing the Member class in Java Attributes -> Java fields Operations -> Java methods

22 Implementing the Member class in Java Keywords private: fields not visible outside the class – need messages to access them

23 Implementing the Member class in Java Keywords public: the class and the methods can be used outside

24 Implementing associations in Java

25 Implementing associations in Java With role names:

26 Implementing associations in Java With role names: public class Ambulance { private Crew[] crew; : public class Crew { private Ambulance ambulance; :

27 Implementing associations in Java With role names: public class Ambulance { private Crew[] crew; : public class Crew { private Ambulance ambulance; : An array since there is more than one crew in each ambulance

28 Sending messages between objects Class diagrams record the way messages can pass between objects AB CD

29 Sending messages between objects In this diagram messages can be sent: between A and B between A and D between B and C AB CD

30 Sending messages between objects In this diagram messages can be sent: between A and B between A and D between B and C AB CD

31 Sending messages between objects In this diagram messages can be sent: between A and B between A and D between B and C AB CD

32 Sending messages between objects To send a message from A to C we must send a message to B that causes B to send a message to C AB CD

33 Sending messages between objects To send a message from A to C we must send a message to B that causes B to send a message to C AB CD

34 Sending messages between objects To send a message from A to C we must send a message to B that causes B to send a message to C AB CD

35 public class Ambulance { private Crew[] crew; : crew[1].doThis(); public class Crew { private Ambulance ambulance; : public void doThis() { } Sending messages between objects doThis() Sending the message Method to handle message

36 public class Ambulance { private Crew[] crew; : public void doThat(){ } public class Crew { private Ambulance ambulance; : ambulance. doThat() ; Sending messages between objects doThat() Sending the message Method to handle message

37 Navigation If we know that messages only travel one way along an association we can modify the class diagram to indicate this …

38 Navigation If we know that messages only travel one way along an association we can modify the class diagram to indicate this …

39 Navigation If we know that messages only travel one way along an association we can modify the class diagram to indicate this … Arrow head indicates direction of messages

40 public class Ambulance { private Crew[] crew; : public class Crew { : No attribute needed for Ambulance since we are not sending messages from here to the “owning” Ambulance Navigation

41 If a class diagram shows no arrowheads than assume the navigation is both ways If any arrow heads are present then the only navigability allowed is that indicated by the arrow heads Navigation

42 Summary Object diagrams provide snapshots for before and after Role names are an alternative to association names Attributes and operations can be recorded in class diagrams We can implement classes in Java We can implement associations in Java taking into account navigability

43 Exercises Ex 4.4 page 67 Ex 4.5 page 67 Ex 4.6 page 68