Skip to content

Putting it into Practice

We've come a long way! Time now to tackle a larger problem that will call on all of what has been covered thus far. Before getting into the brief though we'll look at an approach to tackling any larger problem from scratch.

  1. Resist the temptation to start coding too quickly. Time should be spent thinking about the problem to be solved and using pen and paper make notes, diagrams, calculations as needed etc.. Sketch out sample solutions and work through the solution in the same way a computer might to convince yourself it is a good solution.
  2. What problem is the program going to solve? List the objectives of the problem.
  3. List both the inputs to the program, and the outputs. What data, and what type of data, is needed. The list is the data dictionary. Does data need to be saved to a file? What format should that be?
  4. Can the data be organised into structures? That is, arrays or structs etc..
  5. Break the problem down into smaller sub-problems, and as needed break these sub-problems down into sub-sub-problems! This will reveal the required methods. Again, make a list of these noting their signature (i.e. their name and any parameters required).
  6. Create a structure/hierarchy diagram to show how the methods connect with each other
  7. Sketch out the algorithm for each of these methods. This needn't (and probably shouldn't) use C# just use a form of pseudocode, structured English, or flowcharts (or a combination).
  8. Design the user interface. We're in console mode at the moment so it'll be text but will you need different screens showing different information? Plan them, and draw them. What is the purpose for each screen?
  9. How can you test if your program, or method, is functioning correctly? What tests should be used to prove this? Don't forget validation of inputs and handling of exceptions. Just because you ask the user to enter a 'Y', does not mean they will!
  10. Once all these things have been considered you're in a position to start implementing. Write the code step by step, testing each new method you write as you go, adding in new functionality gradually working your way through the list of required methods.
  11. Remember the maxim: "If you fail to plan, you're planning to fail"

Go to the next section to start the project.