Chapter 3
Introduction to MVC
We have taken a quick look at AngularJS and how to get a simple Angular-based web page up and running, but the
reality is that you don’t need AngularJS if all you want to do is build a very basic application.
One of the major strengths of AngularJS lies in its ability to help you properly organize and structure your
applications, and very small applications tend not to benefit much at all from this. Of course, smaller applications
should be properly structured too, but such applications are not as likely to require the rigid underpinnings and
formal structure of a medium- or large-sized application. The way you would approach pitching a tent is not the same
way you would approach building a log cabin.
With that in mind, in this chapter, we will look at what it means to organize and structure an application and how
the Model View Controller (MVC) pattern can help you to do both.
Design Patterns
Before we get into MVC, let’s talk about design patterns for a moment. After all, MVC is a design pattern, so it would
be good to know what design patterns are and why you should care about them. Essentially, a design pattern is a
documented solution to a recurring problem that programmers have identified—usually in a particular context.
Design patterns won’t give you the code you need to solve a given problem, but they will propose a well-thought-out
and generally accepted approach that you might want to consider adopting yourself.
A good way to think of design patterns is that they are like recipes that have been created by programmers who
have spent a lot of time in the trenches. These programmers have found out, often through a combination of talent
and old-fashioned trial and error, a lot of really great ways to solve specific kinds of problems. Furthermore, these
programmers have decided to share these recipes with everyone else.
There isn’t really a formal standard that states how design pattern documentation should be written, but we will
examine something fairly typical. You will generally find something along the lines of what I have outlined in Table 3-1
on design pattern documentation.