Is writing high quality code important?

Martin Fowler (1999) stated that

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

Why do we need to write clean codes as programmers?

I believe we must all take the time required to write a piece of clean code and deliver a high quality product rather than just writing some codes that are buggy, painful for others to read or maintain, and difficult to test.

Here are some quick rules you could adopt to improve your codes’ quality:Image representing quality code.

  • Use meaningful variable and method names
  • Do not hesitate to break huge block of codes into smaller functions
  • Always comment your work, for you to understand when you return to the same code in the future or for others to understand easily if they need to maintain the code
  • Follow naming conventions such as BEM for web development

Many organisations have their own standards or style when it comes to writing quality codes. This helps to ensure that all developers use the same writing style. It will be easier for each person to maintain codes written by others, since they all have a consistent way of doing things.

Software Testing

Another aspect directly related to quality of work is testing. Software testing should not be neglected as we all leave bugs when writing some piece of code. While developing, it is important to test extensively to avoid leaving bugs behind. From my own experience, around 25% of the whole development process is spent on testing. If a product is delivered without ample testing, it will be more expensive later on to correct bugs and it can also prove to be critical at such a point in time.

Here are some types of testing to consider:

Image showing finding a bug among binary codes.

Static testing & Dynamic testing
Static testing is reviewing of the code without running the application (at most one can launch the web interfaces). Dynamic testing involves interacting with the application.
Black box testing
During black box testing we test without knowing the code. We provide our input and see if the expected output is returned.
White box testing
During white box testing, we know exactly how the code will process our input, and we provide our test inputs based on that.
Test-to-pass & Test-to-fail
Test-to-pass is simply testing the code and see if it does what it is supposed to do. And test-to-fail is providing the incorrect inputs trying to make the code fail in any way.
Boundary conditions
It is the testing of the values of conditional operators and see how the code behaves with test values that are on the boundaries.
Unit testing
Unit testing is the testing of each individual function of a program.

In a nutshell, it is important to write codes without bugs, but it is even more important to write good quality codes, following your organisational standards or naming conventions. Also, do not forget to comment all your codes to clarify any functions or complex algorithms you may write. And, document everything as deemed correct. Lastly, just coding and meeting the specifications is not enough. Instead, enough time should be spent in testing the code rigorously, ensuring that a high quality product is being delivered.

Here are some additional resources for further reading.

One Response

  1. That’s why the editors have to be so hard concerning what is added, iff they really did permit
    any kind of old thing to be added wikipedia would be entieely useless.