Skip to main content

All Questions

1 vote
1 answer
156 views

Is this right for a factory method producing singletons?

I've got this bit of code for a factory method to produce singletons. I have a small MAUI app and want to have persistent global data. public static class FactoryService { private static ...
XJonOneX's user avatar
  • 404
0 votes
0 answers
25 views

Is this the Abstract Factory pattern or something else?

I have an abstract class that's following the singleton pattern, then I have a few concrete classes that extend it: UML Diagram At startup, based on the current system, I'm setting a concrete instance ...
jackson915's user avatar
0 votes
1 answer
1k views

what is the best way to move logic from controller to a service

my question is : How to take my business logic out of controller and transfer it to a service ??? I am currently using two separate controllers for Post model in Laravel. One for user-related logic ...
Elmo Townsend's user avatar
4 votes
1 answer
4k views

How to implement Singleton pattern in Dart using factory constructors?

I'm trying to implement the singleton pattern in a database helper class, but, I can't seem to understand the purpose of a factory constructor and if there's an alternative method to using it. class ...
Salma's user avatar
  • 1,260
0 votes
3 answers
663 views

Changing `self` for another instance of same object?

I want to create a class, and all objects need to have a unique identifier key, and If I attempt to create a new instance of the object with a previously existent key, the instance should be the same ...
ekiim's user avatar
  • 842
2 votes
2 answers
5k views

Combining the Factory Method and Singleton Design Patterns

I am currently implementing a game in which there are different types of maps. Being all maps, they naturally share certain attributes and methods, so an abstract class Map was created, to then be ...
Luke Collins's user avatar
  • 1,463
0 votes
2 answers
702 views

What is the best way to implement Singleton pattern combined with Factory pattern in Java? Detail in description

I am learning design patterns for JAVA. I wanted to use factory pattern with singleton. Now I am not sure If I went with correct approach or not. Let me share what I have tried first. I have used ...
PareekSandeep's user avatar
3 votes
4 answers
297 views

How do I return a limited number of cached instances in Java?

I have a "configuration" class that becomes a field of several other classes. It indicates some kind of configuration or "abilities" of those other classes to allow or disallow actions. The ...
manuelvigarcia's user avatar
0 votes
1 answer
76 views

Is this singleton design pattern bad? Is it wrong to use Singleton in this case?

The problem: For simplicity i'll use a simple example. In a sample application, a Class-A reads some data. Class-A then instantiates Class-B, which then instantiates Class-C. So in all there is a 3-...
Just a coder's user avatar
  • 16.6k
0 votes
1 answer
815 views

Optimized way to create OracleConnection and Command objects in c#

I have the following code in DAL layer: using(OracleConnection conn= new OracleConnection(connString)) using(OracleCommand cmd = new OracleCommand(sql.ToString(), conn)) { conn.Open(); } The above ...
WonderHeart's user avatar
0 votes
1 answer
108 views

C++ Factory of templated sigleton

Here a simple project in C++ with 2 design pattern: singleton and factory, sigleton is a templated class too and an interface (IHash) and a class (Hash1). A simple factory class (HashFactory) creates ...
gekomad's user avatar
  • 565
1 vote
1 answer
1k views

Where to initialize Factory object?

I'm used to creating Singletons to implement a globally shared state, and I'm reading about how Singletons aren't testable and that the Factory pattern should be used instead. The problem I'm having ...
Jay's user avatar
  • 568
2 votes
1 answer
850 views

Java Abstract Factories and Singletons [duplicate]

I would like to implement an example of abstract factory, however concrete factories must be served as singletons. Giving the example of Mr. Banas here : http://www.newthinktank.com/2012/09/abstract-...
Phil's user avatar
  • 65
1 vote
1 answer
2k views

how to use singleton and/or factory patterns in business logic layer

I understand the purpose of singleton and factory patterns, however I have doubts implementing it. My problem is that whenever I need to call a method from BLL, then I have create an instance of BLL ...
renakre's user avatar
  • 8,271
-2 votes
2 answers
658 views

Singleton pattern combined with Factory [closed]

I'm running an email marketing program that runs and schedules campaigns. So I have two types of campaigns in it: Ad hoc Scheduled And since I want my program to create one campaign at a time. I ...
disasterkid's user avatar
  • 7,268

15 30 50 per page