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 6817671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:05:03+00:00 2026-05-26T21:05:03+00:00

I have a class that when passed an id becomes/proxies/mimicks/works with/wraps an instance based

  • 0

I have a class that when passed an id becomes/proxies/mimicks/works with/wraps an instance based on that unique id, but we can pass it a new id $obj->become($id); and it will change its internal state to work with that object instance instead. What is this design pattern called?

/edit/

Below is php pseudocode… this is the essence of the pattern I keep seeing.

class ObjectPoolManager{
    protected $objectPool;
    protected $currentlyManagedObject=null;

    public function become($id){
        //... searching $objectPool for $objectSpecifiedByIdParameter ...
        $this->currentlyManagedObject = $objectSpecifiedByIdParameter;
    }

    /*
    * All calls to the manager are delegated to the managed object
    */
    public __call($name,$arguments){
        return call_user_func_array(array($this->currentlyManagedObject, $name),$arguments);
    }
}
  • 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-26T21:05:03+00:00Added an answer on May 26, 2026 at 9:05 pm

    Often the pattern depends as much on intent as it does implementation.

    In this case, State is possible if the intent of this class is to represent a set of operations whose implementation differs based on its logic state (hence the name).

    Strategy is is also possible if the intent of become is to explicitly switch the algorithm (similar to selecting a compression routine to use on a subsequent Compress invocation).

    If the intent is to pool numreous stateless (meaning object instances with no data) such that they can be shared and therefore reduce the number of objects in memory then this could be a Flyweight.

    And of course, the layer of indirection represented here is a form of Proxy.

    Tell us what the intent of the code is and we can all provide better feedback.

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

Sidebar

Related Questions

I have a class that builds a request based on a few passed in
I have a class that occasionally gets passed null for File objects. During normal
I have class method that returns a list of employees that I can iterate
I have a class that map objects to objects, but unlike dictionary it maps
I have class that represents users. Users are divided into two groups with different
I have a class that I want to use to store properties for another
I have a class that I wish to expose as a remote service using
I have a class that looks like this public class SomeClass { public SomeChildClass[]
I have a class that creates several IDisposable objects, all of these objects are
I have a class that encapsulates tcp socket communications with a server. For each

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.