I would like youy to consider a civil engineering application whose purpose is to detect which elements, called Crossings, pass through certain Holes in the walls. The final objective is to associate a list of Crossings with each Hole element.
The Crossings may be of many subtypes (pipes, air ducts, equipment, etc.), as well as the Holes (round, rectangular, “L” shaped, polygons, etc.). The algorithm that detects if a given Crossing passes through a Hole depends both on the Hole and the Crossing subtypes. Note that, at the start of the development, not all Crossing and Hole subtypes are known.
Given the amount of possibilities, the different algorithms to implement and their varying degrees of complexity, the application architecture should allow adding newer algorithms and Hole/Crossing subtypes without much effort.
Since the detection algorithm depends on both the Holes and the Crossings, it seems artificial to have the calculation method (algorithm) built inside one or the other. This is also valid for any possible subtypes derived from these main types.
The fact that not all the exact subtypes of the objects involved (Hole and Crossing) are known beforehand makes me think of the Factory DP. However, the behaviour dependency on the subtypes ("detection algorithms") somehow confuses me while trying to apply the Factory DP here.
I have also thought on considering the “detection algorithm” as an object on its own. Then, a sort of “Factory” could be responsible for issuing a given “calculation method” depending on a specific Hole/Crossing pair. However, due to the complexity of the algorithms involved, I am afraid that the implementation of this “Factory” may turn out to be an angry herd of ancient and hairy woolly mammoths.
Summing up, my two main questions are:
- How should I model the distinction between the two “obvious” main types (Hole and Crossing) and their multiple, and mainly unknown subtypes?
- How should I model the "detection algorithm"?
These qustions should be answered keeping in mind that, in the future, more Holes, Crossings and their respective algorithms should be easily added.
Can anyone out there lend me hand on figuring out an elegant solution for this architecture problem?
Thank you
Aucun commentaire:
Enregistrer un commentaire