Chapter 5. View models
This chapter covers
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.