Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7762479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:24:53+00:00 2026-06-01T14:24:53+00:00

I understand the theory behind the factory design pattern now, but can’t seem to

  • 0

I understand the theory behind the factory design pattern now, but can’t seem to find any realistic examples of it’s use. Can someone be as kind enough as to provide one?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:24:55+00:00Added an answer on June 1, 2026 at 2:24 pm

    There are a few variants of factory designs: abstract factory, factory method, etc… Since you’re interested in a real-world example, I thought I’d share what I did.

    As one example, I used a data access factory to return a concrete instance of a data access class. The logic class doesn’t know or care which database is being used; it simply asks the factory for a data class, and then uses that data class.

    This is the method within my DataAccessFactory class. It is responsible for determing which data class to use, and returning it to the caller:

    public static T GetDataInterface<T>() where T : class
    {
        Assembly assembly = Assembly.GetExecutingAssembly();
    
        T theObject = (from t in assembly.GetTypes()
                       where t.GetInterfaces().Contains(typeof(T))
                         && t.GetConstructor(Type.EmptyTypes) != null
                         && t.Namespace == _namespace
                       select Activator.CreateInstance(t) as T).FirstOrDefault() as T;
    
        return theObject as T;
    }
    

    And this is how one of my business logic classes makes a DAL request:

    return DataAccessFactory.GetDataInterface<IApplicationData>().GetAll();
    

    The business logic is completely decoupled from the data access layer. Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure that works correctly, but don't understand the theory behind
I'm no expert, I can't understand the theory in details but it is said
I understand the theory behind incompatible serialVersionUIDs (i.e. you can discriminate different compilation versions
I was studying the Model-View-Controller design pattern and i understand the concept behind the
I want to understand the actual theory behind types rather than just learning about
I don't understand the exact algebra and theory behind Haskell's monads. However, when I
I just read some stuff about the theory behind 3d graphics. As I understand
I basically understand the theory behind using the Hough Transform to detect parabolas (i.e.
We have a relatively simple assignment that I understand in theory but I think
I'm trying to understand the main concepts of graph theory and the algorithms within

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.