2.2. Developing a Program Plan

Let's put what you've learned thus far to use designing a program. Of necessity, we'll leave out some code that would make your little program more bulletproof simply because you haven't learned how to do that yet. (You will learn how to make programs more bulletproof soon enough.) The goal here is to show you how to start writing a program to solve a specific task.

2.2.1. Where to Start?

Without a doubt, the hardest thing for beginning programmers to figure out is where to begin writing a program. As a general rule, students start solving a program problem by dragging and dropping controls from the toolbox onto a form as the first step in writing a program. Wrong! Don't confuse movement with solutions. If you start dragging and dropping objects all over the place without a coherent plan, you're in for some unexpected disappointments. Inevitably, you'll end up backtracking and developing a plan of attack for the task at hand, so you may as well start out with a plan in the first place.

Indeed, to write good programs you must have a plan. Central to a programming plan is an algorithm. An algorithm is simply a step-by-step recipe, or plan, for how you want to solve the programming problem at hand. A good place to start a program plan is with the Five Program Steps.

2.2.1.1. The Five Program Steps

As a broad generalization, you can describe all programming problems in terms of five steps.

2.2.1.1.1. Step 1: Initialization

This step involves those ...

Get Beginning C# 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.