What is the name of a template with single-dot values?

I wonder what type of template I am using. I am confused between factory, proxy and multitone. Thank you for your responses.

class Base extends Database
    {
        /**
         *  base class that contains common methods through 
         *  out the application, and loading of application configs
         */
    }

    class MyObjectsBase extends Base
    {
        /**
         * base class for my objects
         */
    }

    interface MyInterface
    {
        /**
         * interface methods
         */
    }

    class MyObj1 extends MyObjectsBase implements MyInterface
    {
        /**
         * MyObj1 class
         */
    }

    class MyObj2 extends MyObjectsBase implements  MyInterface
    {
        /**
         * MyObj2 class
         */
    }

    class PatternInQuestion
    {
        private static $singleInstanceOfType = array();


        public static function getInstance ($objType)
        {
            if ( ! array_key_exists($objType, self::$singleInstanceOfType) ) {
                self::$singleInstanceOfType[$objType] = new $objType();
            }

            return self::$singleInstanceOfType[$objType];

        }

    }

    /**
     * Usage :
     */

    $type = 'MyObj2';

    $obj = PatternInQuestion::getInstance($type);

      

I wonder what type of template I am using. I am confused between factory, proxy and multitone. Thank you for your responses.

+3


source to share


1 answer


This is an implementation of the multiton pattern .



In software development, a multiton pattern is a singleton-like design pattern that only allows one instance of a class to be created. The multi-tone pattern extends from the singleton concept to manage the map of named instances as key-value pairs.

0


source







All Articles