I was frustrated, and then Unit tests came to my rescue!
Managing complexity is a problem I recently came across. It was challenging. I learnt about the importance of unit tests. I take a bow to their power.
The product I work in : HyperView has both a Gui and command layer API. One functionality was being routed through multiple classes in the core for Gui. But strangely, the architecture for the command layer API’s was different. There was just one function bearing the load for the same functionality at the command level. All those special classes that were gracefully implementing the functionality at the GUI level were missing.
The QA was having a ball raising issues one after the other. There were 80 unique test cases related to this part of the code. Every time I had to make a change to that part of the system, it would make me nervous. When I made a small change to fix one wrong set of values I would have to test 79 other cases manually. More often than not I would break something. And I would have to start over again.
I started getting scared at the prospect of even touching that part of the code. I was always worried I would break something else when fixing the issue at hand.
Gosh, it was maddening. Just like the scene in Game of Thrones, where Jon Snow sees hundreds of white walkers speeding towards him. Take a look at the horror on their faces. Imagine the same feeling. Now that’s what I felt.
And this my friend are tell-tale signs of a complex code. I later realized that these are all symptoms of code complexity. Your emotional reaction to touching the code base says it all.
I felt like pulling out my hair, every time I had to do that. If you feel frustrated about the code you are working on, accept the code’s complexity. And then move on to action. That’s what I did.
To manage this complexity, finally I changed a few things in the code, made it more modular. Then I wrote a BVT(Build Verification Test). These are what we call unit tests in our company. This one BVT would automatically test 80 unique test cases.
The initial effort in setting up this change was considerable. But after the changes, the QA was relieved of its duties to raise issues with that functionality any more. Yayy! No one could be happier than me. With a sigh of relief I did a hi-five to myself.
This experience has intrigued me. I am curious about how developers manage complexity.
Did you ever face such an issue? What did you do to solve it?
Let’s share our experiences and open new doors.
Let’s amaze each other!
If you like this post, don’t forget to recommend and share it. Check out more great articles at Code Like A Girl.