Summary
It's very easy to overlook the chance to use a creational pattern and fall back on the new keyword. This is a “Get it done” mentality; and although I can sympathize with it as a developer, it doesn't save you any time on the next project. The quick implementations may be the last nail in the coffin.
This doesn't mean you should afraid of the keyword new, but consider how important it is for the declaration to be in the body where it resides. This is the deciding factor when you're considering whether your code should use a creational pattern.
Abstraction is crucial. Specifics are always necessary in an application, but their placement is critical. The design patterns discussed in this chapter rely heavily on abstraction that makes code ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access