[Case 1] Solving packaging problem by inverting dependencies#4
[Case 1] Solving packaging problem by inverting dependencies#4vzurauskas wants to merge 1 commit intogrimsa:mainfrom
Conversation
While such technique could be useful in some case (probably if domain concepts were of somewhat equal weight, or if some domain experts saw it that way), I don't think this would be a good idea in general. I think my example (
In such case this: would seem preferable to what I think you proposed: The reason is that reading top-down should reveal progressively more details, and if you are interested in high-level algorithm implementation you'd have to go to |
|
I'm not convinced yet. I think the best approach depends on specific situation. Do several algorithms use the same step, or is a step specific to an algorithm? In former case I'd say the step is more abstract because algorithms depend on it and it doesn't depend on algorithms; in latter case the algorithm is more abstract because the steps are only its parts. Although now that I think more about it, I think I see your point. If client code cares only about algorithms and not individual steps, then the steps can be package private and then they are just an implementation detail, even if multiple algorithms use the same step. On the other hand, if step is conceptually more abstract than algorithm, then perhaps it's wrong for client code not to care about steps. Should it use steps to compose algorithms? Then the package structure would be entirely different. |
This seems to be the simplest solution. I changed no code, only structure and naming. If the default implementation of the algorithm,
DefaultPvModuleLayouts, depends on lower level details in a subpackage, then they are not really lower level details. In fact,DefaultPvModuleLayoutsis supposed to be in a lower level, because it depends on everything and nothing depends on it. Therefore:pvmodulelayoutspackage.DefaultPvModuleLayoutsinto a subpackage. I propose to call itdefaultlayoutsfor the default algorithm. Presumably you will need alternative algorithms, they can be put into other subpackages, and they can depend on the same layout specifications in the parent package.If this is a library, then this is enough, and you can have even stricter rules than the three proposed. Instead of "packages should never depend on sub-packages", you can introduce "packages can only depend on superpackages (no sibling dependencies)". If it's a runnable app, however, then you need a place which ties the whole app together, there is no way around that. I usually introduce an
apppackage at the root of the project, representing the application fully assembled from all disparate parts from all packages, but since your package structure already hasapp, I introducedappconfig, similar as in your solution PR.