Friday, March 19, 2010

Installments Issue!

I realized one thing, writing a piece of code anyone can do, but coming up with an efficient code is what only a good programmer can do! :) N i cant do that. At least now..!

This time I had been given a task to work on this installment portal which will let the customer choose the amount he wishes to pay in how many ever installments (<5) he wants. I did use the minuscule amount of programming knowledge that i have and wrote a 30 line code.  :) BTW my piece of code divides the principal amount as installments equally such that the balance money will be zero. I know its as easy as 
Each Installment = Principal / Num Of Installments ; 

But this was a user friendly one. The customer could make changes to any of the installments out of the 5 but the balance had to be a "0". This took some time, around a week i guess for it to be exactly like how my boss wanted it. 
One more stupid thing which lead to confusion was the dutch format which had a comma instead of the period.
                          Indian           Dutch
Rs 0                     0.00             0,00
Rs 83 30ps          83.30            83,30
Sometimes after the calculations the value generated was 67.98767456597... Waaa...?? So i had to round them off also. But if i round off a dutch number it would turn Indian{The round off method was for Indian format} To make a number Dutch i had to Parse it. At one point of time i had to use:
It was such a khichdi in my mind. But the code seemed fine.

When i was having this talk about my code, boss made me realize the fact that i had used 5 for loops in my code, to take care of all the issues which would come up. He said that's like a whopping 5^5 iterations for  just 5 installments. That actually made me realize what a bad programmer i was.

P.S: More than coding i liked the trial and error part! Learnt so much. Future when i become a good programmer i will definitely read this post and have a laugh. :) ATB to me!

No comments:

Post a Comment

Hey ther,
Thanks for visiting my blog.
Feel free to write whats in ur mind about the post you read..!! A Good day to u!!