module ufc016qm object-oriented design and programmingjsa/oodp/unit1.pdf · 2005-09-27 · 3 module...

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

Upload: others

Post on 10-Mar-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

Module UFC016QMObject-Oriented Design and ProgrammingUnit 1 – What’s OO?

Page 2: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

2

Agenda

Module overviewFire alarmTeaching approachContact detailsFree Software!What is Object-Orientation?The Object-Orientated lifecycleIntroduction to use casesTutorial details

Page 3: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

3

Module Goals

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

Page 4: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

4

Learning Outcomes

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

Page 5: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

5

Module Overview1. Use Cases2. Classes and Objects3. OO Analysis (!)4. Message Passing5.6.7. Case Study8.9. Activity diagrams (!)10.11.12. Revision

1.2.3.4.5. Java Message Passing6. Inheritance7. Case Study8. Java GUI9.10. Java Exceptions11. Java Threads12. Revision

DESIGN PROGRAMMING

Page 6: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

6

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/

Page 7: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

7

Assignment

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

Page 8: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

8

Contact Details

Appointments available on:Monday, Tuesday and Thursday

Email: [email protected]: [email protected] (faster!)

Email: [email protected]

Page 9: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

9

Free Software!

Microsoft Academic Alliance3P12 with ID cardWindows XP, Visual Studio etc.Visio

Page 10: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

10

Reading: Books - Java

Introduction to Java Programming5th 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!

Page 11: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

11

Reading: Books - UML

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

Page 12: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

12

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.htmlhttp://java.sun.com/docs/overviews/java/java-overview-1.html (shorter)

UML 2.0 Specification:http://www.uml.org/#UML2.0

Page 13: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

13

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.

Page 14: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

14

A system made up of objectsComputer

System

Function

Data

Object

Page 15: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

15

Objects Collaborate With Other ObjectsGet Total Price

Get Cost

“War & Peace”Book£9.99

“War & Peace”Book£9.99

Get Cost

“Mission Impossible”

DVD£6.99

“Mission Impossible”

DVD£6.99

Get Cost

“Best Ever Hits 2005”

CD£10.99

“Best Ever Hits 2005”

CD£10.99

Shopping Basket

Shopping Basket

Computer

System

Page 16: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

16

Comparison with “structured” systems

The System

data / information

space

function space

state space

“orthogonal” view(Tom DeMarco, Ed Yourdon)

Page 17: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

17

Role of OO modelsConceptual

(domain) models

Analysis models

Design models

Implementation (Code)

Computer

System

Logical, platform independent model

Physical, platform specific model

Business Process Context

Page 18: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

18

Object Oriented Lifecycle - simplifiedUse Cases

Java Technical Architecture

Logical

PhysicalClass Model (static), Interaction Model,

State / Activity Model (dynamic)

Java Source Code

Page 19: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

19

Unified Modelling Language

“The Unified Modelling Language (UML) is a language for specifying, visualizing,

constructing, and documenting the artifacts of a software-

intensive system.”

UML SpecificationObject Management Group (OMG) Version 2.0,

October 2004, www.omg.org/uml

UML SpecificationObject Management Group (OMG) Version 2.0,

October 2004, www.omg.org/uml

Page 20: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

20

“Object-Oriented Modellingand Design” (1991)

“Object-Oriented Modellingand Design” (1991)

“Object-Oriented Software Engineering: A Use Case Driven Approach” (1992)

“Object-Oriented Software Engineering: A Use Case Driven Approach” (1992)

GRADYBOOCH

IVARJACOBSON

IVARJACOBSON

JAMESRUMBAUGH

JAMESRUMBAUGH

“Object-Oriented Design withApplications” (1993)

“Object-Oriented Design withApplications” (1993)

Major Contributors

Page 21: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

21

UML: Unified Modeling Language

“Modeling is the designing of software applications before coding.” [OMG]Standards for…

Model elementsFundamental modelling elements and concepts e.g. use case, class, object, state etc.

NotationVisual rendering of model elements into graphical diagrams

Page 22: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

22

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.

Page 23: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

23

“Outside” versus “Inside” view of system

Use Cases

System Actors

Interaction Model

State Model

Class Model

ActivityActivity

Computer

System

Page 24: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

24

UML Graphical Diagrams (1)

Use Case Diagram

Page 25: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

25

UML Graphical Diagrams (2)

::Stock

«business»Copy

uniqueReferencecreateLoanoverduePriceareYouRentablepriceOfTheLoan$CreatedeleteYourself

«business»Video

directoractorscertificategetActorgetDirectorgetCertificate

«business»Compact Disk

artistgetArtist

«business»Title

{Abstract}typerunningTimenamedateAddedpriceOverdueloanPricePerDayoverduePricereserveOnDateForgetReservations

addACopydeleteYourself$CreateaddDetailsgetTitlegetDateAddedgetRunningLengthwhatIsYourClassgetCopiesdeletegetTypecopiesAvailabledecrementCopies

«business»Store

storeName

«business»Catalogue

findTitlegetPickingList

«business»Copy

uniqueReferencecreateLoanoverduePriceareYouRentablepriceOfTheLoan$CreatedeleteYourself

«business»Video

directoractorscertificategetActorgetDirector

«business»Compact Disk

artistgetArtist

«business»Title

{Abstract}typerunningTimenamedateAddedpriceOverdueloanPricePerDayoverduePricegetReservation

addACopydeleteYourself

$CreateaddDetails

getTitlegetDateAddedgetRunningLengthwhatIsYourClassgetCopiesdeletegetTypecopiesAvailabledecrementCopies

«business»Store

storeName

«business»Catalogue

findTitlegetPickingList

1

*

*

*

1

Class Diagram

getType

addDetails

Page 26: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

26

UML Graphical Diagrams (3)

Behaviour Diagrams

* State Diagram

* Activity Diagram

* Interaction Diagrams

- Sequence Diagram

- Collaboration Diagram

Page 27: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

27

UML Graphical Diagrams (4)

Implementation Diagrams

* Component Diagram

* Deployment Diagram

Page 28: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

28

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 behaviourTextual narrativeUnit of interaction between actor and system

what the system does, not howSequence / Flow yielding result of value to actor Basis of system scope, construction and testing

Page 29: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

29

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

Page 30: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

30

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.

<<actor>>

Manager

Page 31: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

31

Use Cases: Diagram

Page 32: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

32

How do Actors interact with system?

SYSTEMActor requests to search for Widget System displays list of

potential Widgets

Actor chooses Widget

ACTOR

System provides Widget Details

Actor amends Widget Details

System updates Widget Details

“ping-pong”interaction

“ping-pong”interaction

SequenceSequence

Amend Widget Details

Page 33: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

33

How do I Identify Use Cases?

Identify candidate system actors identify candidate use casesRefine 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)

Page 34: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

34

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.AKA – Extend.

Make Reservation________________

<<extension points>>Add Extra Guest

Page 35: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

35

Use Cases: Include

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

Page 36: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

36

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.

Page 37: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

37

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. …

Page 38: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

38

Use Cases: Example

Page 39: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

39

Use Cases: Example

Sales Clerk Make Reservation

Check Availability

<<include>>

Page 40: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

40

Summary

Object-Orientationobjects are function and data in the same place

The Object-Oriented lifecycleuse cases, class and object modelling, code

Introduction to Use Cases“black-box” interaction between actor and system

Page 41: Module UFC016QM Object-Oriented Design and Programmingjsa/OODP/unit1.pdf · 2005-09-27 · 3 Module Goals Gain an understanding of object-oriented concepts, to be able to analyse,

41

Tutorial

Familiarise yourself with the UweFlixCinema Booking System case studyUsing the UweFlix system requirements:

Identify possible system actors and use casesProvide an objective for each use caseCreate a use case diagram in your UML modelling tool