Recently I’ve faced a common problem of most of the big applications. With time, due to constant improvements, technologies changes and contribution of different developers, applications become heavy and maze-like. When the application becomes huge, it is hard to control and here many problems arise. The main challenge of app management in such case is that the application just doesn’t work properly. You may ask why this happens if applications are written by ultra smart programmers? The reasons are multiple and different in each case but the common problem is that the logic behind the application is delegated a lot of responsibility.
Single responsibility principle says that each object should not have more than one responsibility.
Of course, for web apps it doesn’t mean that we should handle only simple action within one application. But if we think about this in a more abstract way, we can find that such functionality as, for example, authentication, notifiers, and bunch of other stuff can run by itself independently on each other.
Exactly this problem happened with the application of a customer of mine when they applied to Svitla. They have a very huge web application the aim of which in short is to help companies from small to large to sell their products effectively. The logic behind their app has grown so huge that every new change to application became very expensive as it could affect other areas.
The task was challenging. To solve the problem, first of all, my team had to make sure that the logic is fully covered with tests. We have written about 2000 bdd powered tests covering the most important business logic that we wanted to extract.
Our next iteration was dedicated to code extraction. It was kinda fun writing it mostly from scratch. As we used new technologies and frameworks with latest stable versions, we decided to pick Rails-API Gem for smoothly integration with the main application. My customer had already used LDAP (Lightweight Directory Access Protocol) for authentication, so I found Ruby’s net-ldap library very useful and well documented even for a person like me who was not an expert in that sphere.
After a two week iteration, we had a fully working and tested Rails API service that could authenticate users via LDAP.
This solution gave us two things. First, we simplified our code base in core application: it became more manageable with less code and less logic. And, what is more important, we reduced the price of code change.
Second, if something goes wrong on the authentication service, the main app will continue working as it should because now it doesn’t depend on anything else, and logged in users will not feel any discomfort.
Now we continue our extraction process searching for other logic that can work on its own. There’s a lot yet to extract but it’s a great architectural change that is required for everyone who is starting to feel that their apps become fat and hard to manage.
May 14, 2014