Legacy Code Base

Due to some unforeseen reason, I took a quick look over two legacy code base in the system to fix certain issues. The more I looked at it, the more my stress level shoot up. I literally want to strangle the original programmers or anyone near me.

Yes, the module or feature did almost work as intended but modification or bug fixing is a pain in the arse. I have to suppress my inner urge multiple times the whole day thinking of whether to do a total rewrite or refactor of the module. I kept shaking my head whether I should fix the bug first or refactor the damn module while fixing it.

Framework, especially Model-view-controller (MVC) framework provides a good initial structure for creating an application. At least, you have the advantage of separation of concerns (SoC) between all these three layers. However, problems arise when we're deciding on what or how to separate a program into these sections. I've seen many types of abuse of the MVC framework especially those lack of Object-Oriented (OO) mindset. While we have idiom like "Fat Models, Skinny Controller" exists as a guideline, it still, can lead to another form of abuse like God Models.

The lesson I've learned is that rather than taking the best engineering approach to design a system, instead use the most suitable solution understandable by the technical competency of the available programmers. You can't change a procedural to OO mindset as well as their egos instantly. Especially true for senior programmer as they said, old habits dies hard. If the basic understanding of MVC and OO is seriously lacking, might as well take what Ramus Lerdorf proposed "no-framework PHP MVC framework" approach. At least it is more procedural and understandable by most PHP programmer.

No comments:

Post a Comment