Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Common Design Patterns for use in MVC Web Applications

I am trying to coach some guys on building web applications. They understand and use MVC, but I am interested in other common patterns that you use in building web apps.

So, what patterns have you found to fit nicely into a properly MVC app. Perhaps something for Asynchronous processes, scheduled tasks, dealing with email, etc. What do you wish you knew to look for, or avoid?

Not that it matters for this question, but we are using ASP.NET and Rails for most of our applications.

like image 832
csexton Avatar asked Nov 29 '08 16:11

csexton


People also ask

What design patterns are used in MVC?

In the MVC design pattern, the view and the controller makes use of strategy design and the view and the model are synchronized using the observer design. Hence, we may say that MVC is a compound pattern. The controller and the view are loosely coupled and one controller can be used by multiple views.

How many types of design patterns are there in MVC?

There are three types of design patterns: behavioral, structural and creational.


1 Answers

Once you get into MVC, it can be worthwhile to explore patterns beyond the "Gang of Four" book, and get into Martin Fowler's "Patterns of Enterprise Application Architecture."

The Registry pattern can be useful to make well-known objects available throughout the object hierarchy. Essentially a substitute for using global data.

Many MVC frameworks also employ the Front Controller and the Two-Step View patterns.

The "Model" in MVC is best designed as the Domain Model pattern, although some frameworks (led by Rails) conflate the Model with the ActiveRecord pattern. I often advise that the relationship between a Model and ActiveRecord should be HAS-A, instead of IS-A.

Also read about ModelViewController at the Portland Pattern Repository wiki. There is some good discussion about MVC, object-orientation, and other patterns that complement MVC, such as Observer.

like image 146
Bill Karwin Avatar answered Oct 13 '22 22:10

Bill Karwin