Technical Difference Document Type and "Composition"
Hello,
When I right click "Document Types" unter Settings I can add Document Type, Element Type and Composition.
Is there any technical difference between adding a Document Type and a Composition (except the Icon)? I only see a technical difference when adding an Element Type, which is the checked "Is an element type" option that leads to not beeing allowed selecting a template and child types.
The technical difference comes into play a bit further down the line to be honest. A Composition should be considered like an interface from a coding perspective. Document types can be composed of multiple compositions, however you cannot compose a doc type from another doc type.
You also cannot compose a doc type from a composition that composes of another composition (bit more like an abstract class in this instance).
Compositions feed into how the Models Builder models are generated as well, so you will see them as interfaces in the outputs.
I would also advise that Compositions don't have templates.
I don't believe the Umbraco back office differentiates that much between Compositions and Doc Types, so you could "technically" let a composition be created in the content tree, it is down to you and your setup of the site to prevent it.
Thanks for the info, I understand the point with the Interface. But that actually comes into play only when deciding to use the Compositions button
I looked at the generated code. I the initial act of adding a Document Type or a Composition to the tree there doesn't seem to be a difference, both is compiled to classes.
In the moment you decide to use these classes in compositions an Interface is generated in addition to that.
So the reason why Document Type and Composition are shown as separate items in the context menu is just a help for the user, I think.
Actually you can also inherit a Document Type from another Document Type (but only from ONE as it is possible in C# class inheritance) by selecting the three 3 dots of a document type and then "Create".
Technical Difference Document Type and "Composition"
Hello,
When I right click "Document Types" unter Settings I can add Document Type, Element Type and Composition.
Is there any technical difference between adding a Document Type and a Composition (except the Icon)? I only see a technical difference when adding an Element Type, which is the checked "Is an element type" option that leads to not beeing allowed selecting a template and child types.
Kind regards, Stephan
Hi Stephan,
The technical difference comes into play a bit further down the line to be honest. A Composition should be considered like an interface from a coding perspective. Document types can be composed of multiple compositions, however you cannot compose a doc type from another doc type.
You also cannot compose a doc type from a composition that composes of another composition (bit more like an abstract class in this instance).
Compositions feed into how the Models Builder models are generated as well, so you will see them as interfaces in the outputs.
I would also advise that Compositions don't have templates.
I don't believe the Umbraco back office differentiates that much between Compositions and Doc Types, so you could "technically" let a composition be created in the content tree, it is down to you and your setup of the site to prevent it.
I hope that helps?
Nik
Thanks for the info, I understand the point with the Interface. But that actually comes into play only when deciding to use the Compositions button
I looked at the generated code. I the initial act of adding a Document Type or a Composition to the tree there doesn't seem to be a difference, both is compiled to classes.
In the moment you decide to use these classes in compositions an Interface is generated in addition to that.
So the reason why Document Type and Composition are shown as separate items in the context menu is just a help for the user, I think.
Actually you can also inherit a Document Type from another Document Type (but only from ONE as it is possible in C# class inheritance) by selecting the three 3 dots of a document type and then "Create".
Hi @steschu
You are right the outcomes of two menu items are technically the same..
A Document Type only becomes a Composition when you use it as one...
But Composition is on that menu mainly to introduce the concept of composing Document Types, which otherwise isn't really introduced anywhere...
... I wrote a bit of a blog post at the time that contained some of the thinking surrounding the reorganisation...
https://moriyama.co.uk/about-us/news/creating-doctypes-in-umbraco-v8/#
Regards
Marc
is working on a reply...