Saturday, February 12, 2011

Part 6: Thoughts of “How we do?” - Easy to Understand or Efficient in Execution


Task is this, we need to hang advertisement cards on the handrail of this train. But we have two types of advertisement cards say red and blue and the pattern should be like red blue red blue red, red blue red blue red.
Anyway, you are not suppose do this, workers will be given to you, you have to give him instructions and ask him to do.
You have two options to do this:
Option 1:
First give the red advertisement cards to the worker and hang on the start, middle and end of each handrails, then give the blue advertisement cards and ask to hang in between every red advertisement cards.
Option 2:
Ask the worker to arrange the advertisement cards as RBRBRRBRBR... then get one by one from the bundle and hang 5 in each handrail.

Lets check these options; in the 2nd option, we do some prearrangement, that means we have added another layer of abstraction and complexity. Need to analyze and understand that layer and test completely before use. In first option worker has to go along train two times, but in 2nd option if he goes once it is enough, the execution is efficient. But in first option we can start the task immediately or need very less time to analyze and understand. In 2nd option, need to spend some more time before start the task, to analyze and understand , is not easy to understand.

This is a simple example, but you may face lot more complex sample in your life. In business, sometimes, the start time of task is more critical than efficient of execution. for example, in option 1, you may be able to add another worker to hang blue cards. If you spend more time in analyzing then there are chances to loose the business. But sure, you cannot execute the business for long with an inefficient execution, you should analyze and make execution efficient. It is your choice to take according to your situation. But keep in your mind you have these options to choose from.

For programers, here is an example in Android, say you want to resize and crop an image.

Option 1 would be:


intermediate = Bitmap.createScaledBitmap(source, dstWidth, dstHeight, filter);

target = Bitmap.createBitmap(intermidiate, x, y, width, height);


Option 2 would be:


Canvas canvas = new Canvas(target);

Matrix matrix = new Matrix();

matrix.preScale(sx, sy);

matrix.postTranslate(dx, dy);

canvas.drawBitmap(source, matrix, paint);


Sure, there are lot more examples, you can find yourself and enjoy.