Stylish Coding

21 Sep 2017

Coding Standards

Coding standards are important in programming, especially when you are working with other programmers. I am sure that every educated programmer has had experience with coding standards either in the classroom, online, or in the workplace. Some of them like coding standards, others not so much. Some do not like conforming to standards and instead prefer to write code in their own personal style because they are more comfortable with it, while others actually prefer the coding standards and are willing to adjust. I believe that coding standards are essential in good programming. They are key in communication and they can help you learn how to code.

Communication

Coding standards are important in communication. You can not expect group projects will be successful if the only one who can read your code is you. Coding standards help prevent confusing formats of code from appearing. Let’s look at two examples of code.

function foo(){
while(true){
if(true){
for(true){
}
}
}
}
function foo2() {
    while(true) {
        if(true) {
            for(true) {
            }
        }
    }    
}

The first function is valid but how easy is it for you to tell which things are in which loops? It’s difficult to read and identify things. The second function is more organized and you can easily tell what belongs where.

Learning

Coding standards are a great way to learn programming. They make the code easier to read and easier for people to understand. It is easier to learn and understand things if the content is not different everytime you see it. If programmers follow a common style, then they can teach it to other programmers while they can also understand what they are doing. I think if there was a universal coding style, that would be great to implement so that everyone can be on the same page.