Posted
12th
of
April
2011 by Kern Herskind Nightingale
Inspired by the Compiled Domain Model and other code generation tools for Sitecore, I came up with a different approach to generating classes and eliminating magic strings.
In most cases the code generator uses the Sitecore API to traverse items in a Sitecore database to generate classes that represent templates and items. I cannot help feeling that basing the generated code on data from a database is a little detached from the codebase that lives in the versioning system.
For some time I have been using TDS to keep my items under version control (this could have been done using Sitecore's serialization feature - but TDS just makes it much more manageable). In a recent discussion with a client I had the idea of generating a model based on the serialized data from TDS.
This is a proof of concept using T4:
I realise that there is some way from this to fully automated model generation but I thought it was a fun demo.
Kern is a Sitecore Specialist with more than 10 years experince achitecting and developing Sitecore solutions. Kern was awarded Sitecore MVP in 2009, 2011 and again in 2015.
Currently Kern is helping the Sitecore Product team in shaping the future of the platform.