This has been the longest session of my project so far, spanning over four separate hours and nearly a week. My schedule was packed with other commitments, but I made significant progress.
The main challenge was grappling with some ASP.NET MVC framework issues related to data binding in views and the UpdateModel
method. To cut a long story short, I encountered difficulties and reached out for help on the MVC-forum. I received excellent feedback from Alberto, which you can read in my forum post.
Here are some key takeaways from this session:
- Use a Separate ViewModel: It’s crucial to create view-specific classes that streamline data handling between views and controllers.
- Naming Conventions in Views: For example, using
Html.TextBox("Product.Name", Model.Product.Name)
in the view and callingUpdateModel()
will correctly populate theProduct
property with the newName
value.
My goal was to continue using the IsValid/GetRuleViolations pattern from Session 22, but I ended up learning a more effective approach instead.
[UPDATED] I managed to resolve the ValidationSummary issue, as shown in the picture below:
I’ve also been reflecting on spending too much time on the MVC specifics. According to my initial intentions, this project was meant to be a learning experience in Domain-Driven Design (DDD), Test-Driven Development (TDD), and ASP.NET MVC. However, I feel that DDD has taken a backseat recently.
It seems that while ASP.NET MVC requires a lot of time to master due to its framework complexities, DDD is more about design patterns and mindset, which can be easier to start with but challenging to master.
I plan to refocus on the DDD aspects in the next session. For now, I need to fix some issues with the testing that didn’t work out as planned. Stay tuned!