Design Again
Objectives
We would like to :
- Briefly discuss design methods
Notes
- We have been using a design method called Top Down Design
- Look at the problem and break it up into big steps.
- Then break the big steps down
- Repeat this until you get down to steps that are easy to implement.
- This method is also called functional decomposition.
- Because you think about how you are going to "do" the problem in terms of steps, which you implement as functions or methods.
- In general we want to build functions that are "cohesive"
- A cohesive function is a function that does one thing.
- You should be able to find a good name for a cohesive function.
- This leads to a type of programming called procedural programming
- This is NOT functional programming, which is a very different beast.
- We learned in the 60's that top down design might not be the best way to go.
- It does not scale well.
- And when a project is large, involving many people, it tends to fall apart.
- An alternative is object oriented design.
- In this case, we look at the pieces or objects that make up our problem.
- These might be real or just logical
- If you were simulating Monopoly, you would have property objects, a board object, possibly money objects, player object ...
- If you were writing a banking application, you would have a customer object, different account type objects (loan, savings) ...
- You then combine these objects to form larger systems to eventually solve the problem
- This is sometimes called bottom up design, as you look a the little pieces first.
- This type of design focuses on data and what you do to the data rather than on steps to solving a problem.
- Both are valid, and both are used.
- Java is specifically an object-oriented language and you will be learning OO design.