Skip to main content

Questions tagged [factory-method]

4 votes
3 answers
3k views

Description I want to create an instance of an object at runtime, however, the parameters used to create the object are not always the same. To help explain, I have created a simplified example (in ...
zwoolli's user avatar
  • 151
0 votes
0 answers
193 views

I started using factory methods in JPA Entity classes. But I'm not sure if it's an anti-pattern. If it is , then where do I place them instead ? A similar sample is below @Builder @Entity Class ...
kommradHomer's user avatar
0 votes
0 answers
1k views

I have the following classes in my system (python): class Metric(ABC): def compute(self): -> float class Visualization(ABC) def visualize(self) class FirstMetric(Metric) def __init__(...
ledermauss's user avatar
2 votes
2 answers
765 views

I'm learning about the Factory Method Desing Pattern and I'm having a hard time to understand exactly what it tries to solve and how. Let's first introduce the example that Wikipedia uses to have a ...
YoavKlein's user avatar
  • 172
0 votes
3 answers
792 views

Suppose we have a BaseModel, which has a type enum, and derived models with same constructor signatures to each other, whose implementations are like : public DerivedModelJ(Object arg1, ..., Object ...
Mike Warren's user avatar
1 vote
2 answers
3k views

I have a simple class called Link that contains some properties, and use different classes for creating different types of links. My code looks like this: class Link { String reference, label, ...
Harold L. Brown's user avatar
-2 votes
1 answer
705 views

I have a program which downloads web pages and then scrapes html to create domain specific collection objects e.g. ProductCollection, CatalogCollection, NewsCollection and more. The idea is to create ...
Navjot Singh's user avatar
0 votes
2 answers
157 views

After working through several tutorials and reading various responses on this site, I believe the Abstract Factory pattern would work well for a current project. I am seeking the opinions of those ...
Norm Schaeffer's user avatar
0 votes
2 answers
633 views

I need to vary the object creation at (*). public class Parser { // Problem code public List<FileOption> methodA() { // Does something ... fileOptions....
Sebastian Nielsen's user avatar
1 vote
1 answer
303 views

I have a program that involves two different data structures, and so I created a class that acts as a generalized data structure that either of the original two can be represented as. (Because the ...
Aaron's user avatar
  • 19
3 votes
1 answer
2k views

I always had problems in grasping the full benefits/motif behind using the Factory design pattern (for this post, I will stick to Factory Method pattern, specifically). True, there are (really) lots ...
Veverke's user avatar
  • 541
2 votes
1 answer
592 views

I'm working on an application which needs to open a database file. There are 2 "versions" of this database: one of them is more general data storage, and the other contains "less" information. That ...
user3132457's user avatar
21 votes
6 answers
14k views

I am new to design patterns and working my way through the Factory Method and Strategy patterns. I understand that Factory is a creational pattern and Strategy is behavioral but I struggle to ...
Reynier Booysen's user avatar
0 votes
2 answers
512 views

Let's assume a SimpleFactory that creates a group of objects: public SimpleFactory { public Bycicle createBycicle(String type) { if(type.equals("ONE")) return new OneWheelBycicle(); if(...
Asier Naiz's user avatar
5 votes
5 answers
4k views

So almost every post I read about oop by purists, they keep stressing about how using static methods is anti pattern and breaks the testability of the code. On the other hand every time I look for ...
lahory's user avatar
  • 315

15 30 50 per page
1
2 3 4 5