Thursday, 11 August 2011

Integrated Development Environments for Programming - Enhance Program Readability for People

If you're just getting started with computer programming, you know that programs are written to be compiled so that a computer can read the instructions to carry out the program. While computers deal in 1's and 0's (transistors that are either on or off), humans obviously read with high level languages. In between these two extremes we find source code written in many different programming languages (like C, C++, and Java). Some of these programming languages lend themselves more to human readability (like Visual Basic) whereas others are quite cryptic (as with C or C++). Two main ways of providing human readability throughout the source code are 1) using comments, and 2) having ample white space. Integrated development environments lend themselves well to accomplishing these two tasks when programming for human readability. Also known as IDEs, they provide a framework with all the necessary components for creating a program from start to finish with a readable flow of the source code with the use of formatting.

Comments

Comments are easy to add to code. You can place them anywhere necessary to clarify various parts of the program. Comments are meant only to provide readability for people; in fact, all compilers ignore them. Comments provide programmers with the ability to go back and 1) update a program, 2) reuse blocks of code, and 3) debug (fix) a program. In addition, comments help other people sift through code should the need arise. Integrated development environments already format code for the programmer which makes placing comments a logical process. For example, you can place a descriptive comment at the beginning of a block of code, such as a function that has been formatted in the IDE with indented statements. Each programming language has its own specification for placing comments; for example, with C, you use /* comment */ or // comment. Sure, it's possible to comment too much, but commenting too little can be detrimental especially if not used enough in very long programs.

White Space

White space in programs greatly enhances readability for people. Without white space, a program would look like a jumble of characters (which is fine for compilers). Although compilers need a space here and there for various statements (such as for declaring variables), they ignore all white space anywhere in the code designed for human readability. However, white space is crucial for people to be able to decipher code. Integrated development environments really help out with the task of providing useful white space because they automatically format for it as they recognize various functions for the particular language. In other words, IDEs are built with readability in mind. For example, after the main( ) function in C, the IDE Code::Blocks indents all the statements within the function; the white space from the indentation helps you see the flow of the program much better. You should also provide plenty of white space throughout the program. For example, you can improve the readability of a mathematical statement:

avg=receipt1+receipt2+receipt3)/3.0;. Now, here's how this statement can benefit from white space: avg = (receipt1 + receipt2 + receipt3) / 3.0;.

Develop Great Programming Habits Now for Human Readability

As beginning programmers, we should start right away with developing great habits by implementing comments and white space throughout our code. Integrated development environments provide the platform for forming good habits right out of the gate. Always remember to comment often and use white space for greater readability. Later on when you need to refer back to the program's source code for updating or debugging, you'll be glad you did.

No comments:

Post a Comment