Questions tagged [multiton]

The Multiton pattern is a creational design pattern. This pattern expands on the singleton concept to manage a fixed number of instances of the Multiton class. This typically done with a map of named instances as key-value pairs.

The Multiton pattern is a design pattern similar to the singleton, which allows only one instance of a class to be created. The Multiton pattern expands on the singleton concept to manage a fixed number of instances. This typically done with a map of named instances as key-value pairs.

Rather than having a single instance per application (e.g. the application object itself in many programming languages) the Multiton pattern provided a fixed set of instances.

A simple example for a Multiton class may be the class Weekday, which allows just seven instances named monday, tuesday, wednesday, thursday, friday, saturday, and sunday. This class keeps its constructor private, and allows access to the seven instances by one class method (e.g. weekdayByName()) or seven class methods (one for each weekday).

Reference wikipedia

30 questions
1
vote
1 answer

Change a Singleton with static properties into a Multiton

I have the following Singleton class public class TestFileEngine { private static int counter = 0; private static List generatedFileList; private static Optional engine = Optional.empty(); private…
Eldros
  • 551
  • 1
  • 9
  • 28
0
votes
1 answer

Who appointed the term Multiton originally?

Who appointed the term Multiton originally? I am referring to a variation of the singleton pattern: http://en.wikipedia.org/wiki/Multiton_pattern Why the word “Multiton”? That’s not a real English word. Isn’t it?
YAA
  • 409
  • 1
  • 5
  • 11
0
votes
0 answers

Multiton Design Pattern in swift (multi singleton)

I am trying to implement multi theme inside application with the help of multiton design patterns. I never implemented multiton before. Please have a look is it prefect implementation or we can implement in some better way. import UIKit …
Matloob Hasnain
  • 1,025
  • 6
  • 21
0
votes
1 answer

How to implement multiton pattern using Spring Framework

How does one implement multiton pattern using Spring Framework's facilities? https://en.wikipedia.org/wiki/Multiton_pattern I want to write a factory which takes a pair of client and supplier as arguments. The factory should always return a bean of…
jerry.pepper
  • 165
  • 1
  • 12
0
votes
1 answer

How to store an instance into an internal table to display the multiton design pattern?

I have a task to create a simple demo of the multition design pattern in ABAP. As far as I understand instances created should be stored into a static internal table so they can later be used. Here is my attempt: CLASS zrp_casino_bl…
0
votes
0 answers

Asynchronous Multiton pattern in JavaScript?

I want to cache performance intensive object generation using the Multiton pattern in JavaScript with an asynchronous function. I provide an example and would like to know if I implemented that correctly, i.e. whether that is enough to guarantee…
Konrad Höffner
  • 11,100
  • 16
  • 60
  • 118
0
votes
2 answers

c# - Implementing plugin Instance property for internal scoped code

i've created my own plugin architecture for one of my programs. Basicly Plugin is the base class for all of my plugins and say that i've plugins like PluginA : Plugin, PluginB : Plugin. public class Plugin { private static Plugin _instance; …
HuseyinUslu
  • 4,094
  • 5
  • 33
  • 50
0
votes
1 answer

Multiple instances of views in PureMVC: Am I doing this right?

What I'm doing NOW: Often multiple instances of the view component would be used in multiple places in an application. Each time I do this, I register the same mediator with a different name. When a notification is dispatched, I attach the name of…
LazerWonder
  • 118
  • 1
  • 9
0
votes
1 answer

Best Practice : Thread safe Multiton pattern with lazy initialization

Idea is to create a factory class that returns different singleton instances based on a 'type'. [Multiton pattern]. Also, the singleton instances should be lazily created. Is the below code thread safe? Using ConcurrentHashMap makes it simpler but…
user170008
  • 1,046
  • 6
  • 17
  • 31
0
votes
3 answers

A C++ idiom for per-class data, accessible without needing virtual getter methods

(This question is related to reflection, but isn't really about reflection) I have this hierarchy of classes (say class A and class B : public A), and in addition to instance-specific data, I'd like to have class-specific data shared by all…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
0
votes
2 answers

Side Effects of Multiton Pattern Usage

I have to need your advice, code-review or improvement about my multiton pattern implementation. I want to multi-connection support for mongodb server. public class MongoDatabaseFactory { private static volatile Map
Hasan Ozgan
  • 45
  • 1
  • 8
0
votes
1 answer

Multiple database connections using multiton or any design pattern

I have following code for multiple database connections. It's not good design. Everything is static. But don't know how to improve it. i can add more functions like prepare query, but presently I want good/clean design. I tried to make multiton…
0
votes
1 answer

Enum constant specific initialization

Now, we all know that an enum is a great way to do multitons (ie. a class which has a fixed number of instances, known at compile-time), as each constant is pretty much a singleton subclass of your own enum class. However, I've run into a problem…
Kelvin Chung
  • 1,327
  • 1
  • 11
  • 23
-2
votes
2 answers

How to make list with unique values with dictionary (multiton pattern)

I need to make this magazine_list that holds only unique values and do it by using dictionary and multiton pattern. List cannot have two objects with the same both name and price. I found only one example of multiton pattern in c# and it didn't…
user3308470
  • 107
  • 1
  • 3
  • 10
-3
votes
1 answer

Multiton design pattern in ES6

I want to create Multiton Design Pattern as part of my user module in my node.js application. And I need good examples of it.
Mike Malyi
  • 983
  • 8
  • 18
1
2