Better programmer - be curious, observe, test and validate

I would like to share my algorithm how to improve your programming skills and become a better programmer. This will also help you understanding of programming and boost your analytical thinking.

This process include 6 steps:

  • be curios about programming - ask good questions about programming, about how something is working. Try to find what is behind the code, algorithm, problem and so on.
    Curiosity doesn't kill the programmer. The bad programmer kill his program.

  • Research and collect information - try to find as much as possible about your problem. Search on internet, ask in programming communities, discuss with friends.

  • Write a conclusion - At the end of your research make a theory about your observation. Write a short and conclusive answer to your question.

  • Validate - Try to validate your conclusion by tests. Try to test all aspects that you can think of. Is it true only for certain circumstances? Is it a general truth? Are there any exceptions?

  • Write it down - Once you finish with your tests - write the whole process from A to Z. Write all conclusions in structured and well organised format.

  • Apply your knowledge - And use this new principle in your work. You can change it according to the results of your job.

Example of the principle

Let say that you want to know about recursion:

Are there any advantages of recursion in comparison to iteration?

Observations and Research

Recursive version it's usually slower and usually uses more memory. Sometimes it is much simpler to write the recursive version(for examples when working with trees and repetitive invocations).

Recursion is good for expressiveness and mutability and not good in performance.

Lets test with code

On this page you can find good java example about non recursive Fibonacci and performance : Java 8 fast non recursive Fibonacci

  • iterative Fibonacci solution in python:
def f(n):
    a, b = 0, 1
    for i in range(0, n):
        a, b = b, a + b
    return a
  • recursive solution in python:
def F(n):
    if n == 0: return 0
    elif n == 1: return 1
    else: return F(n-1)+F(n-2)

another example about factorial

  • without recursion
int factorial (int N) {
  if (N == 0) return 1;
  int tmp = N;
  for (int k=N-1; k>=1; k--) tmp = tmp*k;
  return (tmp);
}
  • recursive example about factorial
int factorial (int N) {
  if (N == 0) return 1;
  else return (N*factorial(N-1));
}

Write it down in your documentation where you can find easily.
Write the conclusion and the code examples. This will help you to create a personal snippet bank. Here you can find how to write good documentation: Complete Guide to Developing a powerful documentation - Lab Diary

Use it in next tasks When you have new task try to find if your new conclusion is valid and applicable.

More about becoming a good programmer: better programmer

Related Article