Sitecore Development Approach Evolution – Destination Helix
Sitecore officially recommended Helix as a set of overall design principles and conventions for Sitecore development around 18 month ago at SUGCON 2016 alongside with an official implementation example - Habitat. Why was it necessary? What are the benefits? Has it worked in practice? Peter Nazarov will share the outlook on why and how a combination of Sitecore Helix and Habitat benefits the business and development users of Sitecore in practice.
4. Time to Market
• It is important to have an ability to put a new feature to production fast
• Fast enough to make customers happy
• Faster than competitors
5. ROI
• The money we invest in software should come back as “Profit” (a benefit for
the business) after a reasonable period
6. Cost of Delay
• If the software delivery is delayed it causes extra direct and indirect costs to
the business, which may be expensive and put a feasibility of the software
solution development under the question.
7. Total Cost of Ownership
• It is important to understand overall cost of software solution for the period
starting Requirement Gathering till the End of Life.
8. Maintainability (Software Code)
• Software solution maintenance and evolution costs should be reasonable –
should be in order lower than the cost of replacing the solution with a new one.
• Regular Approach to Maintainability (Software Code)
• Follow Software Architecture and Software Design Principles
• Perform Solution Code Review Regularly
• Monitor Code Metrics
• Maintainability Index
• Coupling
• Cohesion
• Cyclomatic complexity
9. Scalability
• Modern software needs to have an ability to scale vertically and horizontally
to support a dynamic change to performance and storage capacity
requirements.
• Regular Approach to Scalability
• Azure and other cloud bases systems
• Private Cloud is still an option
10. Resilience
• Software solution should be resilient to the hardware and software faults
• Regular Approach to Resilience:
• Use resilient underlying platforms and systems
• Resilient hosting infrastructure like Azure
• SQL Server and SQL Azure
• MongoDB
• Azure Search
• Solr
• Azure Web Apps
11. Reliability
• The business and the customers need to trust that to the software solution.
• Regular Approach to Reliability:
• Test Automation
• Regression Testing
• Unit Tests
• Integration Tests
• Spec Flow
• Selenium
• Live System Monitoring
14. Development Approach Evolution
0
2
4
6
8
10
12
14
16
2011 2013 2015 2017
Code is Separated from Sitecore Instance
Sitecore Items Serialisation
CI
N-Tier Architecture
DVCS with Branching Strategy
Continuous Deployment
No Downtime Deployments
FakeDB
Unit Tests
DDD
Automated Regression Testing
Dynamic Scalability
Modular Architecture
Coud-First Approach
15. Sitecore Helix
Helix is a set of overall design
principles and conventions for
Sitecore development
16. Does Helix Solve a Business Problem?
• Helix principles help the business, indeed.
• Increase ROI
• Mitigate Cost of Delay associated risks
• Reduce Time to Market Cycle
• Decrease Total Cost of Ownership
17. What is the Magic?
• Modular Architecture that focuses on key principles:
• Flexibility
• Extensibility
• Simplicity
23. Sitecore Habitat
Habitat is a real Sitecore project
implementation example that
allows developers to see how
Helix is applied and lets
developers experience a project
based on these principles
24. Using Habitat As a Starting Point
• Enables Sitecore Code Solution to have a consistent
structure that makes any Sitecore project look familiar
to all Sitecore developers
• Provides existing features that can be reused to boost
your software delivery
• Would help to reduce Sitecore Support Team response
time
25. Is There a Quick Start?
• Read the guidelines at http://helix.sitecore.net
• Setup Habitat-based solution
26. Source Code and Sitecore Instance
• Option 1:
• Clone Habitat Source code from https://github.com/Sitecore/Habitat/
• Install local Sitecore instance
• Use the version Habitat currently supports.
• Option 2:
• Use Generator Habitat: https://github.com/kamsar/generator-habitat
• Install node.js with Node Package Manger (NPM)
• Install generator-habitat using PowerShell:
npm install -g yo
npm install -g generator-habitat
• Create new Habitat based solution:
• Install new Sitecore instance in a separate location (e.g.: C:websitesmy-solution-website)
• Use the version Habitat currently supports
• In the directory where you like to create your new solution source code (e.g.: C:codemy-solution-code):
• Run: yo habitat
• Follow prompts to create a connect the source code to the installed Sitecore instance website
27. Adjust Habitat solution
• Rename Solution
• Use “Habitat” Project module example to create a Project module for
your website(s).
• Then delete “Habitat” Project.
• Remove Habitat modules that you don’t need
• Feature Modules
• You may like to delete all modules and create your solution specific ones
• Tips: Keep a separate instance of a complete Sitecore Habitat solution to use for
references or for bring back some Habitat modules later on
• Foundation Modules
• There are a few well-designed modules that would be useful to keep
• You should consider whether to keep or remove the other Foundation Modules
28. Deploy Your Code
• Open Solution Directory and run npm install using PowerShell
• In Visual Studio open Tools > Other Windows > Task Runner Explorer and
run default task
29. WFFM
• You may have Unicorn Sync issues because of WFFM
• Consider removing Habitat features related WFFM
• If you need a form builder upgrade to Sitecore 9
30. Adding new Feature and Foundation Modules
• Create the corresponding solution folder
• In the source cooed root directory use PowerShell to run
yo habitat:feature or yo habitat:foundation to generate
module code and test projects.
• Add code and test projects to your solution.
• Example: Adding “Accounts” Feature module:
32. Key Pillars of Good Modular Architecture
• High Cohesion of Modules
• What should reside in the same module?
• What works together should live tougher (Functional Cohesion)
• Low Coupling Modules
• Minimise dependency between modules
37. No ORM?
• Is Glass.Mapper.Sc part of Habitat?
• No, it is not. However it is easy to add it!
• Introduce “Orm” Foundation module
• Install Glass.Mapper.Sc to it
• If may also like to add Sitecore item base
interface and class models. E.g.:
• ISitecoreItemBase.cs
• SitecoreItemBase.cs
38. ORM - Generate Models Code
for Sitecore Templates
• You can use free T4 code generation tools
• T4 Sitecore Code Generator by Robin Hermanussen (https://github.com/hermanussen)
• https://github.com/hermanussen/sitecore.codegenerator/blob/master/README.md
• You need to install T4 Toolbox Visual Studio to run T4 templates:
• https://marketplace.visualstudio.com/items?itemName=OlegVSych.T4ToolboxforVisualStudio2017
• To enable T4 template code syntax highlight install T4 Editor:
• https://www.devart.com/t4-editor/download.html
39. Yes, we are good to go now!
Are there some other tips?
41. Number of Modules Complexity Challenge
• Large Sitecore Solution may contain about 35-50 modules – about 70-100
projects (Code and Test)
• However, it does not need to be big without a reason
43. Separate Sitecore Instance from Code
• You need to have an ability to make a “fresh” deployment to Sitecore
instance
• You would need to have an ability to remove you customizations from Sitecore
instance and apply new customization. You can use the following techniques to
roll-back the file-system state:
• Version Control System (e.g. Git)
• SIM
• PowerShell (Sitecore 9)
44. FE Development for Sitecore
• Like to like FE and BE partial structure
• For example: Handlebars Mark-up + JSON Data Models would allow to replicate
Sitecore multi-layer partials nesting: Layout, Sublayout, Rendering, Nested
Rendering.
• Integration to BE: Replaced with Handlebars syntax with .NET + Sitecore ORM code.
• http://handlebarsjs.com/partials.html
• You may consider separating out FE code into Git branch or Repo
• Use Separate FE QA Environment and FE-only Testing process (no back-end)
• FE development without a need to make a manual mark-up integration to
Sitecore?
• Consider using Sitecore JSS (In Preview)
• React.js
• Other FE framework support is upcoming…
45. CI Run and Deployment
• Build the code (e.g. TeamCity)
• Quickest option – use the same Habitat provided Gulp build script
• Deploy (e.g. Octopus Deploy)
• Changes you may like to make
• Replace Gulp MSBuild based Configuration Files Transformation task with a call to
“Microsoft.Web.XmlTransform.dll”
• Call PowerShell script file directly to run Unicorn Sync
47. Real Experience with Habitat-Based Software Delivery
• Small Solution - 8 weeks from scratch
• A content website with Sitecore Search features and lightweight third party
integration (including CI and CD).
• Agile Team:
• 1 UI/UX
• 1 FE Dev
• 1 Sitecore BE Dev
• Large Solution– International multi-country ongoing programme
(2 years+ roadmap) for large international business
• Consistent Brand Presentation
• Separated Code Base for EU and USA
• Variety of Back-end Systems Integration
• Distributed Agile Teams: 20-30 people