05-greatsoftware

05-greatsoftware - Great Software Kenneth M Anderson...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Great Software Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/5448 — Lecture 5 — 09/08/2009 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Lecture Goals • What is Great Software? • How do you produce great software each time you participate in a development project • Discuss the Chapter 1 Example: Rick’s Guitars • Emphasize the OO concepts and techniques encountered in Chapter 1 2
Background image of page 2
The Example • Rick’s Guitars • Purpose of Application? • Find Guitars for Rick’s Customers • Design of Initial Application? • Worse than Bad • What’s the Major Problem? • Application fails to ±nd guitars that Rick knows exists! • Note: Customer Focus… we could have said “The problem is due to the use of a case-sensitive string comparison” but Rick wouldn’t care about that! 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Initial Application getSerialNumber(): String getPrice(): double setPrice(double) getBuilder(): String getModel(): String getType(): String getBackWood(): String getTopWood(): String serialNumber: String price: double builder: String model: String type: String backWood: String topWood: String Guitar addGuitar(String, double, String, String, String, String, String) getGuitar(String): Guitar search(Guitar): Guitar guitars: List Inventory Egads! Alarm bells in the design center of your brain should be ringing like mad! Why? 4
Background image of page 4
Dumb Data Holder • Meet the Dumb Data Holder • A “data holder” is a class that only stores information and is dumb since it provides ZERO services • get() and set() don’t count! • If this is all you are going to use an object for, you may as well go back to C and just use structs! getSerialNumber(): String getPrice(): double setPrice(double) getBuilder(): String getModel(): String getType(): String getBackWood(): String getTopWood(): String serialNumber: String price: double builder: String model: String type: String backWood: String topWood: String Guitar 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
The Manager • Meet the “Manager” • A manager is a single class that contains most of the application’s services • For this simple application, a manager is okay, but… there are still problems addGuitar(String, double, String, String, String, String, String) getGuitar(String): Guitar search(Guitar): Guitar guitars: List Inventory 1. addGuitar(): too many params 2. getGuitar(): why only one param? 3. searchGuitar(): if I’m looking for a guitar, why am I passing one to the search() method? Managers must be used with care: its easy to centralize too many services within them! 6
Background image of page 6
Bad Smell? public Guitar search(Guitar searchGuitar) { 1 for (Iterator i = guitars.iterator(); i.hasNext(); ) { 2 Guitar guitar = (Guitar)i.next(); 3 // Ignore serial number since that's unique 4 // Ignore price since that's unique 5 String builder = searchGuitar.getBuilder(); 6 if ((builder != null "" 7 (!builder.equals(guitar.getBuilder()))) 8 continue ; 9 String model = searchGuitar.getModel(); 10 if ((model != null
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 31

05-greatsoftware - Great Software Kenneth M Anderson...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online