'web'에 해당되는 글 2건

  1. 2008.07.10 MVC or MVP Pattern – Whats the difference?
  2. 2008.05.29 What put the 2 in Web 2.0?
MVC or MVP Pattern – Whats the difference?

Over the years I have mentored many developers on using design patterns and best practices. One question that keeps coming up over and over again is: What are the differences between the Model View Controller (MVC) and Model View Presenter (MVP) patterns? Surprisingly the answer is more complex than what you would suspect. Part of reasons I think many developers shy away from using either pattern is the confusion over the differences.

Before we dig into the differences let’s examine how the patterns work and the key benefits to using either one. Both (MVC & MVP) patterns have been use for several years and address a key OO principal namely separation of concerns between the UI and the business layers. There are a number of frameworks is use today that based on these patterns including: JAVA Struts, ROR, Microsoft Smart Client Software Factory (CAB), Microsoft Web Client Software Factory, and the recently announced ASP.Net MVC framework.

Model View Controller (MVC) Pattern

The MVC pattern is a UI presentation pattern that focuses on separating the UI (View) from its business layer (Model). The pattern separates responsibilities across three components: the view is responsible for rending UI elements, the controller is responsible for responding to UI actions, and the model is responsible for business behaviors and state management. In most implementation all three components can directly interact with each other and in some implementations the controller is responsible for determining which view to display (Front Controller Pattern),

Model View Presenter (MVP) Pattern

 

The MVP pattern is a UI presentation pattern based on the concepts of the MVC pattern. The pattern separates responsibilities across four components: the view is responsible for rending UI elements, the view interface is used to loosely couple the presenter from its view, the presenter is responsible for interacting between the view/model, and the model is responsible for business behaviors and state management. In some implementations the presenter interacts with a service (controller) layer to retrieve/persist the model. The view interface and service layer are commonly used to make writing unit tests for the presenter and the model easier.

Key Benefits

Before using any pattern a developers needs to consider the pros and cons of using it. There are a number of key benefits to using either the MVC or MVP pattern (See list below). But, there also a few draw backs to consider. The biggest drawbacks are additional complexity and learning curve. While the patterns may not be appropriate for simple solutions; advance solutions can greatly benefit from using the pattern. I’m my experience a have seen a few solutions eliminate a large amount of complexity but being re-factored to use either pattern.

 

·         Loose coupling – The presenter/controller are an intermediary between the UI code and the model. This allows the view and the model to evolve independently of each other.

·         Clear separation of concerns/responsibility

o    UI (Form or Page) – Responsible for rending UI elements

o    Presenter/controller – Responsible for reacting to UI events and interacts with the model

o    Model – Responsible for business behaviors and state management

·         Test Driven – By isolating each major component (UI, Presenter/controller, and model) it is easier to write unit tests. This is especially true when using the MVP pattern which only interacts with the view using an interface.

·         Code Reuse – By using a separation of concerns/responsible design approach you will increase code reuse. This is especially true when using a full blown domain model and keeping all the business/state management logic where it belongs.

·         Hide Data Access – Using these patterns forces you to put the data access code where it belongs in a data access layer. There a number of other patterns that typical works with the MVP/MVC pattern for data access. Two of the most common ones are repository and unit of work. (See Martin Fowler – Patterns of Enterprise Application Architecture for more details)

·         Flexibility/Adaptable – By isolating most of your code into the presenter/controller and model components your code base is more adaptable to change. For example consider how much UI and data access technologies have changed over the years and the number of choices we have available today. A properly design solution using MVC or MVP can support multi UI and data access technologies at the same time.

Key Differences

So what really are the differences between the MVC and MVP pattern. Actually there are not a whole lot of differences between them. Both patterns focus on separating responsibility across multi components and promote loosely coupling the UI (View) from the business layer (Model).  The major differences are how the pattern is implemented and in some advanced scenarios you need both presenters and controllers.

 

Here are the key differences between the patterns:

 

·         MVP Pattern

o    View is more loosely coupled to the model. The presenter is responsible for binding the model to the view.

o    Easier to unit test because interaction with the view is through an interface

o    Usually view to presenter map one to one. Complex views may have multi presenters.

 

·         MVC Pattern

o    Controller are based on behaviors and can be shared across views

o    Can be responsible for determining which view to display (Front Controller Pattern)

 

Hopefully you found this post interesting and it helped clarify the differences between the MVC and MVP pattern. If not, do not be discouraged patterns are powerful tools that can be hard to use sometimes. One thing to remember is that a pattern is a blue print and not an out of the box solutions. Developers should use them as a guide and modify the implementation according to their problem domain.

Posted: 17 Oct 2007, 17:08

'web' 카테고리의 다른 글

What put the 2 in Web 2.0?  (0) 2008.05.29
Posted by 으랏차
,

What put the 2 in Web 2.0?

web 2008. 5. 29. 10:21

The industry has spent a lot of time defining Web 2.0 and mapping its DNA. But as we attempt to emulate the fast-growth success of the Web 2.0 darlings, we need to zero in on the parts of the DNA that actually create this noteworthy new value.

What put the 2 in Web 2.0?

Your instinct may tell you that some of the DNA-like attributes of Web 2.0 have been around for some time, and in truth, many have. So why didn’t we see Web 2.0 offerings popping up years ago? Because these older attributes, while significant, weren’t enough to produce viable Web 2.0 products.

Some of the attributes we associate with Web 2.0 were introduced and commercialized as early as the mid 1990s; let’s call these Foundation Attributes. The figure detail below is part of a PDF that separates these “significant but not sufficient” attributes from the more recent Experience Attributes, those that create the kind of value that’s caused the recent excitement over Web 2.0.

What Puts the 2 in Web 2.0

When Experience Attributes are combined with Foundation Attributes for a Web 2.0 offering, the result can be a valuable new service with a fast-growth business model.

I identified these attributes based on how concisely they captured the capabilities of Web 2.0. Rather than returning to the underlying functional features of Web 2.0 (e.g., tagging, RSS), or overextending into the business impacts (e.g., mash-up ecologies), these attributes outline the capabilities of Web 2.0 independent of specific business concepts. Together, they represent the aspects of Web 2.0 success that you can apply in multiple market spaces.

Foundation Attributes

Amazon was taking advantage of the Long Tail before we even had a name for the concept that has since become widespread. Ebay capitalized on the network effect to create a many-to-many marketplace. Early blogs were already embracing the value created from individual users.

These attributes — user-contributed value, the Long Tail, and network effect — are all Foundation Attributes of Web 2.0 services. They’re a part of many Web-based offerings, including some that we don’t call Web 2.0:

User-Contributed Value - Users make substantive contributions to enhance the overall value of a service.

The Long Tail - Beating the sales of one or two best-seller products by using the Internet to sell a cumulatively greater amount of the products that have low demand or low sales.

Network Effect - For users, the value of the network substantially increases with the addition of each new user.

All of these attributes are significant parts of the Web 2.0 economic model, but aren’t sufficient to create the new value of Web 2.0 on their own. They enable Web 2.0 offerings to generate and maximize value from many sources, no matter how small they may be.

Experience Attributes

Flickr, Google Maps, and Wikipedia are all unique services that were undeliverable before Web 2.0. What makes us take notice is the novel way they use Experience Attributes to generate value. (Foundation Attributes then distribute that value across the network and down the Long Tail.) Experience Attributes include:

Decentralization - Users experience services on their terms, not those of a centralized authority, such as a corporation.

Co-creation - Users participate in the creation and delivery of the primary value of a service.

Remixability - Experiences are created and tailored to user needs by integrating the capabilities of multiple services and organizations.

Emergent Systems - Cumulative actions at the lowest levels of the system drive the form and value of the overall system. Users derive value not only from the service itself, but also the overall shape that a service inherits from user behaviors.

By blurring the lines that traditionally delineate supplier, vendor, and customer, these services have pioneered new value streams that can output new types of offerings, harness new efficiencies, and produce higher levels of continuous innovation. Experience Attributes make Web 2.0 offerings fierce competitors in their respective marketplaces.

Where Your Company Fits

If your company is competing in the Web 2.0 space, pay attention to which attributes are part of your plan. The Foundation Attributes are essential ingredients for your economic model, but they won’t generate compelling new value on their own.

Building on one of the Experience Attributes will give you a competitive advantage and a differentiating new value for your Web 2.0 offering. Experience Attributes should provide you with a value stream and a service offering that looks, works, and feels much different from that of your marketplace competitors.

Brandon Schauer is a senior practitioner for Adaptive Path, the world’s premier user experience consulting company. He has nearly a decade of experience developing new products, services, and user experiences on the Web, handhelds, and beyond.

'web' 카테고리의 다른 글

MVC or MVP Pattern – Whats the difference?  (0) 2008.07.10
Posted by 으랏차
,