8 characteristics of good software code

Ngoc Huynh

Software code seems pretty ubiquitous these days, since software seemingly powers everything around us, from computers to cars to refrigerators. But not all code is created equally. Different software programs, even those that are meant to serve the same purpose, can differ greatly in the quality of their writing. What defines “good” software code? Developers will often have different answers to that question. However, a handful of qualities are often cited as being characteristic of well-written code. Here are 8 such characteristics and developer input, culled from various online discussion forums where the question “What makes good code?” was kicked around.

It works

Software, ultimately, is meant to serve a purpose. While some developers feel it goes without saying, others still feel it necessary to say that the first thing good code must do, simply, is work. If the code doesn’t fulfill the needs for which it was originally designed, then it cannot possibly be considered good.

It’s easy to read

Developers seem to agree that one of the most important qualities of code is its readability. Code that’s written in a way that makes it easy for other programmers to understand with a minimal amount of time and effort is considered top notch. Good naming, clear control flow, and smart smart use of comments all help to make reading code much less of a chore and, hence, easier to maintain, extend or reuse.

It’s testable

Software developers generally agree that a requirement for code to be considered of high quality is that it can be tested. More specifically, good code should be testable programmatically. In other words, the code has been written in a such way that automated (unit) tests have been (or, at least, could be) created to ensure that each component of code does what it’s supposed to do.

It’s easy to maintain

No matter how well a piece of code is written, bugs will be found that will need to be fixed. The ease (or difficulty) with which that can be done will depend on things like its readability, modifiability, and simplicity. Whether the original developer or someone else will have to do this work, programmers agree that code which is easy to maintain is considered to be good code.

It’s pleasant to look at

While the look of source code isn’t related to how it actually performs, it can still matter to developers. The use of proper formatting such as spacing, indentation, and capitalization can make a software program easier (or, at least, more pleasant) to read and, hence, understand. Many programmers think that better looking code is higher quality code.

It’s easy to change

The functionality of an existing piece of code will often need to changed, expanded or reused elsewhere in the future. Good code is often considered to be that which can be modified with a minimum amount of effort. Most importantly, developers like code that can be changed without causing unpleasant side effects.

It’s simple

A piece of source code may ultimately be doing complex things, but the best code, developers often say, is often very simple. This means many things such as avoiding deeply nested loops, big if/else statements, and keeping methods, functions, and other blocks of code short and highly focused. The best code writers will know how to get the job done without over-complicating things.

It’s efficient

To some developers, the best code is code that runs fast and uses minimal system resources. Run time efficiency is considered especially important for software that’s meant to perform computationally intensive tasks, such as in scientific computing. Faster execution times can often come at the expense of code readability, a tradeoff that some developers are willing to make.

Share the news now

Source : http://www.itworld.com/