Now well set up with our tasks the team spent day 2 making progress in each of their areas.
One of the attractions of Blazor as a web development framework is that a common language is run both client and server-side. This has the advantage of meaning developers only need to know that one language to become quickly productive in writing code for both sides, but also code can be shared between the two. As well as some basic domain objects, of particular interest to us is validation logic.
Sharing validation logic in a Blazor project
In a Blazor project, the same validation code, written in C#, can be executed both client-side and server-side – no duplication of code, no risk of discrepancies.
This would be reasonably straightforward for a traditional web app with hard-coded validation rules on its shared objects, however because the forms we’re loading are defined in data, including the validation rules, our validation needs to be constructed dynamically and so today Greg A and Ned started work on the basics of the shared validation design.
Greg H fleshed out the basic Blazor form components, added application routing so that we could load multiple distinct pages, and created the form state object connected to the fields of the form. This involved working with mixed collections of generics, which wasn’t a straightforward experience, but if it has to be done, Greg recommends starting with a non-generic base type.
Julian and Andrew continued work on getting the example EventFlow project working with Cosmos DB but with little success. Julian also investigated a non-EventFlow project that used Entity Framework to connect to both Cosmos and SQL Server, which appeared to work correctly so went back to debugging the EventFlow project.
Andrew continued work on the application project, implementing the components required by the EventFlow framework. This turned out to be a laborious process, although each component is not complicated, the number of components and their architecture is reasonably complex so takes time to put together. By the end of the day all the components were present but not yet hooked up to either the persistence layer or the client.