Code to exchange money between 2 banks.
So the system was - enter source bank, destination bank, source account, destination account, number of dollars.
As you can guess, the app was simple, and it was a web app written years ago.
The problem: One. Big. Source. File.
A giant JSP.
It was just a JSP which communicated with a mainframe.
And
the problem was that sometimes it transferred several times the same
amount of money... and also if the amount of money was too big, it
failed.
So the JSP had Java code to handle the "form.submit" as you would expect in... ASP or PHP app.
And since it had many pages, the dev decided to store the data in the session.
So the code was like:
If ( step == 1 )
{
grab_variables_from_sessi on();
process_data();
store_variables_in_sessio n();
step = 2;
}
else if (step == 2 )
{
.....
}
Needless
to say, the program was utter crap. But I was not allowed to modify it.
For some reason, banks prefer to stick to their technology which
clearly works as a dog with distemper.
So the
amount of money was too big to for a float. I changed it to double and
it started working correctly, but it took me almost a week just to find
the line to change... even if when they told me what the problem was, I
already had an idea that the float was the problem.