Chapter 5. View models

 

This chapter covers

  • Representing UI concepts in code
  • Defining the presentation model
  • Representing user input
  • Scaling to complex scenarios

Part 1 of this book covered some of the big picture ideas; now we’ll start covering specific topics in depth. In this chapter, we’ll discuss the model, specifically how to approach designing models for ASP.NET MVC. When exploring the Model-View-Controller pattern, the model is often the most difficult part to understand. This is mainly because “model” is an overloaded term—it has different meanings in different contexts, which can lead to some confusion when trying to understand how it fits in with controllers and views.

A model is a representation of something meaningful. It’s not necessarily something physical but something real: a business concept or an API that’s difficult to work with. When you work with object-oriented languages (such as C#), you create classes that define this representation. You can create your representation so that when you use it you’re working in a more natural language that allows you to talk about the concepts represented by the software instead of using programming language constructs like Booleans, strings, and integers.

5.1. What is a view model?

5.2. Representing user input

5.3. More complex models for both display and input

5.4. Summary

sitemap