cancel
Showing results for 
Search instead for 
Did you mean: 

Violation of MVC Principle?

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

PradeepBondla
Active Contributor
0 Kudos

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

Answers (2)

Answers (2)

former_member188598
Contributor
0 Kudos

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

Former Member
0 Kudos

Make use of this hierarchy:

ViewController -> Custom Controller -> Component Controller -> Model

Place code that is not view-specific further to the right.

Armin

Former Member
0 Kudos

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

former_member197348
Active Contributor
0 Kudos

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

Former Member
0 Kudos

The component controller is always there, a custom controller must be created explicitly.

Armin

former_member191569
Active Participant
0 Kudos

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, ....)

Former Member
0 Kudos