Easy Tutorial
❮ Android Tutorial Intro Cpp Enum Intro ❯

Neat Programs and Good Programs

Category Programming Techniques

Recently, I had an interesting discussion with some programmers about programming issues. I usually have the impression that some programmers overemphasize the neatness of the code. Don't get me wrong, I also pay attention to the neatness of the code and have written quite a few articles emphasizing the importance of neat code in the past few years. But when I program, code neatness is only my second priority, and it will never replace my primary goal: to get the software running first. Making it run beautifully is my greater wish.

When talking about code neatness, many people can speak with great interest. They persistently pursue this goal, and sometimes they even wear clothes with Uncle Bob's green propaganda logo when programming, to remind themselves what is most important: writing neat code. Unfortunately, I have found many times that while many people pay attention to the "appearance of the code," they neglect to put the "function of the code" on an equally important position. For example, many people are unwilling to learn the underlying principles of ORM implementation, and they prefer to use something like the Hibernate entity mapping tool to map data into entity objects, even when doing so is surprisingly inefficient compared to directly obtaining data. They do not consider the cost of multiple remote calls or the cost of large data volume transmission. They keep writing a bad bowling game because they put database operations in a loop.

Code neatness is not a necessary condition for a good program, and a good program is not necessarily neat. For me, a good program is code that runs well, is easy to understand, and easy to modify. This is their order of priority. I know everyone is very clear that the ease of understanding and safe modification of the code is very important. But no matter how clear and easy to read and modify the code is, if it does not do what it is supposed to do (cannot cover all corner cases), or spends time executing operations that it should not have used, it is not good code. Of course, it is neat, but it is useless, isn't it?

I am not encouraging you to optimize prematurely. Unless you have the skills of Neo in "The Matrix," at least a quarter of your code optimized prematurely is incorrect. The most important thing about optimization is to find the bottleneck, and other efforts are wasted.

Anyway, you should write neat code. But you should think twice, don't give up writing good code just for the sake of code neatness.

Original source: http://www.vaikan.com/clean-code-versus-great-code/

** Click to share notes

Cancel

-

-

-

❮ Android Tutorial Intro Cpp Enum Intro ❯