I was looking at the "Rendering Content" v8 documentation, and it struck me that the @Model.Value("propertyAlias") syntax is listed before the ModelsBuilder @Model.PropertyAlias syntax. To me, this suggests that @Model.Value("propertyAlias") is now the 'standard' way of accessing values.
For a developer working in Visual Studio, given that the .Value method is quite concise, appears to support the same fallback and default value options as ModelsBuilder, and can be passed a type argument, what is the benefit of using ModelsBuilder in v8?
Is it just that ModelsBuilder methods can be overriden with custom logic? Better Intellisense? Or should we no longer bother with ModelsBuilder at all?
From my experience, the value of Intellisense for property names isn't worth the constant model regeneration and compilation when using ModelsBuilder. I have a large client website using ModelsBuilder and I plan to turn it off when they switch to Umbraco 8. It will save them money over time since using ModelsBuilder slows down development.
That said, if you need a complex business layer where your objects use Umbraco content models as properties, or if you want to inherit from the Umbraco content models and extend them, it's a handy option.
I guess the point is that you'll likely know when you need to use ModelsBuilder. Don't use it by default.
True, except that using invalid models/properties in Razor doesn't always throw compilation exceptions. More of a VS flaw than anything else. But if you want compile-time validation (especially for classes), ModelsBuilder is the way to go.
By far the biggest upside from my point of view. You prevent "magic strings" by having to type the alias manually, and if you delete a property, you get a compile error instead of it silently failing.
Benefit of Models Builder in v8?
I was looking at the "Rendering Content" v8 documentation, and it struck me that the
@Model.Value("propertyAlias")
syntax is listed before the ModelsBuilder@Model.PropertyAlias
syntax. To me, this suggests that@Model.Value("propertyAlias")
is now the 'standard' way of accessing values.For a developer working in Visual Studio, given that the .Value method is quite concise, appears to support the same fallback and default value options as ModelsBuilder, and can be passed a type argument, what is the benefit of using ModelsBuilder in v8?
Is it just that ModelsBuilder methods can be overriden with custom logic? Better Intellisense? Or should we no longer bother with ModelsBuilder at all?
Interested to hear people's thoughts.
-David
a strongly typed model - you don't need to guess all the propertynames, just use intellisense. The modelsbuilder-properties just wrap calls to Value
From my experience, the value of Intellisense for property names isn't worth the constant model regeneration and compilation when using ModelsBuilder. I have a large client website using ModelsBuilder and I plan to turn it off when they switch to Umbraco 8. It will save them money over time since using ModelsBuilder slows down development.
That said, if you need a complex business layer where your objects use Umbraco content models as properties, or if you want to inherit from the Umbraco content models and extend them, it's a handy option.
I guess the point is that you'll likely know when you need to use ModelsBuilder. Don't use it by default.
If you compile the website, you will get validation that it works, before deploying/running it. That’s always something :-)
True, except that using invalid models/properties in Razor doesn't always throw compilation exceptions. More of a VS flaw than anything else. But if you want compile-time validation (especially for classes), ModelsBuilder is the way to go.
By far the biggest upside from my point of view. You prevent "magic strings" by having to type the alias manually, and if you delete a property, you get a compile error instead of it silently failing.
is working on a reply...