1 a student guide to object- orientated development chapter 9 design

30
1 A Student Guide to A Student Guide to Object- Orientated Object- Orientated Development Development Chapter 9 Design Chapter 9 Design

Post on 22-Dec-2015

218 views

Category:

Documents


0 download

TRANSCRIPT

1

A Student Guide to Object- A Student Guide to Object- Orientated DevelopmentOrientated Development

Chapter 9 DesignChapter 9 Design

2

DesignDesign

Analysis describes WHAT a system must do

Design describes HOW to do it

Analysis decisions are implementation-independent

Design decisions are implementation-dependent

3

DesignDesign

Design activities:

overall system designdetailed design

4

Overall system designOverall system design

designing the overall architecture of the system

selecting a strategy for coping with persistent data

designing a user interfacechoosing software and hardware

platformsproducing a test plan

5

Design - overallDesign - overall

Product of overall design activities layered diagram of the system

architecture a set of component and deployment

diagrams a database definition a test plan screen and report layouts

6

Design - detailedDesign - detailed

Product of detailed design activitiesa set of detailed class diagrams supporting documentation such as

data dictionary and operation specifications

a set of detailed interaction diagrams

7

ArchitectureArchitecture

Architecture describes the software and hardware components of the system

8

Architecture -softwareArchitecture -software

logical software components : classes, packages, subsystems Modelled with class diagrams etc.

physical software components : executable files, class libraries and databases Modelled with component diagrams

9

Architecture - hardwareArchitecture - hardware

Hardware architecture : the computers, peripherals and

networks on which the system will run

hardware architecture is modelled using deployment diagrams.

10

Packages and dependenciesPackages and dependencies A package is a UML mechanism for

grouping modelling elements

Does not represent anything in the system, but is used to group modelling elements that do

Can be used to group use cases, classes, collaborations, sub-systems etc

11

We can also use packages to nest modelsWe can also use packages to nest models

Hire Bike

ManageData

Level 1 Packagediagram of sub-systems

Level 2 classdiagram forManage Datasub-system

Bike Customer

12

DependenciesDependencies

A dependency exists between packages if a change in one can affect the other.

If a change in package A can affect package B, then package B depends on package A.

13

DependenciesDependencies

Package A Package B

Dependency

14

DependenciesDependenciesA dependency exists between two

classes if they have a client-server relationship

Hire Bike

Manage Data

15

Layered architectureLayered architecture

In a layered architecture, packages are arranged into layers so that each layer only uses the services of the layer below it.

Layer 6Layer 5Layer 4Layer 3Layer 2Layer 1

16

the presentation layer near the topdata storage layer towards the

bottomapplication layers in the middle

Layered architectureLayered architecture

17

Layered architectureLayered architecture

Presentation layer

Application logic layer

Application layer

Storage layerDatabase

User Interface

Application Logic

Application

18

Implementation diagramsImplementation diagrams

Component diagram - models physical software components

Deployment diagram - models hardware components

19

Component diagramComponent diagram

Hiring.javaMaintenance.java

Database

20

Deployment diagramDeployment diagram

Database Server

Shop PC Reception PC

Maintenance.java Hiring.java

Database

21

User interfaceUser interface

Should be consistent:screen layouts should follow the

same general patternsimilar tasks should be performed in

similar waysmessages from the system to the

user should always be in the same format.

·

22

User interfaceUser interface

User tasks that are boring and prone to error should be minimized

system should provide shortcuts for experienced users

data should be entered by selecting from a menu rather than typing

screens should be free of clutter, containing all the relevant information and no more. An overcrowded screen is tiring to look at and irritating to work with.

23

User interface - exampleUser interface - example

24

Dealing with persistent dataDealing with persistent data

Object-oriented and relational databases

• A database stores, organizes and maintains data to support the operations of an organization

•An object-oriented database provides the facilities of a traditional database, and supports the complex data structures of object-oriented systems

•However, for an information system, such as Wheels, a developer would be much more likely to choose a relational database.

25

Dealing with persistent dataDealing with persistent data

Object-oriented and relational databases

• Relational databases are established, proved efficient for the sort of data found in information systems like Wheels • Object-oriented databases relatively recent• Business organizations have invested money in relational database systems - reluctant to throw it away in order to change to an object-oriented database

26

Dealing with persistent dataDealing with persistent data

Linking an object-oriented program to a relational database

• For an O-O program to access a relational database we need

code to establish a connection

• JDBC (Java Database Connectivity) - interface that interacts with both the code and the database

27

Implementing a class diagram in a relational Implementing a class diagram in a relational databasedatabase

Basic rule - one class maps to one table

BikeNo.

Available Type Size Make Model DailyHireRate

Deposit

249 On hire mountain woman's Scott Atlantic Trail £8.00 £50.00250 Available tourer man's Raleigh Pioneer £9.00 £60.00251 On hire mountain woman's Scott Atlantic Trail £8.00 £50.00252 On hire tourer man's Dawes Galaxy £8.00 £50.00253 Available mountain child's Raleigh Chopper £5.00 £25.00

Bike tableBike tablePrimary key

Bike classBike classBikebike#availabletypesizemakemodeldailyHireRatedeposit

28

Implementing a Implementing a one to many association in a relational in a relational

database: database: First method

One to many associationOne to many associationCustomer PaymentcustIDnameaddresstel

1 1..*datetotalAmountPaidtotalDepositPaidtotalDepositReturned

Customer tableCustomer table

CustID Name FirstName Street Town PhoneNo1 Sykes Jim 2 High Road Greenwood 01395 2110562 Perle Lee 14 Duke Street Greenwood 01395 2378513 Hargreaves Les 11 Forest Road Prestwich

Albans01462 501339

4 James Sheena 4 Duke Street Greenwood 01395 2376635 Robins Charlie 11 Juniper Road Greenwood 0 1395 267843

Payment No. Date Total amountpaid

Total depositpaid

Total depositreturned

401 19/03/04 £56.00 £50.00 £50.00402 19/03/04 £20.00 £25.00 £25.00403 19/03/04 £145.00 £80.00 £80.00404 20/03/04 £186.00 £100.00 £84.00405 20/03/04 £44.00 £40.00 £40.00

CustID Payment No.1 4092 5132 4053 404

11 501

Payment tablePayment table

Customer-Payment tableCustomer-Payment table

29

Implementing a Implementing a one to many association in a relational in a relational

database: database: Second method

One to many associationOne to many associationCustomer PaymentcustIDnameaddresstel

1 1..*datetotalAmountPaidtotalDepositPaidtotalDepositReturned

Customer tableCustomer table

Payment tablePayment tablewith foreign keywith foreign key

Customer

CustID Name FirstName Street Town PhoneNo1 Sykes Jim 2 High Road Greenwood 01395 2110562 Perle Lee 14 Duke Street Greenwood 01395 2378513 Hargreaves Les 11 Forest Road Prestwich

Albans01462 501339

4 James Sheena 4 Duke Street Greenwood 01395 2376635 Robins Charlie 11 Juniper Road Greenwood 0 1395 267843

Payment

Payment No. CustID Date Total amountpaid

Total depositpaid

Total depositreturned

411 17 19/03/04 £56.00 £50.00 £50.00412 20 19/03/04 £20.00 £25.00 £25.00413 6 19/03/04 £145.00 £80.00 £80.00414 3 20/03/04 £186.00 £100.00 £84.00415 17 21/03/04 £44.00 £40.00 £40.00

foreign keyforeign key

30

Implementing a Implementing a inheritance in a relational database in a relational database

SpecialistBike

epochinsurance

Bike

bike#availabletypesizemakemodeldailyHireRatedeposit

Inheritance relationshipInheritance relationship

BikeNo.

Available Type Size Make Model Epoch Insurance Daily HireRate

Deposit

249 On hire mountain woman's Scott AtlanticTrail

£8.00 £50.00

250 Available tourer man's Raleigh Pioneer £9.00 £60.00251 On hire mountain woman's Scott Atlantic

Trail£8.00 £50.00

252 On hire tourer man's Dawes Galaxy £8.00 £50.00253 Available mountain child's Raleigh Chopper £5.00 £25.00254 Available tandem man's Sunbeam Voyager 1930s £15.00 £20.00 £100.00

normal bikesnormal bikes

specialist bikespecialist bike