- The current controller is not type-safe - although your view is <SomeType> for ViewData in your controller you can basically *suff* anything in the ViewData as it accepts an object - it suffers from all problems we've dealt with generics (and it's not
clear for the developers what they should send down the pipe to view)
- When I was trying to test the controller and the data sent down the pipe (ViewData) I had to both check if it had the typed data or if it had that data in the dictionary - this is not intention revealing, this is not clear, this is not good, it has too
much noise... not good... You should be able to say:
List<Order> orders = controller.ViewData as List<Order>
And that's it... this should be un-ambigious - especially now that we have the means (= Generics)
- Why like this... because currently to get the Rendered View, ViewData and Master in a test you need to subclass that controller... yuck... with this approach you could upon RenderView save it and extract it through the properties (which don't exist for
ViewName and MasterName) and again... get the type-safed ViewData which was sent down the pipe
Vladan Strig...
Participant
1011 Points
222 Posts
Re: What do you think, should default controllers look like this?
Jan 07, 2008 07:31 AM|LINK
Several things:
- The current controller is not type-safe - although your view is <SomeType> for ViewData in your controller you can basically *suff* anything in the ViewData as it accepts an object - it suffers from all problems we've dealt with generics (and it's not clear for the developers what they should send down the pipe to view)
- When I was trying to test the controller and the data sent down the pipe (ViewData) I had to both check if it had the typed data or if it had that data in the dictionary - this is not intention revealing, this is not clear, this is not good, it has too much noise... not good... You should be able to say:
List<Order> orders = controller.ViewData as List<Order>
And that's it... this should be un-ambigious - especially now that we have the means (= Generics)
- Why like this... because currently to get the Rendered View, ViewData and Master in a test you need to subclass that controller... yuck... with this approach you could upon RenderView save it and extract it through the properties (which don't exist for ViewName and MasterName) and again... get the type-safed ViewData which was sent down the pipe