I moved my controllers into the business logic assembly where they belong. But to get my MVC running I had to make a little trick: I changed the namespace from my cntrollers to the namespace of the Web Project, otherwise the Views didn't find my controllers.
Is there a more elegant way of telling the views where theere controllers are?
Thanks, Rainer
Never underestimate the power of stupid people in large groups.
Yes there is a more elegant way of having the views know where the controller is. Keep the controller in the web project where it belongs. OK, I don't mean to be a smart ass, but I really can't think why you believe that the controller belongs in the business
logic assembly. Business logic is just that and should be completely testable without regard to a UI or even considerations of a UI. There might be no UI for example in a webservice. Controllers in an MVC are used to create UIs. And in particular the controller
in the ASP.NET MVC framework is specifically targeted to the web and as such will include web references that just do not belong in a business logic DLL.
I think you misunderstood the concept of MVC Framework. Your views will never ever know about controllers directly. It should be the other way around, i mean your controller will be aware of your views. you route the paths to your controllers. And if you still
want to put controllers to business layer, please take a look at my post: http://forums.asp.net/t/1228179.aspx
I can think of some very legitimate reasons why it would be a good idea to have controllers in a separate assembly. Consider an environment where you have multiple different apps with *completely* different interfaces and UI requirements that share the same
Controller logic. In such a case, it would be a VERY valid scenario to put controllers in a separate assembly that could be shared between projects. I'm currently working in such an environment.
aspevia
"Controllers in an MVC are used to create UIs."
That's a first for me. The "V" in MVC stands for "View" ... which *is* the UI for an MVC application, not the Controller. Unless there is a compelling need to extract it and place it somewhere else (often times, the Model is more appropriate), the Controller
*is* where I put much, if not all, of the business logic in my MVC apps.
With that out of the way ... I think the original question is a very legitimate one, and I'd love to know the answer to it.
I can think of some very legitimate reasons why it would be a good idea to have controllers in a separate assembly
putting controllers in a separate assembly wasn't the original question. It was putting controllers in the business logic assembly where they clearly do not not belong.
ryexley
That's a first for me. The "V" in MVC stands for "View" ... which *is* the UI for an MVC application, not the Controller
As to the question about controllers used to create UIs. That's what they are for. Sure the view is the visible UI, but the controller is meant specifically for interacting between the model and the view. Without the view the controller has no meaning
in MVC. In traditional MVC (before the Web variant of it), the controller handled events from the view. In that scenario it could easily be argued that a click event while not a "view" is a UI phenomenon and thus the controller while it may not "be" the
UI, is intimately involved with it.
putting controllers in a separate assembly wasn't the original question
Sorry...I guess I was going by the title of the thread: "How to move the controllers into Businee Logic assembly?" Seems to me to be asking how to put controllers into a separate assembly.
Sorry...I guess I was going by the title of the thread: "How to move the controllers into Businee Logic assembly?" Seems to me to be asking how to put controllers into a separate assembly.
And I guess I should have gone with the spirit of the thread rather than the letter. Yes it would be nice to know how to put them in a separate assembly. I'm not sure I need it, but certainly there could be a need for it.
It was putting controllers in the business logic assembly where they clearly do not not belong.
aspevia
Without the view the controller has no meaning in MVC.
I think you need to do some more reading on the
MVC pattern.
wikipedia
The model-view-controller solves this problem by decoupling data access and
business logic from
data presentation and user interaction, by introducing an intermediate component: the controller.
Maybe you are thinking strictly in terms of a "front controller" pattern? True, they decide which view to use, but that is not their only purpose.
Their main purpose is to control business logic. Controllers == Business Logic. All of my business logic is in my controllers. All of my controllers are in my business logic assembly. My controllers assembly is completely independent of my view, and
therefore, completely testable independently of the views. The controller has knowledge of an interface to a view, but doesn't care how the view is implemented.
Maybe you are thinking strictly in terms of a "front controller" pattern? True, they decide which view to use, but that is not their only purpose.
Their main purpose is to control business logic. Controllers == Business Logic. All of my business logic is in my controllers. All of my controllers are in my business logic assembly. My controllers assembly is completely independent of my view, and
therefore, completely testable independently of the views. The controller has knowledge of an interface to a view, but doesn't care how the view is implemented.
That's exactly what I meant and that's the reason why I want them in a seperat assembly, the BizLogic Assemlby that I can test. As I wrote above, it works if you give them the View namespace, but that is an ugly hack.
Never underestimate the power of stupid people in large groups.
Cepheus
Member
337 Points
75 Posts
[MVC] How to move the controllers into Businee Logic assembly?
Mar 04, 2008 06:27 AM|LINK
Hi,
I moved my controllers into the business logic assembly where they belong. But to get my MVC running I had to make a little trick: I changed the namespace from my cntrollers to the namespace of the Web Project, otherwise the Views didn't find my controllers. Is there a more elegant way of telling the views where theere controllers are?
Thanks, Rainer
aspevia
Member
73 Points
33 Posts
Re: [MVC] How to move the controllers into Businee Logic assembly?
Mar 04, 2008 12:10 PM|LINK
Yes there is a more elegant way of having the views know where the controller is. Keep the controller in the web project where it belongs. OK, I don't mean to be a smart ass, but I really can't think why you believe that the controller belongs in the business logic assembly. Business logic is just that and should be completely testable without regard to a UI or even considerations of a UI. There might be no UI for example in a webservice. Controllers in an MVC are used to create UIs. And in particular the controller in the ASP.NET MVC framework is specifically targeted to the web and as such will include web references that just do not belong in a business logic DLL.
My 2 cents,
Trevor
tehlike
Member
70 Points
25 Posts
Re: [MVC] How to move the controllers into Businee Logic assembly?
Mar 04, 2008 01:27 PM|LINK
ryexley
Member
98 Points
22 Posts
Re: [MVC] How to move the controllers into Businee Logic assembly?
Mar 04, 2008 01:52 PM|LINK
I can think of some very legitimate reasons why it would be a good idea to have controllers in a separate assembly. Consider an environment where you have multiple different apps with *completely* different interfaces and UI requirements that share the same Controller logic. In such a case, it would be a VERY valid scenario to put controllers in a separate assembly that could be shared between projects. I'm currently working in such an environment.
That's a first for me. The "V" in MVC stands for "View" ... which *is* the UI for an MVC application, not the Controller. Unless there is a compelling need to extract it and place it somewhere else (often times, the Model is more appropriate), the Controller *is* where I put much, if not all, of the business logic in my MVC apps.
With that out of the way ... I think the original question is a very legitimate one, and I'd love to know the answer to it.
|| «.YEX.»
|| <)))><
|| John 16:32-33
|| http://bob.yexley.net
*/
aspevia
Member
73 Points
33 Posts
Re: [MVC] How to move the controllers into Businee Logic assembly?
Mar 04, 2008 02:07 PM|LINK
putting controllers in a separate assembly wasn't the original question. It was putting controllers in the business logic assembly where they clearly do not not belong.
As to the question about controllers used to create UIs. That's what they are for. Sure the view is the visible UI, but the controller is meant specifically for interacting between the model and the view. Without the view the controller has no meaning in MVC. In traditional MVC (before the Web variant of it), the controller handled events from the view. In that scenario it could easily be argued that a click event while not a "view" is a UI phenomenon and thus the controller while it may not "be" the UI, is intimately involved with it.
ryexley
Member
98 Points
22 Posts
Re: [MVC] How to move the controllers into Businee Logic assembly?
Mar 04, 2008 02:48 PM|LINK
Sorry...I guess I was going by the title of the thread: "How to move the controllers into Businee Logic assembly?" Seems to me to be asking how to put controllers into a separate assembly.
|| «.YEX.»
|| <)))><
|| John 16:32-33
|| http://bob.yexley.net
*/
aspevia
Member
73 Points
33 Posts
Re: [MVC] How to move the controllers into Businee Logic assembly?
Mar 04, 2008 02:52 PM|LINK
And I guess I should have gone with the spirit of the thread rather than the letter. Yes it would be nice to know how to put them in a separate assembly. I'm not sure I need it, but certainly there could be a need for it.
davethieben
Member
10 Points
11 Posts
Re: [MVC] How to move the controllers into Businee Logic assembly?
Mar 04, 2008 03:16 PM|LINK
I think you need to do some more reading on the MVC pattern.
Maybe you are thinking strictly in terms of a "front controller" pattern? True, they decide which view to use, but that is not their only purpose.
Their main purpose is to control business logic. Controllers == Business Logic. All of my business logic is in my controllers. All of my controllers are in my business logic assembly. My controllers assembly is completely independent of my view, and therefore, completely testable independently of the views. The controller has knowledge of an interface to a view, but doesn't care how the view is implemented.
tehlike
Member
70 Points
25 Posts
Re: [MVC] How to move the controllers into Businee Logic assembly?
Mar 04, 2008 03:16 PM|LINK
Cepheus
Member
337 Points
75 Posts
Re: [MVC] How to move the controllers into Businee Logic assembly?
Mar 04, 2008 03:27 PM|LINK
That's exactly what I meant and that's the reason why I want them in a seperat assembly, the BizLogic Assemlby that I can test. As I wrote above, it works if you give them the View namespace, but that is an ugly hack.