Imperative design

in

Today I have fixed an "optimization" which caused up to 10x performance degradation. In case you are interested, it was my optimization. And no, it was not iterating over 1000000-something long list. And it was not some hastily assembled patch. It was deliberately engineered optimization. I didn't even care to check how well it optimizes - so obviously neat it was. Instead of blocking and waiting for signal, I just returned ERESTART to the caller and looped there with a small sleep. It was saving me a whole bunch of pthread calls.

In this connection Teemu has put forward a cool maxima: "If your code needs to call sleep(), there is a problem with design."

At first you wonder, how can you live without sleeping there. But then you realize how weak this code really is, and that sleep() was just a half-hearted attempt to avoid solving the problem. And just with a little more thought you find a much better and solid solution.

This is just another one of SW design imperatives which really prevents you from going astray when you get a coding fit. The trick is to keep them all in mind.

Teemu has shown me the way! It's amazing! I'm just sooo totally happy!

XOXOXOX