Chad and me have been talking about some changes that we (maybe more
me, anyway, I am a dreamer ;) would like to see happening. One of
these changes is that we might want to drop the controllers all
together and only have behavior chains. Because if you look at the
current controllers they don’t offer any added benefit (except for
conventional configuration). This also mean that you will not have
multiple action methods in one class anymore, so in that respect a
little bit less freedom, added benefit is that SRP is more enforced :)
An other thing that I really like is splitting up the web page into
multiple responsibilities and give each responsibility its own model
and behavior chain. What I mean with this is that the master page has
its own model. The actual view will have its own model, you will still
be playing with partial views that take their model from the model of
the view it self. But you will also be able to add partial views that
have their own model not related or attached to the model of the view
that calls the partial view.
The mean reason I really like this idea is that currently the model is
getting very fat, it needs to know about to many things (things
unrelated to each other). One downside might be if you need the same
information in the different models like logged on user, but that can
perhaps be solved using some sort of caching.
Url’s will most like not be auto discovered anymore, but this was a
big issue anyway and in most cases not even possible. So I don’t see
that as a big loss. Now I have an idea on this as well but it won’t be
sufficient.
This means that now you can have the following scenario:
/Home/Index
/Home/Index.aspx (view)
- HomeModel
- - - access_the_database_through_a_unit_of_work
- - get_last_five_blog_posts
- - execute_the_results
- - - - Shared/BlogPostPartial.ascx (takes posts from the HomeModel.Posts)
- - load_the_current_principal
/Shared/MasterPage.aspx
- MasterPageModel
- - set_the_current_site_details_on_the_output
/Shared/MenuPartial.ascx
- MenuModel
- - load_the_current_principal
/Shared/LastTenPublishedPostsPartial.ascx
- LastTenPostModel
- - get_recent_blog_posts
What happens here is a action invoker loads the view and the view has
a model defined which has a chain of behaviors attached to it. These
get executed. Also the view need a master page that has its own model
and chain of behaviors that get executed. During executing of the view
and master page the render (or something else) discovers that there
are partial views being loaded that depend on a model _not_ provided
by the parent model, then it will also get these models and behavior
chains.
Now this needs much thinking and finalizing but I hope you can
appreciate that doing it this way you increase reusability and you are
really separating the different concerns. The models will become a lot
cleaner.
Now I don’t know yet how to configure all of these things, you
probably want to be able to re-use models with different behaviors
attached going towards different views or partial views. Perhaps a
partial view should also be able to be rendered on its own with its
own Url. Some urls will only have Json results or RSS results and so
on.
Anyway this is something that I feel that could be awesome but feel
free to burn it to the ground :)
-Mark
BTW, with my limited time/resources, this kind of evolution is the reason
that I have held back about my offer to explore T4 templates and tooling
support.