Wednesday, August 5, 2009

refactoring and performance

Many programmers always put performance at the first place in development. However, in my opinion, performance should be the last and least thing we need to worry about. Let's have a look at what Martin Fowler says in his book - Refactoring.

"To make the software easier to understand, you often make changes that will cause the program to run more slowly...but it also makes the software more amenable to performance tuning. The secret to fast software...is to write tunable software first and then to tune it for sufficient speed."

"Changes that improve performance usually make the program harder to work with"

"Build your programm in a well-factored manner without paying attention to performance until you begin a performance optimization stage, usually fairly late in development."

"A well-factored program ... gives you time to spend on performance tunning... Because the code is clearer, you have better understanding of your options and of what kind of tuning will work."

I always believe the first task for developer is to make the software easy to maintain, extend, modify. It also means we should focus more on architecture, structure, design, and coding style.

Unfortunately most of performance-first developers haven't realized that their performance achieved coding creates buggy, hard to understand and maintain system and finally achieves nothing but lost.

Why do we not just use assembly language for programming? We can get better performance than using C++, Java, PHP.

Why do we prefer OOP instead of coding in native language way? Native PHP language code runs faster than OOP code with those classes, objects.

Why do we break code into smaller pieces and functions? Putting everything in one function can save a lot of time than calling other functions and then return to the caller.

Why do we use template engine? Why not just embed PHP into HTML? It is faster.

Why do we use framework? It absolutely runs slower than a index.php.

Why do we use java? Every performance oriented programmer is crying Java is slow.

No comments: