For those new programmers, including me, it is very fascinating and exciting if we can create new things and make them work. After solving some struggle or tricky problems regarding to the codes and finally get what has been expected, we attempted to be satisfied enough that there is no need to fix or change since it just works fine.
The book called 'Code Complete' suggests us that if we already know how to program, then the next thing we need to know would be how to program efficiently. In order to become efficient, the book specifically suggests us to make use of routine.
What is Routine?
As the book 'Code Complete' states,
A routine is an individual method or procedure invocable for a single purpose.The book also mentions that we can evaluate routines we create as 'high-quality' or 'low-quality', and programmers can create efficient, faster programs in an efficient way by focusing on this notion of routine.
This is because the main purpose or the focus of making use of routine is to reduce unnecessary parts from your program and so create very readable, less complex, and faster program.
Hints to Create Useful Routine
Here are some points I personally think are especially important from the book:
- Name properly; Easily understandable, yet tells you what a routine does.
- One purpose per routine; Keep simple. Just like each method in Java is supposed to have only one functionality
- Try to shorten each routine; The book suggests less than 200 lines is appropriate.
Having mentioned some of the ways to create and make use of useful and efficient routine, let us not just satisfy ourselves by knowing how to create things; let us satisfy ourselves by knowing how to create efficient programs efficiently.