Life as a C++ programmer can be extremely frustrating. Recently I was assigned to implement Chained RICs (a RIC contains data such as Bid, Ask, and Volume etc and comes from Reuters) in a proprietary currency-trading system.

The application architecture made it almost impossible but I managed to get the job done.

The function responsible for most of the work contains the following:

1) It uses a global variable, nothing wrong with that right!
2) It uses a couple of static variables, pretty simple right!
3) It’s recursive, ouch (insert flashback memories from that university course on algorithms)
4) It uses “goto” within itself; most people would call that “bad boy!!”
5) It triggers events!

Each point taken out of context isn’t bad or wrong, but looking at the whole picture this function is nasty!

So, can anyone beat my monster!!!!!