Skip to main content

Questions tagged [design-patterns]

For questions requesting extra attention to be paid to the usage of design patterns in the code.

Filter by
Sorted by
Tagged with
1 vote
1 answer
261 views

Rules-engine to be improved/simplified for Efficiency (performance), Extensibility and Maintenance?

This is a simple implementation of a rules engine. I am really hating the very long MATCH/CASE function. I am wondering what kind of Design Patterns could be used there to make this code more ...
user avatar
4 votes
1 answer
690 views

Using builder pattern and facade pattern in real project

The code below is used to upgrade the firmware of three different types of cameras. I am not good at design patterns. I wonder if it is suitable to use builder pattern and facade pattern here. Since ...
John's user avatar
  • 417
2 votes
1 answer
87 views

Semi-generic data loading utility class

The following implements a relatively generic and modular data loading utility. It loads images from a local storage given a lookup table. The data loader is parametrized via dependency injection to ...
lo tolmencre's user avatar
3 votes
2 answers
454 views

Extensible sorting algorithm collection

I have just learnt the strategy pattern. I'm using this pattern to implement this UML to better understand it. Here is the code snippet: ...
John's user avatar
  • 417
4 votes
2 answers
438 views

naive C++ stack template class

I just learned Adapter Pattern, and I have used STL for some time. I know that the std::stack is a adapter for sequence container (say, ...
John's user avatar
  • 417
4 votes
2 answers
186 views

A simple text editor

I just have learned the Command Pattern carefully. I try to use this pattern to implement a simple editor. Some code may need some improvements, say the instance of ...
John's user avatar
  • 417
7 votes
3 answers
1k views

Room light controller

I just have learnt the command pattern carefully. I try to achieve the goal below in the right way. But I am sure the code may need some improvements. Requirements: Use the command pattern to create a ...
John's user avatar
  • 417
4 votes
2 answers
395 views

Poker bets on Python

I'm writing poker for my bot in discord. So far I'm presenting an incomplete version of the project, which is only a betting system. The development took a lot of time, so I decided to ask for help. ...
Cat met's user avatar
  • 43
6 votes
2 answers
104 views

Observer pattern written in C++

I just carefully studied the observer pattern. And I wrote a demo snippet to better undertand it. I am not so sure that if it's the right way to define ...
John's user avatar
  • 417
5 votes
3 answers
640 views

Password checker using Decorator Pattern

I'm currently trying a Password checker for password in Decorator Pattern, which will point out what the current password missing to be a strong password (my example will check for 8 characters, at ...
DEF ABC's user avatar
  • 53
3 votes
2 answers
102 views

Data Base Management System in C++ mimicking SQL based DBMS's (not for parsing SQL syntax)

I'm building a DBMS similar to SQL based DBMS's (like mySQL for example) currently implemented creating a table and reading from a table. no user input yet implemented for testing I create std::string ...
Ellie's user avatar
  • 549
1 vote
0 answers
56 views

Rust minesweeper grid generator code design

I wrote this not really to create a minesweeper game, but to practice using some of the "rusty" (but not only) design patterns and improving my code structure. I would appreciate a review of ...
Imaginary's user avatar
-3 votes
1 answer
74 views

Best practice code for payment integration [closed]

I am new to coding, and I am doing my best to write efficient and robust code. I am also trying to incorporate design patterns into my code. Could you please take a look at my repository and let me ...
Thomas Charles's user avatar
1 vote
1 answer
89 views

My C++ implementation of the Factory Pattern

Please review my implementation of the factory pattern; it gives a trivial example. Feel free to point out anything I've missed or any code styling tips. ...
Archie Payne's user avatar
3 votes
1 answer
211 views

A library management system

Following is my code for a library management system. I am pretty new to OOD and trying to learn it. I am specially looking for ways where any design patterns can be useful here. I tried to make ...
Pankaj Kumar's user avatar
4 votes
1 answer
73 views

My C++ Implementation of the Observer Pattern

I have written my own basic implementation of the Observer pattern. Please code review it as you feel. This is a one file implementation, and any feedback no matter how small is appreciated. One ...
Archie Payne's user avatar
1 vote
1 answer
56 views

Handling HTTP requests in existing Web Api

I am working in a Web Api project that has the following project structure: Root Controllers Orchestrators Managers Services etc The ...
Yiannr's user avatar
  • 119
4 votes
1 answer
66 views

Terminal Graphical Visualizer, using a queue of different matrices

I built a project in which I provide a string input or a whole matrix to configure a frame, create a bunch of different frames and push them into a queue and finally print them in order of the queue. ...
Ellie's user avatar
  • 549
2 votes
1 answer
341 views

Chain of Responsibility pattern for dealing with multiple changes

In Dungeons and Dragons, when one puts on multiple magical items, all of its effects will take place. These effects are to be cumulative, so if Girdle of Strength adds 2 to one's strength, and a ...
prestokeys's user avatar
  • 1,371
2 votes
0 answers
58 views

Implement Iterable where hasNext depends on mutable object state, which is mutated through explicit call

I am trying to implement the Iterable interface on an object, where the hasNext method on iterator will depend on mutable object state. This state is mutated by ...
Abhijeet srivastava's user avatar
3 votes
1 answer
85 views

Random generation of points for the graphs of 3 stock share parameters

I currently studying OOP and related design patterns, and tried to implement random data generation for some stock charts using OOP as an exercise. This code randomly generates data points for 3 ...
Jin22's user avatar
  • 33
0 votes
1 answer
41 views

Object build while sequential read user input [closed]

The implementation reads sequentially the user's input changing the type to build according to user choices. There are two main components a conditional structural sharing (...
user avatar
3 votes
1 answer
93 views

Sequentially find the indexes of an element into a collection

Util class to find into a collection the indexes of a given element with multiple occurrences from the first index or relative to a given index. ...
user avatar
1 vote
2 answers
87 views

Verification job with multiple type of batch verifiers

I have a use case where a verification batch job (non-generic) verifies domains based on its input e.g domain_type, batch_pointer etc. The verification handles it based on the domain type which uses ...
user3239193's user avatar
1 vote
1 answer
126 views

Business logic verification template

I have a use case of template design pattern with generics as mentioned below. I have AbstractVerificationHandler that provides template for verification business ...
user3239193's user avatar
1 vote
0 answers
140 views

Chain of Responsibility in the game of Hangman

I tried to do the Hangman Refactoring Kata for the piece of code over here - https://www.youtube.com/watch?v=-0MeoFTj6DU This is how the initial code looks like after first set of refactorings (i.e. ...
yadav_vi's user avatar
  • 496
1 vote
1 answer
177 views

CPU emulator written in python (Adjustable Microcode!)

I've designed and implemented a CPU architecture in one day. Of key architectural details: Processor is supposed to support updatable microcode, Architecture extensions and Is designed to be ...
ToAskOrNotToAsk's user avatar
-2 votes
1 answer
262 views

Design a set to classes to report battery/power status of different Alexa devices

I was asked below quesion in Amazon sde2 low level design interview recently and I have shown below my solution during the interview. I was rejected in this round. ...
sachin's user avatar
  • 55
2 votes
1 answer
145 views

Implement saga pattern with Kafka

There are very few example on how to implement saga pattern with Kafka so I tried to come up with my own implementation choreography saga pattern using Kafka. I need to implement outbox pattern as ...
Kazul Haram 's user avatar
1 vote
1 answer
558 views

Mouse and keyboard event system

I wrote a mouse and keyboard event system in C++, using the GLFW library to get mouse and keyboard states. I've been working on a 3D game engine of my own for a long time (about 9 months) and wanted ...
Tristen Woodruff's user avatar
1 vote
1 answer
127 views

A Model View Controller Pattern implementation. Do I get it right?

I know there has been many questions on the Model-View-Controller pattern, but this question is a follow up on a previous question I asked regarding the implementation of a download manager: Get files ...
M. Saintourens's user avatar
5 votes
2 answers
147 views

Get files downloaded asynchronously after double clicking on list item (C++)

The problem I am trying to solve as an exercise is as follows: I have a UI running in the main thread, specifically a list view with many items. Each item represents a file that the user can download....
M. Saintourens's user avatar
4 votes
3 answers
1k views

Python Enum Strategy Pattern

I have two behaviours: pulling or cloning a git repository. It started as an Enum, but then I had to switch over the enum all the time. I wanted to turn it into some kind of strategy pattern and ...
lukstru's user avatar
  • 968
1 vote
1 answer
125 views

Improved Component-Entity-System Using C++

Introduction I am a newbie, so please take me easy :). I am writing a low-level game engine using C++, GLFW and also OpenGL. This is a continuation of Entity Component System Using C++ I've ...
Andrei Rost's user avatar
2 votes
1 answer
563 views

Model-View-Presenter (MVP) pattern implementation

To learn more about design patterns, particularly the Model-View-Presenter (MVP) pattern, I am currently creating a CLI weight tracker application in Python. I would like you to review the code to ...
J. Lo's user avatar
  • 43
2 votes
1 answer
346 views

Entity Component System Using C++

Introduction I'm a new to C++ so please take me easy :) I am currently working on a low-level game engine using C++, OpenGL, and GLFW; I've implemented the Event System and the Input Manager, which ...
Andrei Rost's user avatar
4 votes
1 answer
235 views

Improved Event System & InputManager Using C++

I am new to C++, so please take me easy. I want to make a low-level game engine only using C++, OpenGL and GLFW. This is a continuation of Event System using C++ ; I added the suggestions from there. ...
Andrei Rost's user avatar
1 vote
0 answers
52 views

Event System in C++ [duplicate]

I am excited to share that I have developed an event system in C++. I have always been passionate about programming and have long aspired to create a low-level game engine solely using C++, OpenGL, ...
Andrei Rost's user avatar
3 votes
2 answers
2k views

Event System using C++

I am excited to share that I have developed an event system in C++. I have always been passionate about programming and have long aspired to create a low-level game engine solely using C++, OpenGL, ...
Andrei Rost's user avatar
8 votes
1 answer
224 views

Lightweight general-purpose graph library in C++

As a personal side project I started building a graph library in C++ (I know, very original). The code is open source, but for the purpose of this question I will provide the relevant details and the ...
Bobray's user avatar
  • 81
3 votes
1 answer
154 views

Implementing The Decorator Design Pattern in C++

I recently tried to implement the decorator design pattern in C++. Here is the code in full: ...
Sc2046's user avatar
  • 33
1 vote
1 answer
65 views

Class handling file conversion and data manipulation archiving [h5py]

I am a physics PhD student who co-developped a python package for file conversion of standard file format used in Scanning Probe Microscopy (SPM) and archiving of data manipulation for tracability. If ...
CoilM's user avatar
  • 13
0 votes
1 answer
106 views

Strategy Pattern Inside State Pattern

I'm making a fps game where I created a hierarchical state machine; the problem is the two types of movement (standing movement and crouching movement). They are very similar; the only difference is ...
Thomas's user avatar
  • 25
1 vote
0 answers
1k views

MVVM using Python's tkinter

My task is to change the architecture of a previously written application to Model-View-ViewModel and use the Command pattern. It is written in Python 3.10.6 and uses the tkinter library for the GUI. ...
broland's user avatar
  • 11
2 votes
2 answers
117 views

Python Logger Implementation

I have developed an implementation of a logger in Python. I know that Python already has a built-in logger, my goal with this is to get feedback and suggestions for improvement, particularly about ...
nabla-f's user avatar
  • 163
4 votes
1 answer
703 views

Unit of Work & Repository Pattern - Injecting UoW into Repository Base

Description I am implementing the Unit of Work & Repository Pattern with Dapper as my ORM and PostgreSQL as the relational database. I have seen examples of UoW where: The UoW class creates an ...
zwoolli's user avatar
  • 41
4 votes
1 answer
670 views

Modern state machine

Based on previous examples and code submitted, I wrote this simple state machine, let me know if you have other suggests on optimizations potentially algorithmic. ...
user avatar
2 votes
1 answer
123 views

Modern chain of responsibility design pattern

Based on this question, I tried to simplify the use case with simpler model, Let me know if you have other suggests on optimizations potentially algorithmic. ...
user avatar
2 votes
3 answers
120 views

Chain of Responsibility Pattern using std::any

The following code has a Handler class that follows the classic Chain of Responsibility pattern. But we don't want to write a new handler class for every new type ...
prestokeys's user avatar
  • 1,371
1 vote
2 answers
146 views

Replace personal names and addresses with company ones

The problem: I am given a data frame. Somewhere in that dataframe there is 3*N number of columns that I need to modify based on a condition. The columns of interest look like this: names_1 address_1 ...
Glue's user avatar
  • 129

1
2 3 4 5
29