Introducing Sitecore Habitat
Ruud van FalierCo-founder & Consultant at ParTech
April 26, 2016
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 2
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved.
“Habitat is a Sitecore solution example built on a modular architecture.”
What is Habitat?
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved.
“Habitat is a Sitecore solution example built on a modular architecture.”
“Habitat is a Sitecore solution framework focused on streamlining the development process and optimizing productivity.”
What is Habitat?
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 5
• Open source
• Based on open standards
• Focus on architecture
What is Habitat?
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 6
Focus on architecture:
• Flexibility
• Extensibility
• Simplicity
What is Habitat?
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 7
“Web applications are unstable”- Abraham Lincoln, 1864
Why Habitat?
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 8
Why Habitat?
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 9
Why Habitat?
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 10
Why Habitat?
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 11
Why Habitat?
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 12
Why Habitat?
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 13
Why Habitat?
A
B
C D
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 14
Why Habitat?
A
B
C D E
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 15
Why Habitat?
A
B
C D
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 16
Why Habitat?
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 17
Why Habitat?
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 18
Layered architecture
FOU
ND
ATI
ON
FEA
TU
RES
PR
OJE
CTS
Site-specific content & styling
Solution specific features
Foundational features
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 19
Layered architecture
FOU
ND
ATI
ON
FEA
TU
RES
PR
OJE
CTS
Site 1(e.g. Corporate)
Co
nte
nt
Indexing
Site 2(e.g. Webshop)
Na
vig
atio
n
Sear
ch
Secu
rity
Pro
du
cts
Site
map
Form
s
Car
t
Taxonomy Assets Extensions Theming
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 20
Layered architecture
FOU
ND
ATI
ON
FEA
TU
RES
PR
OJE
CTS
Site 1(e.g. Corporate)
Co
nte
nt
Indexing
Site 2(e.g. Webshop)
Na
vig
atio
n
Sear
ch
Secu
rity
Pro
du
cts
Site
map
Form
s
Car
t
Taxonomy Assets Extensions Theming
Dependencies
Dependencies
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 21
Sitecore 8.1 ASP.NET MVC DynamicPlaceholders Unicorn 3.1 Bootstrap jQuery Sass Gulp
Technology stack
Assets Indexing Installer MultiSite Serialization SitecoreExtensions
Foundation
Accounts Identity Language Media Metadata Navigation News PageContent Person Search Social Teasers
Features
Website Design
Project
Layered architecture
Demonstration
Habitat in Visual Studio
22
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 23
• Everything is a module
• A module has one single purpose (no “Helper” or “Utility” modules)
• Modules are kept separated from each other (High Cohesion/Low Coupling)
• A module is self contained
• A module is as stable as possible
Modules
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 24
“The granule of reuse is the granule of release”https://en.wikipedia.org/wiki/Package_principles
• What belongs together is maintained and released together
• A module contains all types of data that are applicable to the module:
• Code
• Configuration
• Templates
• Renderings
• Items
Modules
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 25
“Classes that change together, belong together”https://en.wikipedia.org/wiki/Package_principles
• Define what belongs to a single module.• Minimize the risk of a change influencing the module
• The Habitat architecture is pointless without this
• Features output semantic HTML
• Site-specific styling belongs in the Project layer
• Only include files that belong to the module. Do not include out-of-the-box Sitecore files or other dependencies
Modules
Demonstration
Contents of a module
26
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 27
• Levels of stability
• The closer to the Foundation layer, the more stable
• The more stable the module, the more abstract
Layers
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 28
“The abstractness of a package should be in proportion to its stability”https://en.wikipedia.org/wiki/Package_principles
Layers
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 29
Layers
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 30
“Depend in the direction of stability”https://en.wikipedia.org/wiki/Package_principles
• Project Layer -> Features Layer -> Foundation Layer
• Changes on a lower level layer have more impact and require more tests
• In order to maintain productivity, we must be able to trust the Foundation layer
Layers
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 31
Project layer modules
• Only website modules
• Very concrete and specific to the solution
• Can contain styling (CSS and design Javascript)
• No functional Javascript
• No business logic
Foundation layer modules
• API only
• High level of abstraction
• No references to the Features or Project layer
• Does not contain presentation
Features layer modules
• No references to the Project layer
• Avoid references to other Features layer modules
• No styling (CSS and design Javascript)
• Can contain functionalJavascript
• Outputs semantic HTML
• Contains configuration that is specific to the module
Layers
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 32
Cool:
• Solid architecture
• Easy to understand
• Future proof, designed for growth
• Community support
Not so cool:
• Conventions / reasoning not (fully) documented
• Build system
• Early days (stability)
• Not upgradable
What do I think?
© 2016 Sitecore User Group Conference Europe and its respective speakers. All rights reserved. 33
Thomas Eldblom, Sitecore
• Sitecore Habitat Architecture 1 –Introduction: https://www.youtube.com/watch?v=2CELqflPhm0
• Sitecore Habitat Architecture 2 – Modules:https://www.youtube.com/watch?v=DgPrikqFe4s
• Sitecore Habitat Architecture 3 – Layers:https://www.youtube.com/watch?v=XKLpTMuQT4Y
Anders Laub, Pentia
• The ground breaking Sitecore Habitat:http://laubplusco.net/the-groundbreaking-sitecore-habitat
• http://laubplusco.net/layers-in-sitecore-modular-architecture
Special thanks to
Download Habitat: https://github.com/Sitecore/Habitat