MVC, also called Model View Controller, is a development model used by ASP.NET. Using MVC over other development options in ASP.NET lets you develop complex applications due to the visibility of each component. Learning the MVC mindset in ASP.NET MVC 5 is explained in this online tutorial, which also goes over the advantages of MVC development.
- In this video, we'll spend a few minutes discussing what MVC is all about and try to clear up the misconceptions that some developers have when it comes to this architectural pattern. You can also take a look at another course of mine on Lynda.com called "Up and Running with ASP.NET" which contains a video called "Understanding the Model-View-Controller Pattern" in the second chapter. It's not a prerequisite for this course. But if at the end of this video you still feel the need for more in the way of high level explanations, then head over there before continuing on.
There's nothing magical about MVC in that regard, it's also not too complex to learn in time for your next project. You'll have to put in some extra work at the start to get up and running, but as I just mentioned, we're not going to be learning a new language or an entirely new framework. And the idea is that once you are up and running, it's going to be a lot easier to add new features and maintain your application. Finally, there's an idea in the developer community that some people like to overengineer systems to show off or to make things harder for other developers to modify, that may be true in some cases.
But I can assure you that Microsoft certainly does not want to scare developers away from using ASP.NET. And MVC-powered frameworks like Ruby on Rails would never have become so widely used if they were too complex for people to adopt quickly. MVC was designed to make our lives as developers easier, not more difficult. I've heard some developers say things like, "I hate MVC, it just makes everything too complicated." Most likely, those developers want to stay in their comfort zones because they feel like they can be productive enough without learning new ways of doing things.
But if you ask them to show you what their workshop and their tool sets look like for building applications, you might be shown something that feels a little bit like this picture. In this workshop it's difficult to find what you need and moving one item will disturb other items or even cause them to break completely. MVC helps us manage complexity through a principle known as separation of concerns. The main concerns are the three letters of MVC, Models, the classes that deal with data and encapsulate our business logic.
Views, the presentation and UI components. And Controllers, classes that handle user interaction and manage control flow in your application. So when you apply the principle of separation of concerns, your workshop can start feeling a lot more like this. Things are easy to find and you have a little breathing room to take out a piece of code and work on it without worrying about disturbing everything else around it. So here are some things to keep in mind about what MVC actually is. It's a useful way to organize code, markup, and control flow logic, it's easy to learn.
Again, it's not a new language, just a rearragement of things you're already familiar with. Especially with ASP.NET, there are plenty of tools and templates to help you get started. And you'll be well on your way to building full-blown applications after watching this course. And remember that MVC exists to help you get your work done and write better software that's easier to test and maintain. So keeping these ideas in mind, in this course I'm going to be covering the things you need to know in order to be successful when developing applications using ASP.NET.
I'll do that by demonstrating how we might implement an ATM cash machine system using MVC principles. One reason I like this project is that it's a system that everyone is already familiar with. The other reason is that I want to get away from the idea that a browser is just requesting web pages because in MVC the browser is going to interact with our application more or less by directly invoking methods of a controller class, for instance, methods like withdraw, deposit, view balance, and transfer funds.
Before we get started with the ATM, I'll introduce you to this concept of controller actions in the next video.
- Exploring ASP.NET routing
- Applying action selectors
- Working with layouts
- Employing HTML helpers
- Displaying and validating model properties
- Generating database objects with Entity Framework
- Adding transactions
- Authenticating users
- Unit testing
- Performing partial page updates with Ajax and jQuery
- Deploying ASP.NET MVC applications