Showing posts with label architecture. Show all posts
Showing posts with label architecture. Show all posts

Friday, November 5, 2010

On perspective (or "concentrate on what's important")

"We already have this great framework we use during the main data processing, why not for user management?"
Or
"There's already a bulk of code responsible for loading and saving millions of records - why should I write something new to load and save configuration records (all 10 of them)?"

I hear those (and similar) often. Or worse, I don't hear them, just see the commits in the version control. I think this is a price we pay for modularizing our code. The more functional and setup-free, the easier it is to reuse a piece of code in many contexts.

When a developer write a piece of code, he usually has a specific use-case in mind. This drives performance requirements, defaults, existing fixtures that need to be in place and other "non-functional" requirements. Innocently, that developer checks-in the code, usually along with it's dependent "client" code (and hopefully, some tests), and says to himself "Good job. Well done, me - time for some coffee".
Then, another developer appears. Let's call the first one "Fred", for being a Framework developer, and the newcomer "Cliff", for developing a new Client code.
So, anyway, Cliff comes in with a new requirement - create a client to change a specific configuration. Since Cliff is "constructively lazy", he asks around for some similar pieces of code to what he needs. Cliff finds Fred, still drinking his coffee and basking in the warmth that comes from a job well done. Fred tells Cliff - "Oh yes, I've just checked-in a very useful piece of code for the highly complex, extremely sensitive, super-important project from the high-lord boss. It's a beauty.". Cliff is happy now - all he needs to do for his tiny client part that, truly, is not that important to the main business, is link it with the shiny new framework Fred has written. He does so, and shortly joins Fred for some black tea (anything with caffeine goes...).
The result is that now both the "super important" code (main data processing, critical engine part, analysis engine...) and the relatively "less important" code (system configuration load and save) use the same underlying code - the framework code. However, all Cliff needed was a simple SQL statement - one for loading, one for writing.

Think about it like this - it's reasonable to hire a chef to cater for out important formal Dinner. However, you probably don't want the same chef, his sous-chefs, the kitchen boy and the delivery girl all running in your kitchen, just because you're peckish and want to grab a cold snack.
The smarter that framework is, the more sophisticated its analyzers are, the bigger the cost is when using it on a non-main path. Easy tasks should have easy solutions. The fact that the engine is there, ready to be used, doesn't mean it should be used - there are usually many hidden costs ("non functional" - remember?). Not to mention the extra coincidental dependency that now exists. Think about it the other way around - you wouldn't use the simple code for your main flow. If you try that, you'll hit problems very soon - performance, compatibility, corner cases. However, no one thinks twice about using the complex code in use cases analogous to opening the fridge and getting a chocolate bar.

To finish, a very known quote from an old Chinese master (paraphrased): "Don't use a cannon to kill a mosquito".

Friday, October 29, 2010

On the old and the new

"Out with the old, in with the new" - this statement doesn't really work in software. We cherish the old. We like the familiar. We cling to what we know, and label everything else as "not mature" or even just plain "risky".
And we should. The new is often wrong. In the "old days", there were a lot of "new" ways of doing what we now need. Evolution (mutation and natural selection) culled most of these and left us with a golden way of "how it should be done". But this kind of process takes time - so that shiny "new thing" is now the "old and familiar".
However, once in a while we get to hear the big news - "500M users due to an innovative design", "Millions of requests per second" (but using out-of-this world architecture), "Terrabytes of memory available for use" (but re-implementing everything we thought we knew about VMs). While the growth is usually gradual, the change in thinking that enabled these is instantaneous. You either try to migrate to a new database or not. You either try to build your data centers with second grade equipment, or not. You either rewrite stuff from scratch - or fight the same battle everyone else is.
I envy those with both talent and guts to go the distance. I pity those who fail. I glorify those who succeed. And sometimes - I try to push a little on my own little corner. Maybe shake a few old cobbles loose and let some new light shine in
I think a statement that fits the software world much better is "no pain, no gain".