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

  • Home
  • SEARCH
  • 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 6915847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:31:35+00:00 2026-05-27T09:31:35+00:00

I have a library with only interfaces and basic objects, lets call it API.

  • 0

I have a library with only interfaces and basic objects, lets call it API. The API has a few known implementations, that may increase in number for the needs of an application. The application can use only one implementation at a time. I have another library, lets call it PROXY, which provides a basic implementation of the API library, and it delegates the logic to a real implementation of the API. The real implementation is provided by configuration and the PROXY library takes care of creating the appropriate real classes and wrapping them. The idea is to use the API and PROXY libraries in my code, so that I can change implementations without recompiling the application – just changing the configuration and providing the real implementation library in the classpath. Here is an example code in C#:

API:

public interface IFoo
{
    void Bar();
}

PROXY:

public class Foo : IFoo
{
    private IFoo _realFoo;

    public Foo()
    {
        _realFoo = ...; // Assume reading the config and creating the real implementation with reflection here.
    }

    void Bar()
    {
        _realFoo.Bar();
    }
}

Real Implementation:

public class RealFoo : IFoo
{
    void Bar()
    {
        // Some specific logic 
    }
}

I guess the Foo class above uses Decorator Pattern to wrap arround the real implementation. I am more interested if the whole approach has a specific name?

  • 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-05-27T09:31:36+00:00Added an answer on May 27, 2026 at 9:31 am

    This is not a use of the Decorator pattern for a number of reasons, most importantly in intent.

    It is a Proxy. Genericly the proxy pattern

    Provides a surrogate or placeholder for another object to control
    access to it

    The fact that you are using it to dynamically load your implementation and therefore have a loose coupling with your implementation based on configuration also make it similar to Dependency Injection. Your version differs in that you have a proxy object in the middle. If instead your client held a reference to RealFoo, but this reference was obtained via the kind of mechanisms you are talking about, then that would more closely match Dependency Injection.

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

Sidebar

Related Questions

I have had a bug recently that only manifested itself when the library was
I have a library that interacts with our phone system, ie, Hey phone, call
I have created a VB.NET 2008 Class Library that has, for the most part,
I have a C# library with lots of internal functionality exposing only a few
Many library classes in AS3 have read only properties. Is it possible to create
I have a library A, that I develop. When I deploy it on a
I have a library that I would like to license and distribute. I know
This is a biggie. I have a well-structured yet monolithic code base that has
I have an old C++ library which has been designed for use in single-threaded
I have a class that has dependencies that I've wired up with Ninject. public

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.