Closed michielbdejong closed 4 years ago
It's not clear how the
LdpHandler
would know whichOperation
s to create when given anOperationFactory
That's actually the point of the OperationFactory
. The LdpHandler
does not know which Operation
to create; it delegates that knowledge to the OperationFactory
. That way, LdpHandler
only needs the handling logic that is common between all operations. The idea is separation of concerns.
You can see that idea in action here (slightly different naming):
In summary, because LdpHandler
does not know this, this knowledge can be tested separately and changed at any time, without involving LdpHandler
. This is managing complexity through components.
so why not just create the
Operation
s before you create theLdpHandler
In this architecture, as can be seen in the OperationFactory
interface's createOperation
method signature, operations are short-lived objects that are created per request. Hence, they cannot be created before LdpHandler
.
This has now happened in 9e68331473c5e9f79281098ad97c9ad95e3c1e5c, following @jaxoncreed's design.
It's not clear how the
LdpHandler
would know whichOperation
s to create when given anOperationFactory
, so why not just create theOperation
s before you create theLdpHandler
, and then pass anArray
of those already instantiatedOperation
s to it instead?