Module UFC016QM Object-Oriented Design and Programming Unit 1 – What’s OO? Agenda

„ Module overview „ Fire alarm „ Teaching approach „ Contact details „ Free ! „ What is Object-Orientation? „ The Object-Orientated lifecycle „ Introduction to use cases „ Tutorial details

2 Module Goals

„ Gain an understanding of object-oriented concepts, to be able to analyse, design and implement systems in a object-oriented programming language „ Develop a critical awareness of the possibilities and limitations of the OO paradigm, its methods and tools „ Develop an understanding of the benefits and problems associated with software reuse

3 Learning Outcomes

„ Fully use a modelling tool to analyse and design an object-oriented system „ Fully use the facilities of a typical object- oriented programming language (e.g. Java) to implement and test an object- oriented design

4 Module Overview DESIGN PROGRAMMING 1. Use Cases 1. 2. Classes and Objects 2. 3. OO Analysis (!) 3. 4. Message Passing 4. 5. 5. Java Message Passing 6. 6. Inheritance 7. Case Study 7. Case Study 8. 8. Java GUI 9. Activity diagrams (!) 9. 10. 10. Java Exceptions 11. 11. Java Threads 12. Revision 12. Revision

5 Teaching Approach

„ You can’t do object-oriented design without knowledge of the OO programming language, but... „ You can’t do object-oriented programming without knowledge of OO design, so... „ must interleave the two! „ 1 hour lecture, 2 hour practical. „ http://www.cems.uwe.ac.uk/~jsa/OODP/

6 Assignment

„ OO analysis, design, implementation, testing… „ Reflection. „ Essay based questions. „ Due date TBC but probably mid December.

7 Contact Details

„ Appointments available on: Monday, Tuesday and Thursday „ Email: [email protected] „ Email: [email protected] (faster!)

„ Email: [email protected]

8 Free Software!

„ Microsoft Academic Alliance „ 3P12 with ID card „ Windows XP, Visual Studio etc. „ Visio

9 Reading: Books - Java

„ Introduction to Java Programming 5th Edition - Y. Daniel Liang (0131489526) „ Java Software Solutions: Foundations of Program Design 4th Edition – Lewis and Loftus (0321322037) „ Or any Java (not JavaScript) book you already have!

10 Reading: Books - UML

„ Oreilly UML 2.0 Nutshell/Full (0596007957) (£20) „ UML Distilled: A Brief Guide to the Standard Object (0321193687) (£20) „ Unified Modeling Language User Guide (Grady Booch) (0321267974) (£30) „ Using UML – Pooley (0201648601) (£37)

11 Reading: Links

„ Unified Modeling Language: http://www.uml.org „ UML tutorial: http://bdn.borland.com/article/0,1410,31863,00.html „ Java Language Whitepaper: http://sunsite.ee/java/whitepaper/java-whitepaper- 1.html http://java.sun.com/docs/overviews/java/java- overview-1.html (shorter) „ UML 2.0 Specification: http://www.uml.org/#UML2.0

12 Design is art! (Well in some cases…)

„ Many ways to achieve same result. „ Opinionated. „ Subject to fashion! „ Don’t take everything you read as gospel.

13 A system made up of objects Computer System Object

Function

Data

14 Objects Collaborate With Other Objects

Get Total Price Computer ShoppingShopping System BasketBasket Get Cost Get Cost

Get Cost “War“War && “Mission“Mission Peace”Peace” “Best“Best EverEver Impossible”Impossible” BookBook HitsHits 2005”2005” DVDDVD £9.99£9.99 CDCD £6.99£6.99 £10.99£10.99

15 Comparison with “structured” systems

function space

data / information The space System state space

“orthogonal” view (Tom DeMarco, Ed Yourdon)

16 Role of OO models

Conceptual Logical, platform (domain) models independent model

Business Physical, platform Process Analysis specific model Context models Design models Computer Implementation (Code) System

17 Object Oriented Lifecycle - simplified

Use Cases Physical Class Model (static), Interaction Model, State / Activity Java Technical Architecture Model (dynamic)

Java Source Code Logical

18 Unified Modelling Language UMLUML SpecificationSpecification ObjectObject ManagementManagement GroupGroup (OMG)(OMG) VersionVersion 2.0,2.0, OctoberOctober 2004,2004, www.omg.org/umlwww.omg.org/uml

“The Unified Modelling Language (UML) is a language for specifying, visualizing, constructing, and documenting the artifacts of a software- intensive system.”

19 Major Contributors

JAMESJAMES “Object-Oriented“Object-Oriented ModellingModelling RUMBAUGHRUMBAUGH andand Design”Design” (1991) (1991)

GRADY “Object-Oriented“Object-Oriented DesignDesign withwith BOOCH Applications”Applications” (1993) (1993)

IVARIVAR “Object-Oriented“Object-Oriented SoftwareSoftware Engineering:Engineering: JACOBSONJACOBSON AA UseUse CaseCase DrivenDriven Approach”Approach” (1992) (1992)

20 UML: Unified Modeling Language

„ “Modeling is the designing of software applications before coding.” [OMG] „ Standards for… Model elements „ Fundamental modelling elements and concepts e.g. use case, class, object, state etc. Notation „ Visual rendering of model elements into graphical diagrams

21 Diagram Types

„ Structure Diagrams: (static) Class, Object, Component, Composite Structure, Package and Deployment. „ Behaviour Diagrams: (general) Use case, activity and state machine. „ Interaction Diagrams: Sequence, communication, timing and interaction overview.

22 “Outside” versus “Inside” view of system

Computer System

Class Interaction System Model Model Actors

State ActivityActivity Model

Use Cases

23 UML Graphical Diagrams (1)

Use Case Diagram

24 UML Graphical Diagrams (2)

::Stock

«business» Catalogue findTitle «business» getPickingList Store storeName 1 1

* * «business» «business» Compact Disk Title artistartist {Abstract} getArtistgetArtist type runningTime name dateAdded priceOverdue Class Diagram loanPricePerDay «business» overduePriceoverduePrice Copy reserveOnDateForgetReservationsgetReservation uniqueReference deleteYourself createLoan addACopy * overduePrice areYouRentable deleteYourselfaddDetails priceOfTheLoan $Create $Create addDetailsaddDetails getTitle deleteYourself getDateAdded getRunningLength «business» whatIsYourClass Video getCopies director delete actors getType certificate copiesAvailable getActor decrementCopies getDirector getCertificategetType

25 UML Graphical Diagrams (3)

Behaviour Diagrams * State Diagram * Activity Diagram * Interaction Diagrams - Sequence Diagram - Collaboration Diagram

26 UML Graphical Diagrams (4)

Implementation Diagrams * Component Diagram * Deployment Diagram

27 Use Cases: Definition

„ “Use cases are a means for specifying required usages of a system.” [UML spec. v2.0] „ Collection of related scenarios „ “Black Box” view of system behaviour „ Textual narrative „ Unit of interaction between actor and system what the system does, not how „ Sequence / Flow yielding result of value to actor „ Basis of system scope, construction and testing

28 Use Cases: Notation

„ “The cinema manager adds details of a new film. Film details include Title, Age Rating, Duration, and short trailer description.”

Add Film

29 Use Cases: Actors

„ “An actor specifies a role played by a user or any other system that interacts with the subject.” [UML spec. v2.0] „ Initiate use cases. „ Exist outside of the scope of a use case. „ Not necessarily human, i.e. external system.

<>

Manager

30 Use Cases: Diagram

31 How do Actors interact with system?

ACTOR SYSTEM Amend Actor requests Widget Details to search for System displays list of Widget potential Widgets SequenceSequence Actor chooses Widget System provides Widget Details Actor amends “ping-pong”“ping-pong” Widget Details interactioninteraction System updates Widget Details

32 How do I Identify Use Cases?

„ Identify candidate system actors „ identify candidate use cases „ Refine and scope units of interaction (use cases) start point (look for actor and initial event) end point (look for beneficial result – the goal - for actor)

33 Use Cases: Generalization

„ General and specific requirements. „ Shared. „ Include or Includes? „ Identify by looking for duplications in the requirements. „ BTW – Actors can also be generalised. Make Reservation ______<> „ AKA – Extend. Add Extra Guest

34 Use Cases: Include

„ Remove duplicate functionality. „ Shared. „ Include or Includes? „ Identify by looking for duplications in the requirements.

35 Use Cases: Include or Extend

„ If on its own a use case does not complete a task then it should be included. „ Go to lunch rule. „ Extend complete tasks.

36 Use Cases: Example

… A car rental company currently takes bookings for cars over the phone. The sales clerk takes the customer details (dates for reservation, car, contact name and address). The clerk then checks availability and prices the order. The quote is offered to the customer where it is either accepted or rejected. If the quote is accepted the car is marked as booked on the requested days. …

37 Use Cases: Example

38 Use Cases: Example

Check Availability

<>

Sales Clerk Make Reservation

39 Summary

„ Object-Orientation

objects are function and data in the same place

„ The Object-Oriented lifecycle

use cases, class and object modelling, code

„ Introduction to Use Cases

“black-box” interaction between actor and system

40 Tutorial

„ Familiarise yourself with the UweFlix Cinema Booking System case study „ Using the UweFlix system requirements: Identify possible system actors and use cases Provide an objective for each use case Create a use case diagram in your UML modelling tool

41