Why should we adopt a standard coding style, what are the needs and benefits?

W

Adopting a standard coding style can make programs more maintainable and reduce confusion in open source projects and programming education. It encourages programmers to write readable code, which improves collaboration and code comprehension.

 

With the recent advancements in IT technology and people’s interest in the IT field, more and more people are taking up programming. It’s a world where anyone can create their own programs, albeit with less expertise, by buying a book and studying on their own or spending a few months at a programming school. This is due to the development of tools that make it easier for people to program. For example, Google distributes the Android Software Development Kit (SDK), a tool for developing programs that run on its smartphone operating system Android, for free, and the incredible ease of use it provides makes it easy for people with no expertise to program.
However, the fact that programming has become so accessible to everyone is not without its benefits. The democratization of programming has also brought with it a number of problems, one of which I’d like to discuss in this article is the problem that arises when people read program code written in different coding styles. Coding styles are like writing styles, if coding is analogous to writing. In the writing process, as long as the grammar is correct, readers will have no problem understanding what you’re writing, but writers use a style that is appropriate for the purpose of their writing to make it easier for readers to understand their thoughts. If the style is not appropriate, it makes it more difficult to understand the writing. For example, if an article is written in a colorful style rather than a strong, dry style, it’s harder to understand the intent. In coding, the same is true: as long as the grammar of the programming language is correct, the program will work. Add to that the right coding style, and the code becomes readable; on the other hand, if the coding style is not correct, the code becomes hard to read.
As programs get bigger, they need to be programmed by more than one person, so programmers need to write their code with readability in mind so that others can easily read and understand their code. However, non-programmers who lack programming experience are significantly less capable of writing readable code. This is because when people learn programming in a short period of time from a book or a school, they are taught how to make a program “work somehow,” but they are not taught how to write “readable code.” If someone writes code that is not readable, they will not only have a hard time collaborating with others, but if they need to modify the code later, they will have a hard time doing so because the code is hard to read.
How can we ensure that incoming programmers write readable code? In response, I’m going to argue for the creation of a standard coding style. By standard coding style, I mean that each programmer should abandon their own coding style and regulate it to a standard. Most programming languages that many programmers use today don’t care about the coding style of the programmer as long as they follow the grammar. By introducing a standard to regulate the coding style, we can reduce the problems that other people have when reading the code.
Of course, my argument for a standard coding style could be countered by the fact that everyone has their own preferred coding style, and a standardized coding style would be an uncomfortable constraint for some people. Not only is it very hard for programmers to code according to a prescribed coding style rather than their own, but working to a standard coding style can also increase their work time. Even I recognize the difficulty of coding outside of my own coding style. When I was working as a grading assistant for the Korean Information Olympiad, a programming competition, in June of this year, I was asked to write code that would be given to students as a model answer. Thinking that it would be easier for the students to read if I wrote code in a similar style to last year’s model answers, I tried to code as closely as possible to the coding style of last year’s model answers. However, because I tried to apply a coding style that was unfamiliar to me, I ended up coding what I could have coded in an hour in over two hours.
As such, the standard coding style is inefficient in terms of convenience and work time. Nevertheless, I believe that the standard coding style will have a positive effect in many more ways.
First, standard coding style is efficient when it comes to long-term maintenance of the program. Companies typically upgrade versions of their programs for months or even years after they are released, fixing newly discovered bugs and adding more features. Rather than developing a program from scratch, programmers work for a relatively long period of time, fixing bugs in existing code or adding new features to existing code. During this time, the programmers working on the program come and go, and in order for the new programmers to work efficiently, the existing programmers need to make the code as readable as possible. If there is a standard coding style, programmers don’t have to think about how to make the code more readable as they code, and when they read the code, it’s easier to read it because it conforms to the established coding style.
Some companies actually have a coding style and ask their programmers to code according to it to make maintenance more efficient. When I went on a tour of Google Korea five years ago, I was told that programmers are required to follow a coding style set by Google, and the company itself has set a coding style to reduce maintenance costs as the size of the program grows. On the other hand, a friend of mine’s game company doesn’t have a set coding style.
Second, in today’s trend of open source projects, a standard coding style will help programmers a lot. Open source is not limited to professional programmers, but is accessible to anyone interested in programming, including non-professionals. Open source is program code that is made available to everyone to add new features or improve existing inconveniences that were never before available, by turning programming over to the average user when it is too large to be managed by a small group of programmers. Because of the open source nature of being modifiable and redistributable by anyone, open source is often coded by multiple people and spread across the internet. This creates a conundrum for programmers who read the code because different people have different coding styles. Each part of the program code is written in a different coding style, which makes it quite uncomfortable to read. For example, I often download open-source programming code for computer graphics from the internet, and I struggle with the different coding styles every time I read it. If there was a standard coding style, I wouldn’t feel so uncomfortable when reading code downloaded from open source.
Third, in terms of programming education, a standardized coding style increases efficiency. For one thing, it takes the burden off of educators. In my experience as an instructor at a programming school, I spend a relatively large amount of time reading students’ code and fixing problems. The problem is that students are trying to write “code that works” instead of “code that reads well”. This hard-to-read code is not easy to find bugs in, so I have to spend a lot of time looking at it, which is very stressful for me. If students wrote code according to a prescribed coding style, I wouldn’t have had the difficulties I had. The claim of easing the burden on programming educators doesn’t only come from my experience. Many courses in Seoul National University’s computer science department, such as “Data Structures,” “Compilers,” and “Principles of Programming,” have some degree of “readability” in the homework code evaluation. This is to encourage students to write readable code, yet the TAs grading the homework complain about the difficulty of reading the code at every turn. This example suggests that a standard coding style would make things easier for educators.
From a student’s perspective, different coding styles among educators and students is confusing and demotivating. Every book or internet course that teaches programming has a different coding style, some of which are completely wrong, and because students don’t have the discernment to judge the right or wrong coding style, they are forced to learn as they are, and end up as programmers who haven’t learned how to write readable code. If there were a standard coding style, and it was taught as is, we wouldn’t even have to think about whether students’ code is readable or not.
So far, we’ve only discussed the effects of a standard coding style, but the feasibility of standardizing coding styles should also be carefully considered. The feasibility can be argued against as well. First, due to the limitations of mathematical models of programming languages, it is very difficult for computers to process not only the grammar of a programming language but also its coding style. Second, there is already a lot of program code out there written in different coding styles, so even if a standard were to be set, it would not be possible to convert all existing code to conform to the standard. Furthermore, there is the question of which coding styles should be standardized.
It’s hard to find a positive answer to these feasibility issues. However, as research on programming languages progresses, they are becoming more and more feasible. For example, Python, a programming language that has recently gained tremendous popularity and is used by many people, breaks away from the limitations of the mathematical model of traditional programming languages and adds a grammar condition called the “indentation rule” to regulate coding style.
In summary, setting standards for coding style can be very effective when considering the maintenance and upkeep of programs, in today’s open source paradigm, and from an educational perspective. Whether you’re a computer science major, a non-computer science programmer, or just someone with a passing interest in programming, you should strive to write readable code regardless of your level of coding proficiency. This is not easy to do in the absence of a standard coding style, and in this current climate, I believe it’s essential, even if some may argue against it.

 

About the author

Blogger

I'm a blog writer. I like to write things that touch people's hearts. I want everyone who visits my blog to find happiness through my writing.

About the blog owner

 

BloggerI’m a blog writer. I want to write articles that touch people’s hearts. I love Coca-Cola, coffee, reading and traveling. I hope you find happiness through my writing.