Maintainable Sitecore Solutions

30
SPECIALISTS ON DESIGNING, IMPLEMENTING AND SCALING CUSTOM SOLUTIONS BASED ON SITECORE CMS Building Maintainable Sitecore Solutions Proven practices for Sitecore team development Thomas Eldblom CTO Pentia A/S

Transcript of Maintainable Sitecore Solutions

SPECIALISTS ON DESIGNING, IMPLEMENTING AND SCALING CUSTOM SOLUTIONSBASED ON SITECORE CMS

Building Maintainable Sitecore Solutions

Proven practices for Sitecore team development

Thomas EldblomCTOPentia A/S

How to Serve Sitecore

…what we could serve!

Cost of maintenanceCo

st o

f Cha

nge

Time

Layouts

Templates

Sublayouts

.NET code CSS & Design files

Settings in Sitecore

XSLT RenderingsConfigfiles

Content structure

How to build maintainable Sitecore solutions

• Component architecture • Using consistent structure and

naming.• Use version control.• Separate custom functionality from

standard functionality.• Automate configuration file

generation.• Automate trivial tasks.

Component Architecture

• Function before type• Agile design principle

– Logically grouped functionality based on cohesion.– Releasable and reusable modules.– Focus on reusability as well as maintainability.

• Simple component architecture– Structure data logically across systems

“A way must exist to deal with groups of classes, otherwise it’s almost like build a sand castle from individual grains of sand”

Robert C. Martin (Uncle Bob)

Component breakdown

• Breaking down the related functionality of the website

• Focus on cohesion in each component• Think of the concern/domain of each

component– Do the component solve a general

functionality?– Do the component solve a project

specific functionality?

Component breakdown

Navigation

Products

Search

Spots

Identity

Navigation

Products

Search

Spots

Component Breakdown

Identity

• Product data• Product presentation

•Menus• Sitemap

• Search boxes• Search results• Indexing •Corporate identity

•Header logo• Footer disclaimer

•Related information•Global marketing boxes

Component coupling

• Defines references between components• Consider each reference made– Both hard (in code) and loose (in strings)– Define new components to avoid references

• Specific components should reference general components– Stable-Dependencies Principle

• Avoid circular references– Acyclic Dependencies Principle

• Use coding patterns to avoid high coupling

Component Coupling – the common but wrong way

• Product data• Product presentation

•Menus• Sitemap

• Search boxes• Search results• Indexing •Corporate identity

•Header logo• Footer disclaimer

•Related information•Global marketing boxes

• Product list page type

• Sitemap page type

• Search results page type

Navigation

Products

Search

Spots

Identity

ProductsProducts

Component Coupling – the common but wrong way

• Product data• Product presentation

•Menus• Sitemap

• Search boxes• Search results• Indexing •Corporate identity

•Header logo• Footer disclaimer

•Related information•Global marketing boxes

• Product list page type

• Sitemap page type

• Search results page type

Navigation

Products

Search

Spots

Identity

ProductsProductsProducts

DesignPage types

Component Coupling – the right way

Navigation Search

Spots

Identity

• Product list page type• Sitemap page• Search results page

Component Architecture– @ Pentia

Consistent structure and naming

• Apply naming conventions– Be consistent with terms.–Use your naming convention across

systems.• Folder structure• Visual Studio Projects/Assemblies• Sitecore Templates• Layouts, rendering, sublayouts etc.

Folder structure on

disk

Templates in Sitecore

Renderings in Sitecore

Team Development for Sitecore

Components in Visual Studio

Advanced component architecture

• High cohesion/Low coupling• Design Principles– Reuse/Release Equivalence Principle– Common Reuse Principle– Common Closure Principle– Acyclic Dependencies Principle– Stable-Dependencies Principle– Stable-Abstractions Principle

• IoC containers• and so on…

Agile Principles, Patterns, and Practices in C#Robert C. Martin

Micah MartinISBN-10: 0131857258

Use version control

• ”Single source of the truth”• Version everything

– Component structure– Code– Layouts and renderings– Templates– Configuration changes– and so on…

• How?– Subversion, Microsoft TFS, you name it…– Use Sitecore item serialization or Sitecore TDS

Separate custom functionality from standard functionality.

• Keep track of what belongs to:– Your solution– Sitecore (versioned)– Sitecore modules– Third party modules

• How?– Separate your solution from standard

functionality in version control.– Implement one-click deployment.

• Team Development for Sitecore.• Web Applications in Visual Studio

How we do it

• The Pentia Build System and Build Library

• Central repository containing:– All Sitecore versions, modules, patches etc.– Third party modules– Pentia shared functionality

• Automated via nAnt– Copies referenced modules locally– Generates database scripts

Debug environment

Version control Build library

Automate configuration file generation

Website Backend Publishing

Website Backend Publishing

Website Backend Publishing

ProductionQ

ATest

Automate configuration file generation

• Sitecore config includes– Located in \App_Config\Include– Only works on <sitecore> section–Not environment specific– /sitecore/admin/showconfig.aspx

• Visual Studio 2010 config transformation– Environment specific merges– Only available with web.config (in Visual

Studio)

Resources

• http://www.pentia.net/professional-services

• Books:– Agile Principles, Patterns, and Practices in C#

• Robert C. Martin & Micah Martin• ISBN-10: 0131857258

– Clean Code: A Handbook of Agile Software Craftsmanship• Robert C. Martin• ISBN-10: 0132350882

• Sites:– Blog - Molten Core: http://mcore.wordpress.net– Learn Sitecore: http://learnsitecore.cmsuniverse.net