This is a follow up to my old question, I am considering moving my application to follow BEM structure. But, is it worth the trouble?
Looking forward to see some interesting responses from the community.
I think moving legacy code to BEM involves a lot of effort and time investment, especially if the existing code liberally uses complex selectors and class combinations.
An alternative solution, that I would recommend you to investigate, would be to systematically embrace SOLID principles and refactor the code piece by piece. While ideas behind SOLID (Single responsibility, Open-closed, Liskov substitution, Interface segregation and Dependency inversion) were originally envisioned for object oriented programming languages, As Miller Medeiros has elegantly explained, they work very well for CSS as well.
Especially I have found that once we begin embracing Interface Segregation religiously:
it’s better to have multiple specific base modules than to have a single generic one. It will increase the cohesion of your modules and make code easier to refactor/change/maintain
it becomes much easier to refactor around the remaining ideas and that makes systematic refactoring much easier.
Irrespective of the specific approach you may end up adopting, I think it is worthwhile to spend some time investigating visual regression testing tools for CSS eg. Gemini.
I think moving legacy code to BEM involves a lot of effort and time investment, especially if the existing code liberally uses complex selectors and class combinations.
An alternative solution, that I would recommend you to investigate, would be to systematically embrace SOLID principles and refactor the code piece by piece. While ideas behind SOLID (Single responsibility, Open-closed, Liskov substitution, Interface segregation and Dependency inversion) were originally envisioned for object oriented programming languages, As Miller Medeiros has elegantly explained, they work very well for CSS as well.
Especially I have found that once we begin embracing Interface Segregation religiously:
it becomes much easier to refactor around the remaining ideas and that makes systematic refactoring much easier.
Irrespective of the specific approach you may end up adopting, I think it is worthwhile to spend some time investigating visual regression testing tools for CSS eg. Gemini.