18 November 2010

Webinar: Message-Driven Architecture with Spring

Hurry up and register for today's webinar @ spring source that would discuss topics related to message driven architecture.

More information here.

15 November 2010

OpenFest 2010

OpenFest is coming on the 20th and 21st of November at the Interpred building in Sofia. Access to the event is free of charge.
Check out the program. I'd probably visit these lectures :
* JavaScript Progressive Enhancement и Event-driven architecture
* NoSQL бази от данни – възможности и приложение
* grsecurity на теория и практика
* Модерни програмни езици за Java Virtual Machine

08 November 2010

Premature optimization

I am becoming more and more a fan of code minimalism. I've recently had several tasks that were aimed at "optimization" and "improvement" of the code and encountered the most visible signs of premature optimization ever. Talk about waste of time ...

First of all what is premature optimization? Wikipedia states that:
"Premature optimization is a phrase used to describe a situation where a programmer lets performance considerations affect the design of a piece of code. This can result in a design that is not as clean as it could have been or code that is incorrect, because the code is complicated by the optimization and the programmer is distracted by optimizing."

Not much information there. So what are the most usual signs of premature optimization? Well here is my initial list:
1. Optimizing something that was never an issue in the first place - you have a perfectly working functionality but a decision is made to refactor it to increase it's performance. Consider this - was performance ever an issue? Is this change going to bring any value of for the customer? What is the associated risk with this change? How much time would this change require?
2. Optimizing without clear benchmarking results - there is a hypothetical performance gain but there is no clear evidence that it would help in the specific situation. In this case the questions would be : Is there any physical evidence that this optimization would actually increase the performance? Is the source of this information trustworthy?
3. Optimizing would lead to undetectable performance gains - yes, improving some algorithm to run 2 times faster seems like a good idea, but if the actual difference is for it to run 1ms against running for 2ms would this actually benefit the application as a whole? Another example is improving a script that runs only once at program start up etc. In such cases the main question is if this investment in development is worth the time.

In most cases I've found that the answers to these questions completely change the perspective on whether or not such an optimization is necessary. Don't get me wrong - I am a strong supporter of code quality and optimization. But developers often tend to optimize prematurely and they need to always control these "urges".

Of course on of the most good examples is when the optimization is suggested by somebody without technical knowledge such as a product owner or designer. Sorry guys, I truly appreciate your work, but the thousands of designer forums that suggest always using a single CSS file for any developed web site are just showing what I meant in the first place. No clear evidence (tests with both approaches and comparison results), no exceptions (no single approach is valid for all cases, there are always exceptions) etc. This is just a bad opinion that is circulating throughout the entire web, a rumor that could (in my opinion) easily be proven wrong.