UW-Madison COMPSCI 302 - CS 302 Chapter 9 Notes (12 pages)

Previewing pages 1, 2, 3, 4 of 12 page document View the full content.
View Full Document

CS 302 Chapter 9 Notes



Previewing pages 1, 2, 3, 4 of actual document.

View the full content.
View Full Document
View Full Document

CS 302 Chapter 9 Notes

94 views


Pages:
12
School:
University of Wisconsin, Madison
Course:
Compsci 302 - Introduction to Programming
Unformatted text preview:

Chapter 9 Copyright 2005 2007 William C Benton 1 1 2 2 3 3 4 4 5 5 6 6 Chapter 9 is a sort of catch all chapter we ll review a few things and talk about design Copyright 2005 2007 William C Benton Scope 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 header Copyright 2005 2007 William C Benton What is a side effect Copyright 2005 2007 William C Benton How are parameters passed to methods Copyright 2005 2007 William C Benton Rest assured that we ll have an exercise on these topics later this week Copyright 2005 2007 William C Benton There are four kinds of classes instantiable tester application and utility Copyright 2005 2007 William C Benton 7 7 8 8 9 9 Instantiable classes model program domain entities What is a program domain entity Copyright 2005 2007 William C Benton What are some instantiable classes we ve seen so far Copyright 2005 2007 William C Benton Application classes contain main methods and rely on instantiable classes to implement program tasks Copyright 2005 2007 William C Benton 10 10 11 11 12 12 What are some application classes we ve seen so far Copyright 2005 2007 William C Benton Tester classes contain methods to systematically exercise every part of another class interface Copyright 2005 2007 William C Benton Utility classes cannot be instantiated rather they contain useful class methods Copyright 2005 2007 William C Benton 13 13 14 14 15 15 16 16 17 17 18 18 What are some utility classes we ve seen so far Copyright 2005 2007 William C Benton Instantiable classes model program domain entities So what is a program domain entity anyway Copyright 2005 2007 William C Benton A class should correspond to a single concept What is a concept Copyright 2005 2007 William C Benton Some classes correspond to tangible real world things Clicker Employee CashRegister Copyright 2005 2007 William C Benton Some classes correspond to abstract concepts What are some example abstract concepts Copyright 2005 2007 William C Benton Some classes are actors which manipulate instances of other concepts What are some examples Copyright 2005 2007 William C Benton 19 19 20 20 21 21 22 22 23 23 23 23 Given a problem description you should be able to choose classes by identifying relevant concepts Copyright 2005 2007 William C Benton Is there a good standard way to talk about these designs Copyright 2005 2007 William C Benton UML 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 interfaces Copyright 2005 2007 William C Benton Usher name clicker salary punchIn punchOut getSalary getHours Clicker count click reset java lang String EmployeeDB ushers hireUsher fireUsher Copyright 2005 2007 William C Benton Usher name clicker salary punchIn punchOut getSalary getHours Clicker count click reset java lang String EmployeeDB ushers hireUsher fireUsher Not shown before public fields before private fields static fields and methods should be underlined Copyright 2005 2007 William C Benton Clicker count click reset Copyright 2005 2007 William C Benton 24 24 25 25 26 26 27 27 28 28 29 29 Usher name clicker salary punchIn punchOut getSalary getHours Clicker count click reset java lang String Copyright 2005 2007 William C Benton Usher name clicker salary punchIn punchOut getSalary getHours EmployeeDB ushers hireUsher fireUsher Copyright 2005 2007 William C Benton Basic UML subject to revision Aggregator Dependent Aggregated Class Class Name fields methods Copyright 2005 2007 William C Benton See Chapter 17 1 for more Copyright 2005 2007 William C Benton A cohesive class is one that only implements a single concept Copyright 2005 2007 William C Benton Cohesive or not Coin class Temperature class that includes getCelsius getFahrenheit methods Email client that can install software on your computer Color class that knows about color spaces CashRegister class that knows about U S currencies or all major currencies 30 30 31 31 32 32 Copyright 2005 2007 William C Benton 33 33 Copyright 2005 2007 William C Benton 34 34 Copyright 2005 2007 William C Benton 35 35 Copyright 2005 2007 William C Benton Homework exercise Find one example of a realworld product that is not cohesive and email it to the class list Copyright 2005 2007 William C Benton Two classes are coupled if they must know about one another Copyright 2005 2007 William C Benton Alternatively a class is coupled to another if it depends on that class Copyright 2005 2007 William C Benton 36 36 Copyright 2005 2007 William C Benton 37 37 38 38 39 39 40 40 41 41 Avoid excessive and bidirectional coupling Copyright 2005 2007 William C Benton The vending machine 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 paid Copyright 2005 2007 William C Benton How do we evaluate a design Copyright 2005 2007 William C Benton The vending machine 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 paid Copyright 2005 2007 William C Benton OK but what about Debit cards Different product types Temperature controlled discounts Is our design general enough to handle these cases Copyright 2005 2007 William C Benton 42 42 43 43 44 44 45 45 46 46 47 47 What makes for a good design Good designs enable future improvements Copyright 2005 2007 William C Benton Wrap up 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 Benton Any questions Copyright 2005 2007 William C Benton So how do we come up with a good design and meet changing requirements and wind up producing a program that works Copyright 2005 2007 William C Benton The software lifecycle is the big picture of software development Copyright 2005 2007 William C Benton The software lifecycle How do we go from an idea to a design to a working program How do we think about this process Copyright 2005 2007 William C Benton 48 48 49 49 50 50 50 50 50 50 50 50 The waterfall model is an old way of looking at software Copyright 2005 2007 William C Benton Analysis Design Implementation


View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

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 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?