1 / 121

CHAPTER 16

CHAPTER 16. SYSTEM DESIGN. CHAPTER GOALS. To learn about the software life cycle To learn how to discover new classes and methods To understand the use of CRC cards for class discovery   To be able to identify inheritance, aggregation, and dependence relationships between classes

huong
Download Presentation

CHAPTER 16

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CHAPTER 16 SYSTEM DESIGN

  2. CHAPTER GOALS • To learn about the software life cycle • To learn how to discover new classes and methods • To understand the use of CRC cards for class discovery   • To be able to identify inheritance, aggregation, and dependence relationships between classes • To master the use of UML class diagrams to describe class relationships   • To learn how to use object-oriented design to build complex programs

  3. Software Life Cycle • Encompasses all activities from initial analysis until obsolescence

  4. Development Process • Analysis • Design • Implementation • Testing • Deployment

  5. Analysis • Decide what the project is suppose to do • Output: requirements document

  6. Design • Plan how to implement the system • Output: • description of classes and methods • diagrams showing the relationships among the classes

  7. Implementation • Write and compile the code • Output: completed code

  8. Testing • Run tests to verify the program works correctly • Output: a report of the tests and their results

  9. Deployment • Install the program and begin using it

  10. The Waterfall Model

  11. The Spiral Model • Describes an iterative process in which design and implementation are repeated

  12. The Spiral Model

  13. Extreme Programming • Development methodology that strives for simplicity by removing formal structure and focusing on best practices

  14. Extreme Programming • Realistic planning • Customers make business decisions • Programmers make technical decisions

  15. Extreme Programming • Small releases • Release a useful system quickly • Release updates on a short cycle

  16. Extreme Programming • Metaphor • A shared story to explain the system

  17. Extreme Programming • Simplicity • Design as simply as possible instead of preparing for future complexities

  18. Extreme Programming • Testing • Programmers and customers write test cases • Test continuously

  19. Extreme Programming • Refactoring • Restructure the system continuously to improve code and eliminate duplication

  20. Extreme Programming • Pair programming • Two programmers write code on the same computer

  21. Extreme Programming • Collective ownership • All programmers change all code as needed

  22. Extreme Programming • Continuous integration • Build the entire system and test it whenever a task is complete

  23. Extreme Programming • 40-hour week • Don't cover up unrealistic schedules with heroic effort

  24. Extreme Programming • On-site customer • A customer is accessible to the programming team at all times

  25. Extreme Programming • Coding standards • Follow standards that emphasize self-documenting code

  26. Object-Oriented Design • Discover classes • Determine responsibilities of each class • Describe the relationships among the classes

  27. Discovering Classes • A class represents some useful concept • Find classes by looking for nouns in the task description • Define the behavior for each class • Find methods by looking for verbs in the task description

  28. CRC Card • Stands for classes, responsibilities, collaborators • Use an index card for each class • Pick the class that should be responsible for each method (verb) • Write the responsibility onto the class card • Indicate what other classes are needed to fulfill the responsibility - the collaborators

  29. A CRC Card

  30. Relationships Between Classes • Inheritance • Association • Dependency

  31. "Is-a" Relationship • The "is-a" relationship is inheritance; use extends • a circle is an ellipse • a car is a vehicle

  32. "Has-a" Relationship • The "has-a" relationship is association; use an instance variable • a tire has a circle as its boundary • a car has a set of tire

  33. Uses Relationship • The "uses" relationship is dependency • an Applet uses a Graphics object

  34. "is-a" and "has-a"Example class Car extends Vehicle //inheritance "is-a" { ... private Tire[] tires; //association "has-a" }

  35. Association and Dependency • One class is associated with another if you can navigate from its objects to objects of the other class • One class depends on another if it comes into contact with the other class in some way. • Association is a stronger form of dependency

  36. UML Notation for Inheritance and Association

  37. UML Relationship Symbols

  38. Five-Part Development Process • Gather requirements • Use CRC cards to find classes, responsibilities, and collaborators • Use UML diagrams to record class relationships • Use javadoc to document method behavior • Implement your program

  39. Printing an Invoice - Requirements • Print billing address, all line items, amount due • Line item contains description, unit price, quantity ordered, total price

  40. Sample Invoice INVOICE Sam's Small Appliances     100 Main Street    Anytown, CA 98765  Description Price Qty Total Toaster  29.95 3 89.85 Hair dryer  24.95 1 24.95 Car vacuum  19.99 2 39.98     Amount Due:   $154.78  

  41. Printing an Invoice - CRC Cards • Discover classes • Nouns are possible classes Invoice Price Address Quantity Item Total Product AmountDue Description

  42. Printing an Invoice - CRC Cards • Classes after a process of elimination Invoice Address Item Product

  43. CRC Cards for Printing Invoice

  44. CRC Cards for Printing Invoice

  45. CRC Cards for Printing Invoice

  46. CRC Cards for Printing Invoice

  47. Printing an Invoice - UML Diagrams • The relationship between Invoice classes

  48. Printing an Invoice - Method Documentation • Use javadoc documentation comments to record the behavior of the classes • Leave the body of the methods blank • Run the javadoc utility to obtain a formatted version of the documentation in HTML format

  49. Method Documentation – Invoiceclass /** Describes an invoice for a set of purchased products. */ class Invoice { /** Adds a charge for a product to this invoice. @param aProduct the product that the customer ordered @param quantity the quantity of the product */ public void add(Product aProduct, int quantity) { } /** Formats the invoice. @return the formatted invoice

  50. */ public String format() { } /** Computes the total amount due. @Return the amount due */ public double getAmountDue() { } }

More Related