Programming Advice needed

Mohammad Rahman

Estimable
Jan 15, 2015
2
0
4,510
How to cope up with the Frustration and falling in to the eternal confusion and mental stagnation of not being able to

a) Solve a problem
b) Find and fix the Bug
c) Design the logic

Help pls!
 

Pinhedd

Distinguished
Moderator


Computers do not do what the programmer wants them to do, they do exactly what the programmer tells them to do.

Most languages and compilers have some mechanism for detecting syntactically valid but obviously unintended instructions. These are rarely problematic. What's problematic are the syntactically valid but unintentionally flawed instructions.

As a beginner, the best advice that I can give you is to learn to think like a computer. If you can do this, debugging will become second nature.

Step 1: Create a flow chart detailing the logical progression of the program including all changes in state, decision points, inputs, and outputs. Be as descriptive and verbose as possible.

Step 2: Create a written, step-by-step guide detailing what you want the program to do at each step detailed in step 1.

Step 3: Write the program. Be as verbose as possible, use as much memory as you need, don't take shortcuts. Carefully document how each portion of the program relates to each element in your flow chart. Then, reverse reference your flow chart to your program to make sure that everything is accounted for.

Step 4: Run the program with some hand-crafted test cases. Press it with stranger and stranger inputs until it breaks. When it breaks, write a brief description of why you think it broke and try and design a fix. Repeat.

Step 5: If the cause of a problem is not immediately obvious (it rarely is) and can't be solved through simple inspection, learn how to use a debugger.

I can't speak for everyone, but I'm most comfortable when I can get my hands up inside of a computer and fondle the memory a little bit. I don't like to rely on automated tools to do my work for me. Effective programming and problem solving is built on an awful lot of practice (especially best practices), sleepless nights, and pattern recognition.