Recently I had an interesting discussion with some programmers about programming issues. I often have the impression that some programmers overemphasize code cleanliness. Don't get me wrong, I also value clean code and have written many articles over the past few years emphasizing its importance. But when I code, code cleanliness is only my second most important goal; it will never replace my primary goal: getting the software running first. Making it run beautifully is my greater wish.
When talking about clean code, many people can say a lot with great interest. They persistently pursue this goal, and sometimes when programming they even wear clothes with Uncle Bob's green promotional icon to remind themselves of what is most important: writing clean code. Unfortunately, on many occasions I have found that while many people value the "appearance of code," they neglect to place the "functionality of code" in an equally important position. For example, many people are unwilling to learn the underlying principles of ORM implementations; they prefer to use tools like Hibernate entity mapping to map data into entity objects, even when doing so is surprisingly inefficient compared to directly fetching data. They do not consider the cost of multiple remote calls or the cost of transferring large amounts of data. They again and again just cannot write a good bowling game because they put database operations inside loops.
Clean code is not a necessary condition for a good program, and a good program is not necessarily clean code. To me, a good program is code that runs well, is easy to understand, and is easy to modify. These are in their order of priority. I know everyone understands very well that code's ease of understanding and ease of safe modification are very important. But no matter how clear, easy to read, and easy to modify the code is, if it does not do what it is supposed to do (cannot cover all corner cases), or takes an unreasonably long time to execute operations, then it is not good code. Of course, it is clean, but useless, isn't it?
I am not encouraging you to optimize prematurely. Unless you have skills like Neo in The Matrix, at least a quarter of the programs you prematurely optimize will be incorrect. The most important thing in optimization is to find the bottleneck; all other efforts are wasted.
In any case, you should write clean code. But you should think twice, and not give up writing good code for the sake of code cleanliness.
Original source: http://www.vaikan.com/clean-code-versus-great-code/