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
6 votes
2 answers
79 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
  • 89
5 votes
3 answers
613 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
94 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
48 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
67 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
77 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
175 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
69 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
52 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
65 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
339 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
57 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
81 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
39 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
92 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
125 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
138 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
162 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
251 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
138 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
451 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
105 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
139 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
116 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
522 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
301 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
218 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
211 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
146 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
63 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
115 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
602 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
659 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
120 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
117 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
145 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
2 votes
1 answer
145 views

Saving entity containing complex jsonb column with validation and comparision

I've been a .NET Developer for almost 4 years. I'm stronly learning and trying using design patterns and following SOLID principles for 3 months right now (I know - a little late, but better late ...
KJanek's user avatar
  • 123
4 votes
1 answer
375 views

Abstract base class for binary serialization

Ensuring that some logic is always being run before the user's overriding methods. I'm writing a library and I have some abstract classes that can be binary serialized (and users can subclass them and ...
Saturn's user avatar
  • 409
2 votes
1 answer
70 views

Composite and proxy pattern for multiclassing

A Multiclass is a CharacterClass that decided to add new CharacterClass types to combine with the original CharacterClass. These new CharacterClass types are ...
prestokeys's user avatar
  • 1,371
1 vote
1 answer
106 views

Prototype design pattern

As a practice and self-development exercise I have decided to implement design patterns in C#. I am using polish cuisine as an example in my implementations. In this project I implemented Prototype ...
Artur's user avatar
  • 169
1 vote
1 answer
107 views

Singleton design pattern

as a practice and selfdevelopment exercise I have decided to implement design patterns in C#. I am using polish cuisine as an example in my implementations. In this project I implemented Singleton ...
Artur's user avatar
  • 169
3 votes
1 answer
92 views

Builder Pattern for factory creation of beings with different races

Races have many distinguishing physical characteristics. But apart from appearances, different races have other distinguishing characteristcs, all of I've decided to be built using the Builder ...
prestokeys's user avatar
  • 1,371
-1 votes
1 answer
56 views

Replacing private helper methods with global functions in Python? [closed]

In Python there is no real notion of private access. It's merely suggested by social convention with _ prepended in method names. ...
Michael Moreno's user avatar
4 votes
2 answers
433 views

Composite Pattern for putting on clothes

When putting on a piece of clothing, we need to check for any clothing that is already on the relevant body parts(s). The possible plural means that we should use the Composite Pattern for the body ...
prestokeys's user avatar
  • 1,371

1
2 3 4 5
29