Decomposing a Problem
Start with a plan! The more time you spend planning, the
less time you will spend debugging!
Procedural Design
- Divide and Conquer-divide a large problem into smaller
problems that can be solved independently (also called top-down design and
step-wise refinement)
- Flow-charts (helpful in identifying loops)
- Pseudo-code (writing out steps in English)
Object-Centered Design
- Identify data and the operations to be performed on that data
- "Clouds"
- Advanced tools: Rational Rose (Modeling tool) and UML-Unified Modeling
Language
General Principles
- Generalize the problem-think about it abstractly. This way your
resulting product will be "reusable" code.
- Think carefully about the input and output. Use "storyboards" to aid
in the design of more complex interfaces.
Words to the Wise
- Comment as you go--you will find your own bugs this way!
- Repetitive code is usually a sign of weak design. Don't
"break" out of loops. Don't use global
variables. "Hiding" information will help to prevent, or at least
isolate, bugs.
- Test each component separately. Comment out code and print the
values of variables to help you isolate bugs.