DOC PREVIEW
UW-Madison COMPSCI 302 - CS 302 Chapter 9 Notes

This preview shows page 1-2-3-4 out of 12 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Copyright © 2005-2007 William C. BentonChapter 91Copyright © 2005-2007 William C. BentonChapter 9 is a sort of catch-all chapter — we’ll review a few things and talk about design.2Copyright © 2005-2007 William C. BentonScope review•What is scope?•Where are each of the following in scope?•a local variable or parameter name•an instance field name•a static field name•a local declared in a for loop header3Copyright © 2005-2007 William C. BentonWhat is a side-effect?4Copyright © 2005-2007 William C. BentonHow are parameters passed to methods?5Copyright © 2005-2007 William C. Benton6(Rest assured that we’ll have an exercise on these topics later this week!)123456Copyright © 2005-2007 William C. BentonThere are four kinds of classes: instantiable, tester, application, and utility.7Copyright © 2005-2007 William C. BentonInstantiable classes model program-domain entities.8(What is a program-domain entity?)Copyright © 2005-2007 William C. BentonWhat are some instantiable classes we’ve seen so far?9Copyright © 2005-2007 William C. BentonApplication classes contain main methods and rely on instantiable classes to implement program tasks.10Copyright © 2005-2007 William C. BentonWhat are some application classes we’ve seen so far?11Copyright © 2005-2007 William C. BentonTester classes contain methods to systematically exercise every part of another class’ interface.12789101112Copyright © 2005-2007 William C. BentonUtility classes cannot be instantiated; rather, they contain useful class methods.13Copyright © 2005-2007 William C. BentonWhat are some utility classes we’ve seen so far?14Copyright © 2005-2007 William C. Benton15Instantiable classes model program-domain entities.(So: what is a program-domain entity, anyway?)Copyright © 2005-2007 William C. BentonA class should correspond to a single concept.16(What is a concept?)Copyright © 2005-2007 William C. BentonSome classes correspond to tangible real-world things: Clicker, Employee, CashRegister.17Copyright © 2005-2007 William C. BentonSome classes correspond to abstract concepts.18(What are some example abstract concepts?)131415161718Copyright © 2005-2007 William C. BentonSome classes are actors, which manipulate instances of other concepts.19(What are some examples?)Copyright © 2005-2007 William C. BentonGiven a problem description, you should be able to choose classes by identifying relevant concepts.20Copyright © 2005-2007 William C. BentonIs there a good, standard way to talk about these designs?21Copyright © 2005-2007 William C. BentonUML22•Simple way to show classes and relationships between classes•Describes all fields and methods declared in a class•Describes relationships (dependence, aggregation, subtyping) between classes and interfacesclick()reset()countClickerpunchIn()punchOut()getSalary()getHours()nameclickersalaryUsherhireUsher()fireUsher()ushers[]EmployeeDBjava.lang.StringCopyright © 2005-2007 William C. Benton23click()reset()countClickerpunchIn()punchOut()getSalary()getHours()nameclickersalaryUsherhireUsher()fireUsher()ushers[]EmployeeDBjava.lang.StringCopyright © 2005-2007 William C. Benton23Not shown:• + before public fields• - before private fields• static fields and methods should be underlined192021222323click()reset()countClickerCopyright © 2005-2007 William C. Benton24click()reset()countClickerpunchIn()punchOut()getSalary()getHours()nameclickersalaryUsherjava.lang.StringCopyright © 2005-2007 William C. Benton25punchIn()punchOut()getSalary()getHours()nameclickersalaryUsherhireUsher()fireUsher()ushers[]EmployeeDBCopyright © 2005-2007 William C. Benton26Copyright © 2005-2007 William C. Benton27Basic UML(subject to revision)methodsfieldsClass NameAggregatorAggregatedDependentClassCopyright © 2005-2007 William C. Benton(See Chapter 17.1 for more!)28Copyright © 2005-2007 William C. BentonA cohesive class is one that only implements a single concept.29242526272829Copyright © 2005-2007 William C. BentonCohesive or not?30•Coin class•CashRegister class that knows about U.S. currencies (or “all major currencies”)•Temperature class that includes getCelsius(), getFahrenheit() methods•Email client that can install software on your computer•Color class that knows about color spacesCopyright © 2005-2007 William C. BentonHomework exercise: Find one example of a real-world product that is not cohesive and email it to the class list.31Copyright © 2005-2007 William C. BentonTwo classes are coupled if they must know about one another.32Copyright © 2005-2007 William C. Benton33Alternatively, a class is coupled to another if it depends on that class.Copyright © 2005-2007 William C. Benton34Copyright © 2005-2007 William C. Benton35303132333435Copyright © 2005-2007 William C. Benton36Copyright © 2005-2007 William C. Benton37Copyright © 2005-2007 William C. Benton38Avoid excessive and bidirectional coupling.Copyright © 2005-2007 William C. BentonThe vending machine39•Design the classes for a vending machine•Holds cans of soft drink, keeps track of inventory•Accepts fifty cents in currency•Activates product selector when paidCopyright © 2005-2007 William C. BentonHow do we evaluate a design?40Copyright © 2005-2007 William C. BentonThe vending machine41•Design the classes for a vending machine•Holds cans of soft drink, keeps track of inventory•Accepts fifty cents in currency•Activates product selector when paid363738394041Copyright © 2005-2007 William C. BentonOK, but what about....•Debit cards?•Different product types?•Temperature-controlled discounts?•Is our design general enough to handle these cases?42Copyright © 2005-2007 William C. BentonWhat makes for a good design?43Good designs enable future improvements.Copyright © 2005-2007 William C. BentonWrap-up44•Read Alistair Cockburn’s “coffee machine problem” article•http://tinyurl.com/faq7r•Inspiration for vending machine problem•Why doesn’t Cockburn like UML? Is this an inherent limitation of UML as we’ve used it?Copyright © 2005-2007 William C. BentonAny questions?45Copyright © 2005-2007 William C. BentonSo, how do we come up with a good design?46...and meet changing requirements? ...and wind up producing a program that works?Copyright © 2005-2007 William C. BentonThe software lifecycle is the “big picture” of software development.47424344454647Copyright © 2005-2007 William C. BentonThe software lifecycle48•How do we go from an idea to a


View Full Document

UW-Madison COMPSCI 302 - CS 302 Chapter 9 Notes

Download CS 302 Chapter 9 Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view CS 302 Chapter 9 Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view CS 302 Chapter 9 Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?