Legacy coderetreat at Budapest

Yesterday I attended to the legacy coderetreat at Emarsys, organized by Athos and Devil. This is my fairly subjective summary.

We’ve been working on the trivia codebase. First impression: This day was gonna be way too easy because the codebase just doesn’t present my biggest struggle with legacy code: it’s too much to memorize, you never know where to start with a certain bug.

Thank god, I was wrong about that as I underestimated the complexity of the code. I really adore their authors: how they rendered so many gotchas into so few lines. Really, achieving this density of bugs is an art. Also, a good way to raise my maybe-not-so-pragmatic paranoia. If you’re interested, clone the code, read it and try to fix one of the bugs you find.

So, what did we do there during those sessions and retrospectives? We:
– added end-to-end testing
– added feature-specific tests for new features
– practiced SOLID principles
– debated a lot about the “right” way of development vs the rambo fix. (Reminder to myself: a coderetreat is not about rambo.)

My first gotcha was that you just cannot go and fix/refactor legacy code because you just don’t know if there is a dependency on a certain bug (e.g. a typo in the log).

Then, I learned that when working with hard-to-test code it’s ugly but fucking effective to write white-box tests. It’s always a trade-off between test-code independency and the time you spend with the code. When you know that you’re gonna have to refactor your API anyway, then a temporary test is better be written quickly.

Finally, I learned a lot about big, end-to-end tests. You know the sort of test which when fails only tells you that “Oooops, something went wrong”. They are way more useful than I thought: they provide a good basis for refactoring as changing the code structure without changing the behavior. Also, you better be able to automatically regenerate them after each change you make otherwise you’ll never make any change in the behavior – ‘cos you know, you’d loose these tests. This means that you need some sort of test runner which you can automatically feed with input – expected output pairs.

Last but not least: it was amazing to meet so many committed and talented professionals. I had not only a useful, but really nice time too. Thanks again to Athos, Devil and Emarsys!


About tamasrev

A software developer, specialized in Java, addressing himself as generalist. A proud daddy.
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

One Response to Legacy coderetreat at Budapest

  1. Pingback: JUnit recipes: a classic book on Object Testing | tamasrev

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s