A story of an elephant: dealing with legacy systems

Discover how IT teams can overcome difficulties resulting from legacy systems by reading this brilliant, metaphorical story.

Agnieszka Stojanik, Solutions Architect at 7N | a member of 7N Inspiration Team

What can you expect to learn from this article?

  • 1

    Legacy solutions can be truly painful – especially if you must deal with a large and ever-growing codebase

  • 2

    How to deal with evolving application architecture? What are the main issues you should consider?

  • 3

    Real life scenario of migrating from ASP.NET MVC with Angular monolith application to microservices architecture

Have you ever tried to eat an elephant? No? Me neither. But there was a guy named Desmond Tutu who once said: "There is only one way to eat an elephant: piece by piece." You have to admit that it’s hard to disagree – especially with someone who was awarded the Nobel Peace Prize. That’s how our story begins…

The very beginning

Once upon a time, there was an SPA. By SPA, I don’t mean a really nice place where you can bath all day long in a hot tub. Oh no. I mean a Single Page Application, which used to be a true nightmare of its own times (old times, thankfully). And bundled with that SPA, we got our elephant, aka The Monolith.

At first, it made a really, really good impression. It was nicely layered, like Rachel’s trifle: there was a layer of lady fingers (data model), then a layer of jam (data access), custard (infrastructure), then beef sautéed with peas and onions (business logic), and finally a layer of bananas (web application) with a fluffy whipped cream on the top (angular application). You can imagine something like this below.

Isn’t it pretty? If only we could preserve that beautiful picture… Unfortunately, we had to add more and more to each layer, sometimes leaking beef to the bottom, and mix it with lady fingers or spilling some jam on peas and onions. Long story short, we ended up with melted, greasy spaghetti. Yummy, right? It may look so on a plate – but not so much in the code. At some point, we had to do something about that.

By the way, if you’re interested in a recipe for such spaghetti, there is an illustrative example. Enjoy!

First bite

Where do you start biting such an elephant? Well, we decided first to rip off its <head>. All the creamy Angular application was scraped off and put into a separate bowl, leaving the <body> finished with a layer of bananas. However, as fun as such a decapitation may seem, we ended up with some security issues.

Until now, to get to any application layer, all users had to go through a web authentication pipeline, which acts as Gandalf shouting from the doorstep, “you shall not pass!”. Let’s imagine that Gandalf The Grey used to live somewhere between custard and bananas, and his job was to make sure that unauthorized creatures wouldn’t get access to other layers. As he had a sweet tooth, he would let in only those who brought him a cookie. You may ask where to get such a delicious cookie. You had to take a short trip to AD FS (Active Directory Federation Service), where, like in Sesame Street, a Cookie Monster was waiting for guests who could introduce themselves properly (with login and password) to hand them that cookie. And everyone was happy… except for those who failed to introduce themselves, as he was a Cookie, but still a Monster!

Piece of... cake?

So, the decapitation was a done deal, and we now had an elephant in two pieces and only one Gandalf, who also aged a little bit. It was high time to embrace not-so-new technology and adopt OAuth 2.0. To do so, our friend Gandalf was moved out of his so-called backend accommodation and dipped into Angular application. Along the way, he advanced to Gandalf The White so that he could welcome our guests in a much cleaner outfit. He also changed his habits and to prevent anyone from developing diabetes, he started to accept tokens instead of cookies. So if it came to your mind that such tokens were still dispatched on Sesame Street, you got it wrong. It wouldn’t make much sense as there lived a Cookie - not a Token Monster. Now, instead of going to AD FS (may it rest in peace), one now had to fly to B2C (Azure Active Directory Business-to-Consumer) located in the heavenly skies of Azure, where, like in the middle of Mordor, the Dark Lord Sauron would give away rings with token inscription (hmm, is it the right story?). Of course, only to those who introduced themselves properly, not to mention those who didn’t...

Great! So now we have a guy who goes on a trip to Mordor, gets a shiny ring with an inscription, and lands softly in whipped cream (sounds like a good party, doesn’t it?). But where is the meat? And peas, and onions, and jam, and lady fingers? It turns out that all of that wrapped into Web API was just at one’s finger[tip]s armed with a ring. We only had to make sure it was the right one. So, a new authentication pipeline was established based on the token validation. Who would be a better fit as an expert in ring inscriptions than a member of The Fellowship? Fortunately, Frodo was available as his ring was already destroyed, and he had nothing else to do. He accepted a new position and moved to old Gandalf’s apartment somewhere between custard and bananas, aka The Backend. And they lived happily... Well, no, unfortunately, this is not how this story ends.

Moving on

The bowl of Angular application was placed on a fancy stand called AKS (Azure Kubernetes Services). As needed, new mini pastries called microservices are baked filling out the Kubernetes (scalable) endless space. Of course, each time a brand-new pastry is taken out of the oven and put on the stand, it gets its own ring inscription expert from Shire to make sure no fraud fingers ever touch it.

And what about the rest of the trifle? Unfortunately, we could neither throw it away nor redo it from scratch, so it has to live alone on its own cloudlet called Azure App Service. And as soon as we have the opportunity, we cut out a piece and process it into another tiny dessert. Unfortunately, it takes a lot of time...

Did you expect a story with a happy ending? Well, not this time. But the moral of the story is: even a half-eaten <head>less elephant filled with spaghetti-like trifle can still be useful and deployed to production.

PS. If you wonder what a half-eaten elephant looks like, do you remember that famous drawing from The Little Prince by Antoine de Saint-Exupéry?