.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Factory Vs Locator Vs IoC

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net

As everyone knows, the factory pattern and service locator help to create an object and it's dependencies. Then we have IoC containers like Unity with the same motive. Can we discuss which is the right approach?

The pros of a factory pattern is that, there is involvement from the developers to create new dependable objects. The cons is that you have an extra layer in the application to just handle the dependencies.

The pros I see of both service locator and IoC is that you can approach the dependencies more as configurations - you are setting up the dependencies. No new layer in the application is needed. The cons may be the passive approach to development as you see in "don't call us, we'll call you".

Can we discuss?




View Complete Post

More Related Resource Links

Abstract Factory Design in C# , Vb.NET

Provide an interface for creating families of related or dependent objects without specifying their concrete classes

Factory Pattern in asp.net

The job of the Factory design pattern is to create concrete sub classes. You can see the Factory design pattern used throughout the .NET Framework.

The essence of the Factory Pattern is to "Define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses." Factory methods encapsulate the creation of objects. This can be useful if the creation process is very complex, for example if it depends on settings in configuration files or on user input.

The Factory Design Pattern

Software architects generally think in terms of high-level abstractions rather than low-level programming details. Representing a system in terms of high-level abstractions promotes understanding of the system and reduces its perceived complexity. One such set of abstractions is software design patterns. They have been successfully applied in the past to simplify and solve recurring problems in software design.

Abstract Factory Design Pattern (Sample in C# and VB .NET)

An abstract factory provides an interface for creating families of related objects without specifying their concrete classes. Sometimes one wants to construct an instance of one of a suite of classes, deciding between the classes at the time of instantiation. In order to avoid duplicating the decision making everywhere an instance is created, we need a mechanism for creating instances of related classes without necessarily knowing which will be instantiated.

Abstract Factory Pattern-Creational Patterns

The Factory pattern allowed us to decouple our client from an object which it uses. The Abstract Factory pattern extends this idea to manage separate families of objects.

A runtime selection, or configuration option, in our client could decide which family of objects is to be used. The Abstract Factory pattern allows us to write generic code to instantiate and use the family objects regardless of which family is chosen at runtime. The pattern also helps us enforce a rule where objects from just the chosen family are used uniformly by the client.

Service Station: Web Service Software Factory Modeling Edition


Web Service Software Factory: Modeling Edition is a collection of resources for modeling and building Web services for Windows Communication Foundation and ASMX.

Gerardo de Geest and Gerben van Loon

MSDN Magazine Launch 2008

Extreme ASP.NET: Web Client Software Factory


The Web Service Software Factory is designed to provide guidance and enhanced tools for building Web services using ASMX or WCF.

Fritz Onion

MSDN Magazine August 2007

Service Station: The Service Factory for WCF


This month Aaron Skonnard continues his exploration of software factories with a look at the Web Service Software Factory for Windows Communication Foundation.

Aaron Skonnard

MSDN Magazine February 2007

Service Station: Web Service Software Factory


Web Service Software Factory is designed to help you build Web service solutions that follow known architecture and design patterns, as Aaron Skonnard explains here.

Aaron Skonnard

MSDN Magazine December 2006

OWC11.Spreadsheet.11 - Retrieving the COM class factory for component with CLSID {} failed due to th

We have a web application (C#) which uses OWC11.Spreadsheet.11 to create excel files. This application works fine on XP 32bit, Windows 2003 server 32 bit versions. Recently we moved our application to a Windows 2008 web server 64bit machine. Now when we run the appication and call the functionality generate the Excel files which uses OWC11.Spreadsheet.11 it throws the following error.Retrieving the COM class factory for component with CLSID {0002E559-0000-0000-C000-000000000046} failed due to the following error: 80040154.In the code we use this library as follows using Microsoft.Office.Interop.Owc11; SpreadsheetClass xlsheet = new SpreadsheetClass();We have registered the Microsoft.Office.Interop.Owc11.dll in the global assembly cash as we have done in 2003 server.  We also tried running owc11.exe to insall all office 2003 web components.Can anyone help us to sort this issue.Thanks in advance.Sam

Validation(): Attribute 'Factory' is not a valid attribute of element 'ServiceHost'

Hi, I'm using REST WCF3.5. In my .svc file, the Factory attribute is giving me Warning in the Visual Studio Team Suite saying "Validation(): Attribute 'Factory' is not a valid attribute of element 'ServiceHost'." <%@ ServiceHost Language="C#" Debug="true" Service="RestService" CodeBehind="~/App_Code/RestService.cs" Factory="AppServiceHostFactory" %> using System; using System.ServiceModel; using System.ServiceModel.Activation; using Microsoft.ServiceModel.Web; class AppServiceHostFactory : ServiceHostFactory {  protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)  {   WebServiceHost2 host = new WebServiceHost2(serviceType, true, baseAddresses);                 // Add the basic authenticator interceptor   host.Interceptors.Add(new BasicAuthenticationInterceptor(    System.Web.Security.Membership.Provider, "foo"));   return host;  } } I've added the reference as well & Everything works fine but I was wondering why am I getting this warning?? Thanks!  

SQLTask fails :: f"Retrieving the COM class factory for component with CLSID {19E353EF-DAF4-45D8-9A0

OS :: Windows 2008 R2 x64 SQL :: 2008 R2 Enterprise x64 The package and task worked fine untill I migrated to a different server, now the SQL Task fails with the following error msg, see below. The package was developed on the same OS & version of SQL.   SSIS package "Package.dtsx" starting. Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "" failed with the following error: "Retrieving the COM class factory for component with CLSID {19E353EF-DAF4-45D8-9A04-FB7F7798DCA7} failed due to the following error: 800700c1.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. Task failed: Execute SQL Task SSIS package "Package.dtsx" finished: Success.  

Retrieving the COM class factory for component with CLSID {6568E194-96D8-4035-9087-99E4F75E9ABC} fai

We are accessing Adobe Photoshop through ASP.NET application and using following two DLLs: [1] Interop.Photoshop.dll [2] Interop.PhotoshopTypeLibrary.dll If we execute the web application within MS Visual Studio (IDE), its working fine and no such error. If we deploy the application in IIS then start producing following error: ------------------------- [UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {6568E194-96D8-4035-9087-99E4F75E9ABC} failed due to the following error: 80070005.]    _Default.Button1_Click(Object sender, EventArgs e) +45    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565 ------------------------- Using regedit we have looked for {6568E194-96D8-4035-9087-99E4F75E9ABC} and found several entries. We have assigned full privileges to ASP.NET, IUS

Hibernate factory initialization

Hi,   1. Could you please tell me where I could initialize (in the mvc code) the hibernate factory?Thanks!

Using the Service Locator in Sharepoint 2010

We are trying to prove out whether or not to use the Service Locator pattern presented in Sharepoint's Foundation pack download to consume WCF and other web services. According to the documentation, the Service Locator pattern can be used to consume services, but an interface and an implementation must be provided. I don't understand how to use the Service Locator pattern effectively with services. Is it possible to use the Service Locator pattern so that we can maintain one implementation and interface for the service for all of the web parts that we create? Thanks in advance for any help!

Donn Felkers Store Locator Oddity

I have been using this code for a while now and all is well except that my wife noticed some strange behavoir. Its this:When the Store locator page is loaded it gets a centered map lon/lat from a profile value.  It runs the search getLocations() and the map and grid are populated with locations nearby (as expected)This problem is this.  If I insert a new location to search from (say London), The numbering for the located items is not reset to 0 and seems to count from the total returned.  If I click the Search button again it does reset the count.Any ideas?Thanks

Error:Retrieving the COM class factory for component with CLSID {} failed due to the following error

  I am trying to take screenshots of any open Internet Explorer. I have writen the code and it works fine when I run the site in debug mode.
  Once the site is published I get the following error:

Retrieving the COM class factory for component with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} failed due to the following error: 8007000e.

This error is shown for the following line:
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();

I have given permission to various files for aspnet user.

I have looked up most of the forum but to no avail.

Any help would be greatly appreciated.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend