on 09-08-2008 10:34 AM
Hi All,
as my application is growing, I noticed that almost all my coding is placed in the View Controllers. I am unsure about whether my application is structured following the MVC Principle.
The major part of my application is editing a table UI element. That means deleting, modifying and inserting rows and after successful validation sending the table to the backend system. On the back end system. changes will be performed. The data that is shown in the table is previously read from the back end.
Now, all coding related to deleting, modifying and inserting rows of the table is placed in the view controller of the view showing the table. Is that correct or would I have had to write all that coding in a custom controller?
I know, there is a rule "Visual Controllers are always consumers, Non-visual providers of data". However, when data is typed into a table UI element, this element obviously provides data. How should this data be handled in this situation?
So, what do you guys think about my design? Is there any information pointing exactly to this topic?
Thanks, Johannes
Hi,
You are right.
NO Business logic should exist in View Controller. violation of MVC.
You can do one thing.
In your custom controller create methods for deleting / manipulating / adding row (s) of the table. In view controller where ever is needed you just call the custom controllers respective method.
PradeeP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Even I agree with Siva. The best way is to use your View is as a visual data provider and write ur methods in the component controller.This way it will not violate the MVC principle. I will request Armin as well to throw more light on Custom controller way of implementation.
Regards
Priyanka
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Make use of this hierarchy:
ViewController -> Custom Controller -> Component Controller -> Model
Place code that is not view-specific further to the right.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So it is advisable to have model nodes in the context of the component controller? My application has a Custom Controller that manages communication with the model directly. Adding the Component Controller in appears like a indirection to me.
View Controller - Customer Controller - Model
is shorter that
View Controller - Customer Controller - Component Controller - Model
Why would you add the Component Controller?
Thanks, Johannes
Hi Johannes,
You are right. But I think the more convenient and efficient way is
View Controller - Component Controller - Model
than
View Controller - Custom Controller - Model
Because when already global (Component) Controller is available and it can do all the functionality that is required , why to create unnecessarily the Custom Controller.
Generally we use Custom Controller for modularity when the application is too large. I think creating Custom Controller adds overhead to the application.
Is there any other benefit using Custom Controller instead of Component Controller?
I am also looking for Mr.Armin's comments on this. He is the right person to explain.
Regards,
Siva
Well, interesting comments about MVC... really, I think that it is difficult to resolve Custom Controller vs Component Controller question and give a good reason. Sometimes is difficult to justify why to put functionality in a Custom Controller instead of Component Controller or viceversa.
The first to know, use always view controllers as data consumers (you can even produce data in view controllers, but no business data... maybe information about UI elements visibility, caption texts, ....)
Did you already have a look at Chris Whealy's presentation?
Armin
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.