That Which Must Not Be Named
The conundrum you're faced with is how to create an instance of an object that requires particular details, without injecting any algorithms or information unnecessarily into the body of the class. The simplest approach uses parameterization.
When you pass a reference of an object into the welcoming arms of some code, a method, a class, and so on, the code can remain ignorant of the details that created the parameterized object and still use its referenced behaviors.
Unfortunately, parameterization perpetuates the burden of creation. It removes the role of creator from one class and places it into another. In other words, something still has to create the object.
Listing 6-2 shows how the removal of the concrete reference, ...
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