download

Matakuliah
Tahun
: Konsep object-oriented
: 2009
DESIGN SYSTEM OVERALL
Pertemuan 21
A Student Guide to Object- Orientated
Development
Chapter 9 Design
3
Design
• Analysis describes WHAT a system must do
• Design describes HOW to do it
• Analysis decisions are implementationindependent
• Design decisions are implementation-dependent
4
Design
Design activities:
• overall system design
• detailed design
5
Overall system design
•
•
•
•
•
designing the overall architecture of the system
selecting a strategy for coping with persistent data
designing a user interface
choosing software and hardware platforms
producing a test plan
6
Design - 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
7
Design - detailed
Product of detailed design activities
• a set of detailed class diagrams
• supporting documentation such as data dictionary
and operation specifications
• a set of detailed interaction diagrams
8
Architecture
Architecture describes the software and hardware
components of the system
9
Architecture -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
10
Architecture - hardware
Hardware architecture :
• the computers, peripherals and networks on which
the system will run
• hardware architecture is modelled using deployment
diagrams.
11
Packages 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
12
We can also use packages to nest models
Hire Bike
Level 1 Package
diagram of subsystems
Manage
Data
Bike
Customer
Level 2 class
diagram for
Manage Data
sub-system
13
Dependencies
• 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.
14
Dependencies
Dependency
Package A
Package B
15
Dependencies
• A dependency exists between two classes if they
have a client-server relationship
16
Layered architecture
• In a layered architecture, packages are arranged into
layers so that each layer only uses the services of the
layer below it.
Layer 6
Layer 5
Layer 4
Layer 3
Layer 2
Layer 1
17
Layered architecture
• the presentation layer near the top
• data storage layer towards the bottom
• application layers in the middle
18
Layered architecture
User Interface
Application
Logic
Application
Database
Presentation layer
Application logic layer
Application layer
Storage layer
19
Implementation diagrams
• Component diagram - models
physical software components
• Deployment diagram - models
hardware components
20
Component diagram
Maintenance.java
Hiring.java
Database
21
Deployment diagram
Database
Server
Database
Shop PC
Maintenance.java
Reception PC
Hiring.java
22
User interface
Should be consistent:
• screen layouts should follow the same general
pattern
• similar tasks should be performed in similar ways
• messages from the system to the user should always
be in the same format.
·
23
User 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.
24
User interface - example
25
Dealing 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.
26
Dealing 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
27
Dealing 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
28
Implementing a class diagram in a relational
database
Basic rule - one class maps to one table
Bike
bike#
available
type
size
make
model
dailyHireRate
deposit
Bike class
Primary key
Bike table
Bike
No.
Available Type
Size
Make
Model
249
250
251
252
253
On hire
Available
On hire
On hire
Available
woman's
man's
woman's
man's
child's
Scott
Raleigh
Scott
Dawes
Raleigh
Atlantic Trail
Pioneer
Atlantic Trail
Galaxy
Chopper
mountain
tourer
mountain
tourer
mountain
Daily
Hire
Rate
£8.00
£9.00
£8.00
£8.00
£5.00
Deposit
£50.00
£60.00
£50.00
£50.00
£25.00
29
Implementing a one to many association in a
relational database: First method
Customer
custID
name
address
tel
CustID
1
2
3
4
5
Payment
date
1..* totalAmountPaid
totalDepositPaid
totalDepositReturned
1
Name
Sykes
Perle
Hargreaves
James
Robins
FirstName
Jim
Lee
Les
Sheena
Charlie
Payment No. Date
401
402
403
404
405
CustID
1
2
2
3
11
19/03/04
19/03/04
19/03/04
20/03/04
20/03/04
Street
2 High Road
14 Duke Street
11 Forest Road
4 Duke Street
11 Juniper Road
Town
Greenwood
Greenwood
Prestwich
Albans
Greenwood
Greenwood
PhoneNo
01395 211056
01395 237851
01462 501339
01395 237663
0 1395 267843
Total amount
paid
Total deposit
paid
Total deposit
returned
£56.00
£20.00
£145.00
£186.00
£44.00
£50.00
£25.00
£80.00
£100.00
£40.00
£50.00
£25.00
£80.00
£84.00
£40.00
Payment No.
409
513
405
404
501
One to many association
Customer table
Payment table
Customer-Payment table
30
Implementing a one to many association in a
relational database: Second method
Customer
custID
name
address
tel
Payment
date
1..* totalAmountPaid
totalDepositPaid
totalDepositReturned
1
One to many association
Customer
CustID
1
2
3
4
5
Name
Sykes
Perle
Hargreaves
James
Robins
Street
2 High Road
14 Duke Street
11 Forest Road
4 Duke Street
11 Juniper Road
Town
Greenwood
Greenwood
Prestwich
Albans
Greenwood
Greenwood
PhoneNo
01395 211056
01395 237851
01462 501339
01395 237663
0 1395 267843
Customer table
foreign key
Payment
Payment No. CustID
411
412
413
414
415
FirstName
Jim
Lee
Les
Sheena
Charlie
17
20
6
3
17
Date
Total amount
paid
Total deposit
paid
Total deposit
returned
19/03/04
19/03/04
19/03/04
20/03/04
21/03/04
£56.00
£20.00
£145.00
£186.00
£44.00
£50.00
£25.00
£80.00
£100.00
£40.00
£50.00
£25.00
£80.00
£84.00
£40.00
Payment table
with foreign key
31
Implementing a inheritance in a relational database
Bike
Inheritance relationship
bike#
available
type
size
make
model
dailyHireRate
deposit
SpecialistBike
epoch
insurance
normal bikes
Bike
No.
249
Available
Type
Size
Make
Model
On hire
mountain
woman's
Scott
250
251
Available
On hire
tourer
mountain
man's
woman's
Raleigh
Scott
252
253
254
On hire
Available
Available
tourer
mountain
tandem
man's
child's
man's
Dawes
Raleigh
Sunbeam
Atlantic
Trail
Pioneer
Atlantic
Trail
Galaxy
Chopper
Voyager
Epoch
1930s
Insurance
£15.00
Daily Hire
Rate
£8.00
Deposit
£9.00
£8.00
£60.00
£50.00
£8.00
£5.00
£20.00
£50.00
£25.00
£100.00
£50.00
specialist bike
32