MexicanHacker
MexicanHacker

Reputation: 2685

How to generalize view?

Hey guys, I'm in the process of designing a set of views that use the same model in my app, the difference is that some views will differ in Read Only and Modifiable fields.

So for example for view A I want to be able to modify A.One but no A.Two properties and for view B I want to have B.One and B.Two as modifiable fields.

I was thinking in having a map that will hold this information and iterate both the modifiable and non-modifiable lists in a generic view, but I was thinking that maybe I can get feedback from you guys.

What do you think?

Upvotes: 0

Views: 45

Answers (1)

Bradley Landis
Bradley Landis

Reputation: 127

I have found that typically you are better off just sticking with having multiple views. There is some duplication but it simplifies things greatly. For example, the decision of whether to be in "view" mode or "edit" mode really belongs in the controller. Also, because views are not easily unit tested, you want to have as little logic in them as possible.

Upvotes: 1

Related Questions