Click here to Skip to main content
15,792,384 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I got a question in my mvc interview which I am unaware.

The question is

I had view containing 2000 lines of code in mvc. On new client request I had to change the model associated with that view. So I need to overwrite the view loosing 2000 lines. Is there any way to restrict this. So 2000 lines doesn't got affected and also the model change should be reflected on the view too.
[no name] 11-Dec-14 23:35pm    
Model change in what sense by the way!!
Anuj Kc 13-Dec-14 23:43pm    
through scaffolding

One solution could be to define a common interface that will be used as model based on the existing model, then the new model must implement this interface.

There a similar discussion about this here:[^]
Share this answer
Suppose you have 2000 lines of code in your view.It's very hard to maintain those code inside views.You can avoid those lines of code through viewmodel.ViewModel nothing but a wrapper class,whatever the data needed for the view you can set to the viewmodel and pass to the view.So you should create each viewmodel for each view.In this viewmodel you can set all the logics and data for the final view.No need to write those logics inside View.I think interviewer expect the viewmodel concept.

Hope this helps
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900