Just wondering if I use glass mapper or any DI framwork then will I need to implement in each project separetly? otherwise if I create a separate project for DI or Glassmapper and add the reference in each habitat project then i guess it will break the habitat rule which says keep the module separate.

  • 2
    With help/input from the guys from GlassMapper I looked into creating a sample version of Habitat with glassmapper. The News feature has been updated so take a look at that as it will give you an idea.
    – NS31
    Dec 12, 2016 at 13:07
  • @Muso I have converted your answer to a comment, because you did not provide any details about the solution itself. So your answer was a link-only answer, which we highly discourage. If you want, feel free to create a new answer that outlines the solution and includes details on how it actually works. Please see this thread for some tips on writing good answers. Dec 12, 2016 at 13:15
  • @Muso I have reviewed your project but that doesn'tn seem to be right approach as you have added glass reference in one of the Feature projects (news). Glass project needs to be implemented in foundation layer and refers in feature layer. Also you are explicitly adding your mapping class in mapsConfigFactory but that should be a general statement to cover most of the required mapping (preferably using DI)
    – S.Kazmi
    Dec 13, 2016 at 7:14

1 Answer 1


You can put it to the Foundation layer. Any project in any layer can have references to the Foundation layer. Also, a Foundation project can have references to another Foundation project, but you need to follow this rule:

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:

Source: Helix principles

Do not forget that Habitat is just an example of how Helix principles should be applied.

  • Makes sense to me.Thanks. I understand Habitat is just an example but does this also suggest to not use glass mapper or DI and keep the modules least dependent on external resources?
    – S.Kazmi
    Dec 12, 2016 at 11:11
  • 2
    not really. you can use DI which you want and for sure you can use glass mapper or another Sitecore ORM :) I think they do not use glass mapper or DI because they do not impose a technology stack. so you can get the habitat example and integrate any DI or ORM which you want.
    – Vlad
    Dec 12, 2016 at 11:22
  • Can you please also suggest that is it advisable to start a new project using example habitat project provided by sitecore and add new stauff (mainly feature projects) as per client requirement? or one should start with clean solution and only the stuff required by following the helix principle?
    – S.Kazmi
    Dec 15, 2016 at 12:37
  • you are free to choose. you can start clean project and use the Habitat modules if you need it. Habitat contain collection of good approaches but for sure you do not need them all. this is the main advantage of using modular architecture that you can take module from one solution and easily set up it to a new solution.
    – Vlad
    Dec 15, 2016 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.