Back to list
Views:   8.1K
Replies:  1
Archived

Design pattern for Controller in ASP.NET MVC3

I have WCF Services exposed by dynamics CRM 2011,  and a ASP.NET MVC3 portal to consume these services.

I have to make call to WCF services from controller and I don't want to make call to WCF services directly from controller. I can think of following patterns

  • Service Facade
  • Command Factory
  • DI and IoC at controller level

What is the best practice in terms of patterns for this scenario.

Thanks


Vishal G, Oct 18, 2011
Reply 1
DI and IOC will complement the wcf services (whether you use Service Facade or not). But even DI/IOC is not always required. Evaluate your scenarios and choose the best fit approach

But since you mentioned your WCF services just provide an abstraction layer for your CRM 2011, having the layer of indirection of DI/IOC is a good idea and will make your design a bit flexible.
Rajesh Pillai, Dec 02, 2011
Yeh.. In a hurry I have mixed two things.. You are right. I am updating the answer to reflect what I mean. What I intend to describe was the the factory method could be easily replaced by generics...
Mar 22, 2011
But would using the suggestion I made not make this a factory pattern after all?
Mar 22, 2011
Thanks, Rajesh. But with the where constraint you have there, I would still have to create each EmployeeCreator class since you are stating that the Generic T parameter must implement EmployeeCreator. Would it be more correct to do something like: public Employee Create(EmployeeType type) { if(type == EmployeeType.Secretar) return new Secretary(); } ?
Mar 22, 2011


Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.2.2