The best first step in solving a programming problem is to describe the problem to yourself. You cannot expect an adequate solution unless you understand the problem in your own terms.
#programming #problems #solutions #solving #understanding
Ask yourself some basic questions:
- What needs to be done? Describe the general goals that the program must achieve.
- What are the big pieces of the problem? Consider the steps required to reach the overall solution of the task. How do the pieces fit together?.
- What is the scope of the problem? Try to identify issues that concern you as well as those you can ignore.
- What resources are available to you as the programmer? Common operations are often captured in library routines. Often you can find examples of programs that perform similar tasks or that provide a certain part of you solution. In many cases, you can discuss the reasoning behind the example code with the programmer who wrote it. Avoid doing work that already been done. However, you must be aware that someone else's model for a solution may not be compatible with yours.
- What kind of inputs is supplied and who supplies it? Certain programs require user interaction, while others receive input from other programs.
- How does the program demostrate that the desired task is complete? The program might succeed quietly by calling other programs or by properly initializing a device. It could also return formatted results, including sophisticated charts and tables.
- Who will use the program? A novice user might require a simple and friendly interface, while a sophisticated user might expect more features and some access to program itself.
- What constraints limit the approach to the problem? Often the programming projects must conform to strict deadlines, or the resulting application must be compatible with the existing programs or must run within a limited amount of physical memory. The environment of the target system might also lack certain resources.
Conceptualizing the problem might give you some ideas about its solution and how that solution might best be expressed.