HACKER Q&A
📣 mips_avatar

Is component factory a good software design practice?


Recently I have been looking through older code that was designed with a component factory, and it is some of the most confusing stuff I have dealt with. Granted I am a stronger C developer than C++ so some of the inheritance is also new to me. I may have the opportunity to refactor this code, but I don't know if I should. Is component factory still a good paradigm for designing software?


  👤 shubb Accepted Answer ✓
Often used to make unit testing easier. For that specific purpose, interpreted languages may have ways to monkey patch in mock objects and methods making it unnecessary.

Patterns are mostly useful as a well thought out way of solving some problem, and as a language to describe conceptually difficult things so that other programmers don't need to figure out what you are doing. If there is a way to solve the problem that you prefer, or no one around you understands the pattern, better choose another option.