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
0 votes
1 answer
26 views

Print a hollow Rhombus [closed]

I am beginner in java, here is my code to print a hollow rhombus: ...
Gagandeep Singh's user avatar
3 votes
1 answer
83 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
79 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
118 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
0 votes
0 answers
131 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
  • 486
1 vote
1 answer
103 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
-3 votes
1 answer
219 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
  • 45
1 vote
1 answer
89 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
178 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
84 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
127 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
  • 958
1 vote
1 answer
84 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
304 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
  • 53
2 votes
1 answer
163 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
3 votes
1 answer
163 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
50 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
173 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
123 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
59 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
95 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
711 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
101 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
346 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
603 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
99 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
96 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,351
1 vote
2 answers
141 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
130 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
  • 23
4 votes
1 answer
326 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
65 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,351
1 vote
1 answer
100 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
95 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
77 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,351
-1 votes
1 answer
51 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
430 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,351
1 vote
0 answers
40 views

Frontend to handle course planning and administration [closed]

I read up on and dived into the Repository pattern for a project I am working on. I have understood that the repository abstracts the actual access to any form of storage for my data model. What I was ...
lhiapgpeonk's user avatar
1 vote
1 answer
59 views

Chain of Responsibility pattern for updating coordinates of moving objects

PrimaryCoordinates are the coordinates in meters. SecondaryCoordinates are the coordinates in decimeters, with the origin ...
prestokeys's user avatar
  • 1,351
1 vote
0 answers
68 views

Check that inputs are valid dates

I have a method in a class that accepts either a datetime or string parameter. It is shown in the last code block (I didn't include the class). A little background is that I am defining a wrapper ...
Travis DePriest's user avatar
1 vote
1 answer
951 views

How to transform the CompletableFuture response

Context: I have a client app which consumes an API. I want to call this API is async way (using java.net.http.HttpClient) and once I receive this data then I want ...
Learner's user avatar
  • 11
2 votes
1 answer
84 views

Build a message string depending on the type of signature of an invoice

The following method was meant to build a message depending on the type of signature of an invoice. It contains some if-else statements and code duplication. The original method : ...
l0r3nz4cc10's user avatar
4 votes
2 answers
201 views

Automating the process of determining which boxes to load on each flight for freight company

I was given a test assignment for the interview of the company and below is the code that I shared with them. I developed it using .NET 6 (Core) Console application. Actual problem statement: Coding ...
user19031158's user avatar
4 votes
2 answers
142 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
3 votes
1 answer
68 views

I made a webpage that simulates sharks eating fish in the torrid world of Wa-tor

I've been self-studying HTML/CSS/JS. I read about Wa-tor. It's a population dynamics simulation which simulates fish and sharks breeding and predating. This seemed cool so I decided to implement it....
Jeff's user avatar
  • 33
0 votes
1 answer
129 views

Is this the correct way of implementing a builder pattern in C++?

Coming from a Javascript background, and just now getting into c++. Want to know if im doing the builder pattern correctly in C++, and also what could improve on ? PongObject.cpp ...
BARNOWL's user avatar
  • 251
1 vote
1 answer
299 views

Creating complex object step by step

Builder pattern separates object construction from its representation I have to generate username and password for the Account class. Since this operation is a bit ...
nop's user avatar
  • 719
0 votes
1 answer
45 views

Nodejs Module Pattern And Caching

The question is about nodejs module pattern code structure. My goal is to initialise the module at one time and export the module using module.export so that, it's ...
Sreejith sreeji's user avatar
1 vote
0 answers
34 views

How do you decide if a function should return data directly (via return statement) or indirectly (e.g. updating a class property) or both? [closed]

I have some functions which update records in some database tables. When I run each function I want to know the number of records affected by each. I'm wondering what the most elegant way of returning ...
WackGet's user avatar
  • 119
2 votes
2 answers
339 views

Generic observable type

I am writing an observer design pattern that is not too complex but I still feel there's a lot for me to learn about C++ be it little details (especially coming from C). A couple of observations: I ...
xyf's user avatar
  • 508

1
2 3 4 5
29