The Brilliant Solution

Updated May 22nd, 2023

The Brilliant Solution

Turning an impossible situation into a success story

Imager for The Project section of The Brilliant Solution

The Project

Years ago, before I founded GoodJava, I worked with a great team to develop an Order Processing system for a client, which integrated inventory and fulfillment systems, payment processors, QuickBooks accounting, tax processing (both domestic and international), and shipment tracking. The project was a huge success, enabling the client to ship over 10,000 orders a day and accumulate nearly half a billion in annual sales. However, as is common for large projects like this, we faced some initial hiccups.

The Challenge

One of the biggest issues we faced was with the accounting integration. We had defined dozens of complex calculations that needed to be performed for every order, which fed into debits and credits on the client's general ledger. These calculations included the cost of goods sold (COGS), sales totals, tax totals, and payment amounts by payment type, among others. And while the calculations worked perfectly when we developed the system using a known set of orders, unexpected edge cases arose when the system went live, leading to errors that quickly accumulated due to the high volume of daily orders.

Image for The World on Fire portion of The Brilliant Solution

The World on Fire

My colleagues and I found ourselves working around the clock to correct ledger discrepancies. For a single week of order activity, it took three of us as much as four weeks to identify and correct all the issues. Make no mistake - that was literally twelve “man weeks” of effort to fix a single week’s data. It was a grueling process, and we quickly realized it was not sustainable. Moreover, any code changes we made to the calculations would fix one edge case, but potentially break the calculations for another. In an attempt to address this issue, I tried using unit tests based on actual order data to prevent breaking other cases with our changes. However, the complexity of the order data model meant that it took a full day's effort just to code out a single unit test.

The Turning Point: An Innovative Idea

As our team approached burnout with no end in sight, I had a breakthrough idea: The process of creating these unit tests, although complex, was repeatable and data-driven… What if I scripted out some code that would write those unit tests for me? And for reasons I can’t remember now, it seemed to make sense to do this in a stored procedure on the database. The query would not only create the object model, but also the entire unit test code module, complete with formatting and imports. The whole thing seemed so unorthodox - I wasn't certain my boss would approve of the idea, but I was convinced it would be worthwhile, so I decided to take a risk and work on it in secret. It took two days to complete, which put us further behind on the reconciliation work. But once completed, the result was a game-changing solution that took the process of creating these complex unit tests from eight hours down to about 30 seconds.

Image for The Impact section of The Brilliant Solution

The Impact

With this newfound efficiency, I quickly fixed several bugs in the calculations, and with a rapidly growing test suite I was able to ensure I wasn’t breaking other cases. When my boss noticed the sudden and incredible increase in productivity, I revealed my innovative solution. He was both amazed and supportive, even though I had taken a risk by not informing him upfront.

 

Armed with this new tool, we rapidly resolved all the accounting issues, ultimately cutting the reconciliation time for one week of orders from twelve man weeks, down to just four hours for a single person.

The Spirit of Ingenuity

I'm proud of the clever solution I devised, and I believe it truly showcases the power of innovation and problem-solving. We have not enabled comments on our blog platform, but we'll share this post with a few other communities where discussion can occur. I'd love to hear about your most ingenious solutions and how they made a difference in your work!

We use cookies to ensure that you get the best experience on our website, although the cookies we use do not contain personally identifiable information. By continuing on this website or by clicking “I Accept Cookies”, you agree to the storing of cookies on your device. Learn More

I Accept Cookies