A Student Guide to ObjectOrientated Development Chapter 9 Design 1 Design Analysis describes WHAT a system must do Design describes HOW to do it Analysis decisions are implementationindependent Design decisions are implementationdependent 2 Design Design activities: overall system design detailed design 3 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 4 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 5 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 6 Architecture Architecture describes the software and hardware components of the system 7 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 8 Architecture - hardware Hardware architecture : the computers, peripherals and networks on which the system will run hardware architecture is modelled using deployment diagrams. 9 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 10 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 11 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. 12 Dependencies Dependency Package A Package B 13 Dependencies A dependency exists between two classes if they have a client-server relationship 14 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 15 Layered architecture the presentation layer near the top data storage layer towards the bottom application layers in the middle 16 Layered architecture User Interface Application Logic Application Database Presentation layer Application logic layer Application layer Storage layer 17 Implementation diagrams Component diagram - models physical software components Deployment diagram - models hardware components 18 Component diagram Maintenance.java Hiring.java Database 19 Deployment diagram Database Server Database Shop PC Maintenance.java Reception PC Hiring.java 20 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. · 21 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. 22 User interface - example 23 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. 24 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 25 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 26 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 27 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 28 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 29 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 30