Issue 8, October 20, 2007

THE artistic programming NEWSLETTER

paint your dreams!

The eighth issue is back with a bang with some solutions to stimulate your programming senses. Give yourself a break too this festive season. Try it. It's not all that difficult.

A Quick Word

As you sit back and read every word of this newsletter carefully, you will be learning "Magic" here.

How was your experience with the programming assignment in the last newsletter?

Most programmers did find the assignment "easy but comprising a number of details to be taken care of".

If you are like most programmers, you would have tried to figure out the logic of the program—keep a track of the Ls and Rs etc. etc.
 
"What else would any one do?" I can almost hear you say that :-))
That is where the differentiator begins.

The solution to this programming seems obvious, there is nothing much to be done about it. This is how you must have felt several times before about your programming assignments at work—something felt so simple and obvious, but when you got stuck while writing that program, you often ended up spending several days to figure out a simple error in the code...that missing semi-colon that kept you awake for so many days...
 
We need not have to live with such situations.
 
A lot of your effort can be made simple—if you would take one more step—devise a "Catabolising Strategy" for implementing this program—breaking down the problem into such simple steps that makes the problem very interesting, exciting and yes, extremely simple.

No, I am not talking about "modularization" here—the golden principle of breaking down things in small modules and implementing them one by one—that your project leads have taught you.
I am talking about approaching this problem with a probing mind that looks for creative ways to turn this apparently dull problem into a series of extremely simple and interesting steps, each of which could be implemented, tested and verified in minutes.

Effective programming is much more than the program logic and algorithms.

What could be a good "Catabolising Strategy" for this programming assignment?

CS

What additional steps could you take that will make the whole problem so simple that it could be designed, implemented and tested in 30 minutes flat?

Sounds too good to be true?

Let us see.

What are the different aspects of the problem that add to the program's complexity?

There are several of them:

i) The logic for scoring in tennis: 15, 30, 40, game, deuce, advantage, tie-breakers—a hell lot of things to be taken care of.

ii) Keep a track of who is on the left or right side

iii) Keep a track of who is serving

Suppose you follow a strategy that looks like this:

1. First of all, just implement the scoring logic, assuming that all points go to a single player. (You can assume a variable currentPlayer and all points are given to the currentPlayer). This module can be independently tested by running a loop that keeps giving point to a player and all you need to verify is that the output follows a pattern : 15-0, 30-0, 40 - 0, Game XXX, Set end, etc.

2. Once you have got this done, it is a simple change to update the value of the currentPlayer based on whether the input is "L" or "R". Even at this point, you can assume that the players aren't changing sides. May be, you have two variables to keep track of the left- and right- side players whose values remain constant, and the currentPlayer is updated either to point to the left- or right- based on whether "L" or "R" is entered. This will again be very easy to test.

3. Now, we can introduce changing sides. After the first game and then every second game, the players change sides. It is another minor change that would take a few lines and a few minutes to do. How can you test this easily to ensure that this works correctly?

4. Now, we can introduce the service change. After every game, the service changes. This is yet another minor change that would take a few lines and a few minutes to do. How can you test this easily to ensure that this works correctly?

You can apply a similar strategy to further break down Step 1 and ensure that even that becomes a series of very small increments such that all these steps can be incremented and tested independently.

Do share with us your "Catabolising Strategy" for Step 1 at artisticprogramming@reinventsoft.com.
 
If it takes you any more than 30 minutes to write a complete working program for this problem—you will love the magic of "Catabolising Strategies" to fill up your programming life with more juice and spice.
 
What benefits do you see by approaching your programming with such "Catabolising strategies"?
 
When you start doing this, you will experience a lot of "wows" and "ahas" ... you will feel extremely good about how you can go about dismantling huge "monstrous" programs to a series of "tiny, loveable" steps. Not only will you accomplish more, you will accomplish it easily and have a soaring high confidence. You will begin to love yourself for that...
 
There is more to programming than logic and algorithms.

There is more to a fulfilling career than slogging your way through it.

There is more to life than spending your late nights and weekends in the office.

The good news is: It is very simple to learn.

Programming can be really creative and fun. Go ahead and make it so...

DID YOU KNOW?

What is MICKEY?
A mickey is a unit of measurement for the speed and movement direction of a computer mouse. The speed of the mouse is the ratio between how many pixels the cursor moves on the screen and how many centimeters you move the mouse on the mouse pad. The directional movement is called the horizontal mickey count and the vertical mickey count. One mickey is approximately 1/200th of an inch.

QuoteA

Today I work because it's fun. In that sense, I guess you could say that I approach business as a kind of problem-solving challenge. That doesn't mean I don't take business seriously, because I do. But life's a lot more fun if you treat its challenges in creative ways.

Bill Gates

 

F-O-O-D For Thot!

It is so easy to draw your comfort zone and try your best to remain there.
Do you realize how exciting the world outside your comfort zone is?
Do you know how easy it is to reach there?

Isn't it time you unleash yours creativity to the fullest and start living your life of dreams?.

Bono