Looking through the Habitat solution, I noticed that the Sitecore.Foundation.Theming
module references the Sitecore.Foundation.SitecoreExtensions
module. I thought modules were meant only to reference modules at a lower level?
4 Answers
Take a look at the documentation:
Unlike the Feature layer, there is no strict convention on dependencies between modules in the foundation layer.
It is allowed to have dependencies between modules in foundation.
https://helix.sitecore.com/principles/architecture-principles/layers.html
Just to add a little extra detail onto the solutions posted by @MattherDresser and @ThomasBaek:
The reason why your foundation modules may depend on one another without your solution breaking the architectural pattern or incurring additional technical debt/dependency madness is because the Foundation layer of your project should contain the "most reliable" code in your solution. This code should have been tested the most, and should change with the least frequency, as compared with the code in the Feature and Project layers.
Additionally, since you cannot add additional layers without breaking the architectural pattern, if Foundation layer projects were not permitted to depend on one another then you wouldn't be able to add common extensions (e.g. .NET extensions like custom IEnumberable
extensions, etc.) that you use in multiple modules, including Foundation modules.
At the same time as you are allowed this additional freedom in the Foundation layer, it is important that you avoid overdoing it and that you continue to ensure that your Foundation code remains well-tested and reliable.
As others have answered.. yes it's fine. It may be helpful to think of the Foundation layer as having multiple, internal layers. The lowest levels of these will abstract the most specialised components, e.g. cache
, logger
, DB access
, web request handler
, etc. Higher levels will abstract more general components that may make use of several other components, e.g. REST helper may use web request handler
, logger
and cache
. These are all still Foundation layer though, as they are the building-blocks for the app and, once created, are unlikely to change.
Yes, it is OK for foundation layer modules to reference each other: http://helix.sitecore.net/principles/architecture-principles/layers.html
Unlike the Feature layer, there is no strict convention on dependencies between modules in the foundation layer. This means that one Foundation layer module can depend on another Foundation layer module in the solution – as long as they rely on the basic principles on component architecture such as the Acyclic Dependencies Principle and the Stable Abstractions Principle: