Software developers are responsible to make ideas into reality. It doesn’t matter of size whether a startups, medium-size or big company, developers are the back bone. While developing or creating new thing, developers should follow some basic rules of writing code. Its really helpful to write a readable, structured programming code, which is easy to debug. We are going to look into basic coding rules using and how to improve your web development skills. We took PHP code example in this article to understand the importance of structured coding.
Basic rules to improve web development skills
1) Naming convention
Name is a word or set of words by which a person or thing is known. We heard and read about the naming convention since engineering days. Generally freshers does not bother about naming convention. One of the famous quote of William Shakespeare’s “What’s in a name? that which we call a rose By any other name would smell as sweet”. Initially our thought match with Shakespeare and we start giving name like abc, xyz etc. Lets have a look of code without naming convention.
class abc{ function abcd(){ var a,b; } }
Above code is having a class, function and two variables. We do not have any idea what is the class of abc , what function abcd is going to perform and what is the use of two variables. If you ever debug the code like above, you will realise that who has written this code.
Naming convention are important while writing the code. It is easy to read, debug the code which follow naming convention. Lets have a look for above code with naming convention.
class calculation{ function sum(){ var int_one, int_two; } }
Now anyone can say that above class is for calculation, function is for sum two variables and two integer variables. Naming convention make code easy to understand, debug ,modification etc.
2) Comments
Comment is the part of coding which does nothing in terms of functionality. Many of us generally do not use this however comment is one of the most important part of coding. Lets have a look for above class example with comment.
/** * Calculation class for mathematics functions. * It has one function sum which took two integer params. **/ /*** class declaration ***/ class calculation{ /*** function sum code start***/ function sum(){ var int_one, int_two; } /*** function sum code end ***/ } /*** End class calculation ***/
3) Section
Section is one of the ways for breaking code in section. Section is one of the powerful tool, can be used for debugging. Section becomes important when you write a lengthy code e.g. 100 lines of code. We use comment to divide code in section. Like in calculation class, We use function end and start comment.
4) Alignment
Alignment is tool use for arrangement of code in section. It feels and looks good if you align your code. We generally use tab or margin for alignment. In calculation class we use alignment to divide code in section. Lets write above code with alignment.
/** * Calculation class for mathematics functions. * It has one function sum which took two integer params. **/ /*** class declaration ***/ class calculation{ /*** function sum code start***/ function sum(){ var int_one, int_two; } /*** function sum code end ***/ } /*** End class calculation ***/
Now you can easily see difference between align and not-align code. Alignment becomes important if your code have many loops. you can easily find out where loop start and end.
Conclusion
Hence by following above guidelines, we can create structured programming code, which easy to maintain, debug etc. It will also help us to improve productivity as it save time during debugging or modification process. Feel free to contact us if you have any further queries.