220 likes | 233 Views
CS 509 Design of Software Systems. Lecture #6 Monday, March 1, 2004. Class Format for Today. Term Project Administration Questions Review of Chapter 10 In-class Exercises: Discuss contents of new text book, choose lecture topics Review requirements for HIS. Term Project Administration.
E N D
CS 509Design of Software Systems Lecture #6 Monday, March 1, 2004 CS 509 - WPI
Class Format for Today • Term Project Administration • Questions • Review of Chapter 10 • In-class Exercises: • Discuss contents of new text book, choose lecture topics • Review requirements for HIS CS 509 - WPI
Term Project Administration • Phase 3 – CIS Design (and journals) due • Return Quiz #3 • Hand out Phase 4 assignment • Change to grading policy: P4 5%, P5 10% • Phase 4 discussion • Only have 1 week for analysis • Would it be more or less productive to have larger groups for phase 4? • 2 groups of 4 instead of 4 groups of 2? CS 509 - WPI
Questions? • About what was covered last time • From the reading • About the Term Project • Anything else? CS 509 - WPI
Chapter 10 Mapping Models to Code CS 509 - WPI
Overview of Activities • What are the purposes of the activities in this chapter? • Optimizing the class model • Mapping associations to collections • Mapping operation contracts to exceptions • Mapping the class model to a storage schema CS 509 - WPI
Optimizations • Address performance requirements of system model • Optimizing associations: • Reducing multiplicity • Adding redundancy • Why do each of the above? • Adding derived attributes CS 509 - WPI
Transformations • Model transformations • Refactorings • Forward engineering • Reverse engineering CS 509 - WPI
Model Transformations • Applied to an object model, produces another object model • Purpose: • To simplify or optimize original model • To bring into closer compliance with requirements • Actions: • Add, remove or rename classes, operations, associations and/or attributes CS 509 - WPI
Refactoring • Transformation of source code • Improve readability or modifiability without changing behavior • Focus on a specific field or method of class • Done in small incremental steps interwoven with testing • Examples: (What do they do?) • Pull Up Field, Pull Up Constructor, Pull Up Method CS 509 - WPI
Forward Engineering • Applied to a set of model elements • Results in a set of source code statements: • Class declaration, expression, DB schema • Maintain strong correspondence between object design model & code • Reduce number of errors introduced during implementation CS 509 - WPI
Reverse Engineering • Applied to source code • Results in a set of model elements • Recreate the model for an existing system • Why? • Does not necessarily create original model • Why not? CS 509 - WPI
Transformation Principles • Goal is to improve design • Making changes is potentially hazardous • How to avoid introducing new errors: • Address a single criteria or design goal • Local transformations, not architectural changes • Applied in isolation to other changes (how?) • Followed by testing to validate CS 509 - WPI
Optimizing for Performance • Increase in performance may result in more complexity • Want a balance between efficiency & clarity • Minimize repeated association traversals • Reduce “many” associations to “one” • Eliminate unneeded classes by moving attributes CS 509 - WPI
More Optimizations • Collapsing objects into attributes • How do you know where this applies? • When should this activity be done? • Delaying expensive computations • Proxy design pattern may be useful • Caching results of expensive computations • Data can be stored temporarily (time vs. space) • Need to be careful about when to update CS 509 - WPI
Mapping Associations • Associations in UML have no direct counterpart in Java • Can map to reference or collection • Unidirectional vs. bi-directional • One-to-one, one-to-many, many-to-many • Qualified associations • Association classes CS 509 - WPI
From Contracts to Exceptions • Contracts are mapped to exceptions using a corresponding check in the code (an if statement) that throws an exception if a contract condition is not satisfied • When is it necessary to check contract conditions? • How do inheritance and encapsulation apply? CS 509 - WPI
Persistent (Relational) Storage • Mapping object models to persistent storage required defining a schema • Tables and keys: • Primary key, candidate key, foreign key • Map each class to a table of the same name • Map attributes to columns in table • Choose primary key (how?) CS 509 - WPI
Association Relationships • Buried associations with multiplicity one • Why is this called a buried association? • How does it work? • Association (or Bridge) Table • What is a bridge table? • What is it used for? • How does it work? CS 509 - WPI
Mapping Inheritance • Vertical mapping • Typo in book on page 418 (sub vs. super) • Horizontal mapping • What are the differences? The trade-offs? • Which one has a “role” column? • What is it for? CS 509 - WPI
In-class Exercises • Discuss contents of new text book • Choose lecture topics for: • 3/8, 3/15, 3/22 • Review requirements for HIS • Work on defining attributes for categories CS 509 - WPI
For Next Time • Phase 4 due (HIS RAD) and Journals • Reading TBD • Think about course content for CS562 CS 509 - WPI