Skip to main content

Questions tagged [abstract-factory]

The abstract factory pattern provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes.

Filter by
Sorted by
Tagged with
32 votes
5 answers
5k views

Chess game for my students

I teach programming, and I currently teach my class about inheritance, abstract classes, and mixins. I wrote this code as an example, and I want to be sure it is as good as possible before I release ...
Infinity's user avatar
  • 505
9 votes
3 answers
14k views

Raising error if method not overridden by sub-class

Background I have a base (only 2 classes inherit from it, and only from it) abstract (meaning I don't want it to be used directly) class that implements some common functionality. Some of it depends ...
Yatharth Agarwal's user avatar
8 votes
1 answer
11k views

Abstract Factory Pattern C# Example

I am working through more tutorials on Design Patterns and came across the Abstract Factory Pattern. I extended it out a bit (the example that is) and want your opinion: ...
Michael Mahony's user avatar
7 votes
2 answers
580 views

Java - Something similar to Abstract Factory?

I have many repositories stored in a map. User chooses some of them and then a downloading begins. Repository may be one of 4 types (see code below). ...
naXa stands with Ukraine's user avatar
7 votes
2 answers
769 views

Factory for mathematics Q&A

I'm having a hard time creating a design (due to my lack of experience). I need a little of help to create the Model. It's a mathematics system. I've created an ...
Darf Zon's user avatar
  • 561
5 votes
1 answer
1k views

Object factory from interface types

I have a library that defines a bunch of ISprite interfaces, like IPieceSprite and ...
Mazyod's user avatar
  • 209
5 votes
1 answer
1k views

Initializing characters in a visual novel game

I am making a visual novel game and I was wondering is there a better way of setting character attributes and initializing than the way that I have done down below. As you can see I did an abstract ...
Jake Snyder's user avatar
4 votes
2 answers
144 views

Abstract Factory Implementation C#

I'm learning Factory pattern and I've implemented this simple example of an abstract factory. I've followed this video a little bit while writing this small example. Is there anything anti-pattern or ...
Hammas's user avatar
  • 141
4 votes
2 answers
5k views

Abstract factory using generics

I am learning design patterns and I have implemented the abstract factory using generics C#.NET. Is this implementation correct or not? Or is there any SOLID principle violation? ...
phoenix's user avatar
  • 49
3 votes
1 answer
1k views

Abstract Factory in C++

I have tried my hand at the abstract factory pattern in C++: ...
Fang's user avatar
  • 545
3 votes
2 answers
984 views

Abstract factory pattern implemented in Java

I need a code review on my Abstract Factory pattern written in Java. Find the two enums AnimalType.java and DietType.java below. ...
Rahul Shivsharan's user avatar
3 votes
3 answers
277 views

A refactored payment service, handling several payment schemes

I was asked to refactor a class, to make it adhere to SOLID principles, with testability and readability. I thought I had done a decent job, only my feedback was: a) Unnecessary introduction of ...
zola25's user avatar
  • 140
3 votes
1 answer
316 views

Abstract Factory Pattern in Python

I have been reading today about the Abstract Factory Pattern, and tried to make the following implementation. I have seen a lot of implementations in the internet, where they use ...
revliscano's user avatar
3 votes
2 answers
15k views

Implementing DAO Factory

I'm trying to do three different type of DAOs with 4 subtypes of each. I have RAM, SQL and Serial with each one have four subtypes. Is a singleton necessary with my implementation within the factory ...
user3590149's user avatar
3 votes
1 answer
855 views

Building an email generator using abstract factory pattern

I'm trying to build a customer email generator in java using the abstract factory pattern. I understand how to use the factory method pattern; however, I'm a bit confused about the abstract factory ...
rafiaTech's user avatar
  • 131
3 votes
1 answer
130 views

Design Pattern - Abstract Factory Pattern Implementation in PHP

Products Class that are like Table, Chair, etc. Please review it and give your thoughts and let me know if there are any rooms for improvement. Products.php ...
indianwebdevil's user avatar
3 votes
1 answer
1k views

Event Aggregator Pattern Decoupling

I have an Android application that is using an EventBus architecture with publishing and subscribing events. Usually this is ...
AndyRoid's user avatar
  • 293
2 votes
2 answers
975 views

Implementation of Abstract Factory pattern with different vendors for product

I am studying about design principles and design patterns. I have implemented an Abstract factory pattern as per my understanding. The scenario I have considered is as follows : There is an ...
Krishna Kumar's user avatar
2 votes
1 answer
604 views

Abstract Factory Design Pattern

I have tried to implement the abstract factory design pattern. This is a complicated pattern. Can you review? My understanding of the pattern is: the objects to be constructed have two or more member ...
TradingDerivatives.eu's user avatar
2 votes
1 answer
553 views

Game engine ObjectFactory class

I've developed as part of a game engine a template class for a factory which manages objects of one specific type. The factory handles initialization, destruction, and accessing previously created ...
Mike's user avatar
  • 23
2 votes
1 answer
427 views

Car store implementation using abstract factory

I'm studying design patterns and I made this car store implementation. Although I'm confident that the idea is right, I'm not confident that the implementation is good. I would like you to check it ...
yayuj's user avatar
  • 185
2 votes
0 answers
266 views

Swift Struct-based Factory Pattern

Edit: I added another configuration vector to CardView, a size attribute, which may be .small or ...
Richard Robinson's user avatar
2 votes
0 answers
827 views

Auto-registering CRTP Factory

I'm trying to write a policy based auto-registering class using the Curiously Recurring Template Pattern. I decided as design choice to not using registering macro. Factory Class ...
Moia's user avatar
  • 121
2 votes
0 answers
68 views

PDcurses clock using abstract factory design

I am currently learning how to use PDcurses and decided to make a clock with it. **NOTE: this Watch that uses the abstract factory design pattern is not the same as this question!!. This question is a ...
globalturist's user avatar
1 vote
2 answers
160 views

Derived methods with Poker classes

I have an interface with two functions. This interface is being inherited by an abstract class which implements just one of those functions. The other one is left to be implemented by the derived ...
Denis's user avatar
  • 8,508
1 vote
2 answers
1k views

Using Factory Design Pattern in Rest Controller of Spring

I used factory design pattern to identify the service according to the enum that comes from the api uri as request param. Everything seems okay according to me but cannot be sure if I used it right. <...
Abdu Muhammadal's user avatar
1 vote
1 answer
161 views

Combat game - character factory

I decided to improve my OOP design knowledge and learn python at the same time so I started to write a simple program which will be a fight "simulator". For now, there are only 2 character types : ...
Norbert Braun's user avatar
1 vote
1 answer
77 views

Abstract Factory Design Java

I am new to Design Pattern implementation and would like to strongly solidify my knowledge to become as good of a programmer as I can. Is this a proper implementation of the Abstract Factory design? ...
Hans Landa's user avatar
1 vote
1 answer
331 views

Deserializing a customly formatted string

The component receives a serialized message as a string and a serialized schema as a string. The ...
Sam's user avatar
  • 179
1 vote
1 answer
100 views

Abstract Factory Pattern in Java

I reproduced my version of Abstract Factory Pattern in Java. I know it's redundant but can I get critical comments about my code. Is it really the classic implementation of the pattern or not? ...
Rajat Saxena's user avatar
1 vote
1 answer
71 views

Python3 tokenizer abstract baseclass ( Without the permission to be instantiated directly )

I'm a newbie python developer, and fortunately I have been introduced to the principle of abstract base classes and they seemed pretty interesting to tackle while going forward in my Python journey. I'...
KhodeNima's user avatar
  • 399
1 vote
1 answer
97 views

Take meal orders from breakfast, lunch and dinner menus

I have an exercise requires me to write a service to management menu. The requirement like this: Food menu includes: breakfast menu, lunch menu, dinner menu. The three menu haves list menu item( name, ...
David Moore's user avatar
1 vote
1 answer
440 views

Helper functions for use with std::variant without an actual object

Sometimes, you want to an type of a particular index in an std::variant, and do something with that type without having an actual object. An example use-case would be de-serialization. What do you ...
user877329's user avatar
1 vote
0 answers
434 views

Caching wrapper with multi-providers and factory to detect the responsible cache provider related to Type

What I'm trying to do abstract the caching actual cache provider (memory || distributed || ...). enable a caching diversity. each cached item type has different ...
Shrembo's user avatar
  • 151
1 vote
1 answer
141 views

Factory pattern for image or shape marker [closed]

I'm making a photo marker application and need to make a factory pattern for marker. I think it is not very flexible and overall not good. Would you check my code and suggest what could be improved? ...
kangtaku's user avatar
0 votes
1 answer
954 views

The Abstract Factory design pattern as a Database Operations program

File - DatabaseOperations.h This file contain classes representing database operations for three different types of databases (relational, document based and graph based) like establishing connections,...
StewieGGriffin's user avatar
0 votes
1 answer
2k views

Mocking objects using abstract factory

For some time I am trying to make a mocking library for C# that mocks objects with just 1 line of code. I am using abstract factory pattern to know what is the object's type so that I can work with ...
Hasan Hasanov's user avatar
0 votes
1 answer
255 views

Best practice for factory pattern in c++?

I'm implementing a simple data reader to get image sequences from either a pre-recorded video file (In my case ROS bag file), or a camera device (In my case Intel Realsense). Basically I intend for ...
zhouch's user avatar
  • 3
0 votes
1 answer
815 views

Mock customer DAO using abstract factory pattern in React

I wanted to implement abstract factory method in typescript with react for sharepoint framework webpart. So I tried to translate ideas from this Java tutorial. I don't have method implementations ...
Luis Valencia's user avatar
0 votes
2 answers
762 views

Factory / Builder Design Pattern in Python

Situation: I have implemented a factory design pattern in Python as below. There are different screens which have different configurations. One can register the screen in the factory and get the ...
rkarft's user avatar
  • 3
-3 votes
1 answer
51 views

Some way to create factory pattern for spring application [closed]

I created this code ...
Mateusz Sobczak's user avatar