views:

2007

answers:

8

Hi I am new in MVC. can u tell me when to use MVC architecture. Is the MVC is the best approch for data driven huge and complex functionality. most of the forms are dynamic??

A: 

Without knowing the actual application, its hard to tell whether an MVC pattern is suitable. Its usually suitable when your app will need constant maintenance, and many people work on it at the same time. It makes the effect of modifying one part isolated to that part.

But to clarify, MVC is just a way of seperating concerns from each other, not an "application architecture". you can have a GUI that uses the MVC pattern (and many do, like swing based GUIs).

Chii
I did not know what swing based was, looked it up, found it to be Java. I guess I live in a Microsoft vaccuum...
Doug L.
+1  A: 

I think it is a very good paradigm, especially in the architectural sense: separate (decouple) presentation from data from behaviours.

You will find differences in the particular implementation of MVC, but most good products use this practice. There are variations I am not considering because they are different only in implementation (for example Document/View), not in general paradigm.

Sklivvz
A: 

Main consideration of using any architectural pattern is how close model that pattern represents to your original business entities and front-end approaches you're faced with.

Basically MVC allows you to have separated presentation and data layer with some kind of intermediate service layer in between. That allows you with small pain to substitute presentation interface, front-end engine or underlying data layer without major changes to other tiers.

Core component of MVC here is controllers layer which operates actual data entities and defines which view to render in which case. Also you can see inverted part of it, whet you're rendering some view it decides which controller will be selected to operate it.

Cheers.

dimarzionist
A: 

Simple: Use it as often as you can. MVC warrants to you to avoid mix responsability between the logic layers, in this way you wont get a spaghetti-code.

What is the return value? You code is much simple to mantain and to be modified. Take into account that your customer will always ask for changes, so you should use a very flexible architecture to avoid waste time drop the code and writte it again.

It is one of the MUST-TO-KNOW patterns in Software Engineering.

most of the forms are dynamic??

Please do not mix Software Patterns with web's eye-candy effects.

Gravstar
A: 

You need MVC when dynamic data structures are buffered multiple times in an application, e.g. in an internal buffer and the display cache of a GUI element or two different objects. MVC at the core is a cache synchronization pattern.

You should avoid data caches in the first place. MVC is the way to go when you can't avoid using them.

Thorsten79
+2  A: 

Recommended reading: Martin Fowler article on GUI Architectures.

Fowler bassically explains the origins of the MVC pattern, its motivations and characteristics, and compares it to other typical GUI architectural patterns, like 'Model View Presenter' and 'Forms and Controls'.

I think that the main point of the article is that it made me understand how MVC is rarely implemented 'right' (in the original Smalltalk way) in moder platforms, and why.

In the end, the article gives what I think is a good solid ground to understand and communicate in terms of what really the MVC is and how it has evolved over time and throughout the different GUI programming paradigms.

Sergio Acosta
+2  A: 

I'd say always start with MVC, because it encodes the good advice of seperation of concerns. At least you will have code you can refactor. That said, 'plan to throw at one away'(F.Brooks, Mythical Man-Month).

Sometimes the Hierarchical-Model-View-Controller (HMVC) pattern (aka Presentation-Abstraction-Control) is a good choice for dealing with more complex interface and application demands.

"However, the traditional MVC scope falls short when it comes to the control of GUI elements (widgets). MVC does not handle the complexities of data management, event management, and application flows. As an adaptation of the MVC triad, the HMVC -- Hierarchical-Model-View-Controller -- paradigm seeks to redress some of the above-mentioned issues."

Jason Cai, Ranjit Kapila, and Gaurav Pal (July 2000). "HMVC: The layered pattern for developing strong client tiers". JavaWorld Magazine.

The Presentation-Abstraction-Control wikipedia article has some other MVC alternatives worth investigating, depending on your needs.

Stephen
A: 

When ever it will help make your code tidier, and easier to manage.

It's really not very complicated - "MVC" is just the idea of splitting your code into sensible lumps: One to generate or process the data (the model), one to display the data (the view), and something to say "grab this from the model, and shove it into this view" (the controller)

dbr