Skip to content

How Synthesis Generates Objects from Templates

Kam Figy edited this page May 30, 2013 · 1 revision

Before diving in to how to use Synthesis, it’s important to have a basic theoretical foundation about how strongly typed template objects get created. Consider the following simple template hierarchy in Sitecore:

Page Information Title : Single-Line Text

Navigation Information Show in Navigation : Checkbox

Simple Page:
inherits Page Information
inherits Navigation Metadata
Content : Rich Text

Once Synthesis had generated objects for these templates, the following classes and interfaces are created to represent them:

class diagram

Each template has two generated representations: a concrete class and an interface. The class implements the interface. The template’s interface implements interfaces representing any base templates. As a result, one is able to refer to the SimplePage class as an IPageInformationItem. This powerful feature provides support for information hiding and generalization.

It is possible to design a rendering that expects an object implementing IPageInformationItem that will work not only for a Simple Page, but also any template that descends from the Page Information template. The rendering can also have polymorphic behavior based on the template type it receives, or simply hide itself if its data source isn’t a relevant type. The ability to refer to an item by any of its base template interfaces is one of the most powerful abilities of Synthesis. It opens up a whole new class of polymorphic architectures that would be very difficult or perform badly without it.

Clone this wiki locally