The 8 secrets of a successful programmer

The 8 secrets of a successful programmer


What makes a programmer go to work every day? It is definitely the love for coding and getting pleasure from high-quality code. But if a programmer really wants to enjoy coding and appreciation of colleagues, he needs to know some basic things. The author of this article shares the secrets of a successful programmer that may be useful for you in the future.

1. Code for human consumption


It is one of the most pervasive misunderstandings in computing that the source code is for the computer’s consumption. Computers work with low-level binary code, a series of impenetrable 1’s and 0’s or hexadecimal numbers, not the structured high-level languages we code in. The reason that these languages were developed was to help the programmer.

In practice, coding for human consumption means coding for clarity first, over efficiency and speed second.

2. Comment often and comment well


The comment is an extreme example of a language element for human consumption. Most compilers will strip the comments from the executable program. The purpose of the comment is to tell you (and any future developer) what the program is intended to do. Write comments with this in mind – and avoid simply restating the code.

Good comment: Calculate the gross asset value adjustment Bad comment: Set cmd Enabled = False

A good indication that you have got the level of comment right: could someone understand what your program is intended to do if all but the comments were removed?

3. Layout code to increase legibility


Just as it is important for an author to split a book into chapters and paragraphs that aid reading so it is important for the developer to consider the layout of the code and how that can aid the readability of the code. In particular any code branch (an IF..THEN…ELSE construction) and any code repetition (a WHILE…END WHILE construction) should be indented so that it is easy to see where they start and end.

4. Expect the unexpected and deal with it


Before you open a file, make sure that the file is present. Before you set focus to a control, make sure that the control is visible and enabled. Try to work out what conditions could cause your code to fail and test for them before they cause the program to fall over, and do not rely on error handling to.

5. Name your variables to aid readability


There are a number of strategies for variable naming. The key is to be consistent and to be as informative as possible. If you name a variable MonthNumber, you give the programmer extra information as to what that variable is expected to contain. Hungarian notation is harmful to readability – but whichever style you use, consistency is the key.

6. Keep your functions and subroutines simple


A function or subroutine should ideally only do one thing. One of the greatest sources of misunderstandings, in my experience, is a subroutine that does a number of different operations. This should be split into separate functions for each different thing it is doing so that these in turn are easy to reuse, and the scope of a code change is easy to understand.

7. Scope functions and variables appropriately


Functions and variables that are only used in one module should not be visible outside that module. Variables that are only used in a function or subroutine should not be visible outside that function or subroutine. This prevents any use of a variable or function outside of where it makes sense to use it.

8. Never stop listening and learning


So the eigth secret is to keep an eye out for new opinions and methodologies and to evaluate them in an impartial and rational way. This applies to your choice of language, operating system, back-end database, and development methodology.

There are many other hints and tips which can help you become a better programmer, which will make you more efficient and the programs you write more maintainable, but the eight secrets listed above will serve as a good foundation – however high you build upon them.

Add a Comment *

Name

Email *

Previous Post Next Post