Computational problem solving involves multiple steps, including programming.
- First,
the problem must be solved and well understood.
- Develop a design for the program based on the understanding of the problem.
- Write the program according
to the design developed in
the previous step.
- Thoroughly test the program to identify and fix any programming errors.
1. Understanding the Problem:
- Before
writing a program, it’s essential to develop a design for
the program.
- Computational
issues for solving the problem can be determined once the problem is
clearly understood.
Knowing What Constitutes a
Solution:
- Understanding
what constitutes a solution is essential. Solutions may include
finding a solution, an approximate solution, a best solution, or all
solutions.
- A
solution: A single valid solution that satisfies all the
problem requirements.
- An
approximate solution: A solution that may not
be optimal but provides an acceptable result.
- A
best solution: The most optimal solution based on
predefined criteria.
- All solutions: Every possible valid solution to the problem.
2. Program Design
Describing the Data Needed:
Based on the problem requirements, the data required for the program are identified and organized in a suitable structure.
Describing the Needed Algorithms:
- When
solving a computational problem, either suitable existing algorithms may be
found, or new algorithms must be
developed.
- There
are standard search algorithms that
can be used for various problems.
- For
problems where it’s infeasible to predict all possible outcomes, heuristic algorithms can
be used. These algorithms work well in general but are not guaranteed to
give the correct result for each specific problem.
3. Program
Implementation
- Design
decisions provide general details of data representation and
algorithmic approaches.
- Implementation
details, such as programming language choice and syntax, are
determined in the implementation phase.
4. Program Testing
Programming errors are pervasive and inevitable. Software testing is crucial for identifying and correcting errors.
Truisms of Software Development:
- Programming errors are inevitable.
- Software testing plays an essential role in software development.
- Any changes made in correcting a programming error should be fully understood as to why the changes correct the detected error.
Test case: A set of input values and expected output used to verify the functionality of a program.
Test plan: A
collection of test cases designed to ensure that a program meets all
requirements.