Using Modular Approach to Maintain and Scale a Legacy App

vteam #638 was hired to develop a web application using the legacy styled custom core PHP code. For review, a basic set of old codes was provided by the client. Firstly, vteams engineer Muhammad Saleem had to understand the legacy code and develop the application features within the given deadline. In order to achieve a maintainable, reusable and scalable code base, Saleem had to apply some optimizations according to the coding standards.

After analyzing the legacy code and application requirements, the whole code was organized using a modular/component approach. The code was transformed into modules and inheritance was implemented with a basic set of classes for reusability. Additionally, the Composer (dependency manager) was integrated in the application to utilize built-in PHP, jQuery and JavaScript libraries which saved much of the development time.

To further organize the code, the following were defined:

  • Re-usable views
  • Functions
  • Classes
    .

To use common functions in the application, basic query builder class  and some helper classes were created. For real time messages, HTML 5 server notification was used.

Saleem modified and improved all the existing features of the application to save time. After that, he created multiple user level directories for each type of user i.e patients, physicians, pharmaceutical companies and admins (including super admins). As most of the views were having similarity, so he created common views & models in the modified modules and also included them in each directory file. Hence it saved the time of development and maintenance was made easy.

Conclusion

Using modular approach, a good level of optimization was achieved while maintaining the old style core PHP code. The application was developed as per the client’s requirements within the given deadline. As an outcome, a stable code base was achieved and made it maintainable, reusable and scalable for future use.