Questions tagged [design-patterns]

A design pattern is a general reusable solution to a commonly occurring problem in software design.

Filter by
Sorted by
Tagged with
0
votes
0answers
31 views

Object Oriented Routing using Python's FastAPI

I created a BaseRoute class route handling. The BaseRoute class takes the following parameters: ...
4
votes
1answer
94 views

Design a pattern using python

I want to print the below pattern * * * * * * * * * * * * * * * My logic written ...
-2
votes
1answer
66 views

Refactoring existing code with some design pattern [closed]

I have the following code, like a git command line system with various supported parameters and commands. But as can be seen, it involves a lot of if-else conditions which It doesn't seem that clean ...
2
votes
1answer
95 views

Using fluent builder pattern for generating pdf

I'm testing to use a fluent builder pattern for generating a pdf file using AbcPDF. I've looked at several methods of accomplishing this and I'd be very glad to get some input on what I've written so ...
2
votes
0answers
34 views

Undo/Redo implementation using Memento pattern Javascript

Relatively new to the Design patterns, Generally my works are writing function for the needs. But now i need to implement a undo redo functionality, so i just read about the different patterns which i ...
1
vote
0answers
38 views

Alert system for game or simulator

I am creating an alert system for a game/sim in C# that keeps track of negative actions performed by the user during a training exercise. There are preconfigured alerts that have data, such as UI text ...
1
vote
0answers
24 views

Android Kotlin: Main Concept: Nested RecyclerView Handling Clicks; Secondary Concept: Appropriate use of OOP concepts

Brief Background: I just started learning Android Development recently. I have some experience with programming and understand the basics of OOP but am not confident that I am using principles of OOP ...
2
votes
1answer
39 views

A proxy class as a generic replacement for getters and setters v2

Have you ever written proxy objects, instead of using a setter and a getter method? In that case, I'm interested in your opinion on the following design for a templated proxy. This is a second version,...
3
votes
0answers
53 views

Sudoku sequence solver for non-standard constraints

This script is designed to help solve sequences in Sudoku puzzles with variant constraints (ex: Thermometer, Renban, etc.). Summary The user specifies the constraints they want applied as well as the ...
0
votes
0answers
25 views

Java database connection and DAO implementation feedback

First things first, I made a DatabaseConnection-class which connects to the database like so: ...
2
votes
0answers
73 views

Arcade Stacker Game - Core Logic

This is my first post here, so I apologize if anything is incorrect. I have created an endless arcade stacker game (like the stacker games at the arcade, but when you hit the top the grid resets and ...
0
votes
0answers
12 views

PHP Class(es) for setting up DB adaptor

Not sure if I have gone over board with this or if I have even approached it correctly. Basic I wanted to created classes which fulfilled the following: Single class that can be used to create a ...
0
votes
3answers
71 views

What is the elegant way to merge collection of entities with a duplicate field?

I have the following entity, I am getting it in response of REST API. class Account { private String ownerId; private List<String> coOwners; } REST ...
1
vote
1answer
86 views

Generic decorator inspired by functional programming

I made a generic decorator in C++20 with concept for specialization. The idea is to be able to define only one function in the decorator to decorate all functions in a class. You may try it (it's a ...
0
votes
1answer
32 views

Refactor typescript long switch case that run different code in according to property value

I have a typescript function that executes an array of actions on a given string value. This is the code: ...
0
votes
0answers
45 views

Two sets of scripts for a Katamari Damacy-style game

I would like some feedback on trying to implement SOLID principles to my Katamari Damacy-style game, I have provided below the 'original' script which accomplished a variety of tasks, and then the '...
0
votes
1answer
20 views

Function pattern for running DB queries using pool or transaction

Take the following INSERT query. Using knex (JS) just for abstractions ...
0
votes
0answers
62 views

React Typescript Project Using Traditional OOP Patterns

I'm writing an app meant to have similar functionality to LucidChart - drawing shapes/diagrams. I'm using React with Typescript (Create React App) and am trying to follow OOP/polymorphic patterns I've ...
1
vote
0answers
73 views

VBA OOP design patterns: factory, constructor, returned interface

While working on my demo database manager app, I have coded a previously presented Storage Library. The structure of the library's code and employed design patterns partially follow that of the Secure ...
1
vote
2answers
94 views

Java dependency injection and hiding details of methods in "Database"-class

I recently posted a bunch of code of my to-do list application and after getting some very helpful and good suggestions on how to improve, I took a shot at it! Here's a link to the former post I made -...
6
votes
2answers
98 views

Conway's game of life as Java OO with underlaying array

Well, there are many game of life's already, but after posting an answer on it in C#, I thought I might as well check if I did any better and if there is anything new to learn - there always is. ...
3
votes
0answers
19 views

Othello game in Tk

I've recently reached a milestone for my Othello clone. This is my first python project and the farthest I've come to a full program beyond small scripts and little automations. I'd love for those ...
0
votes
0answers
43 views

GUIComparer with MVVM dialog to allow user input in ArrayList sorting algorithm

download Bit of an esoteric title, but let me explain. I wanted to create an IComparer that can be supplied to a sorting algorithm, which rather than using the ...
0
votes
1answer
75 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,...
2
votes
3answers
102 views

Factory Method Design Pattern Implementation as a Coffee maker program

File: InfoFactory.h contains four classes. CaffienatedBeverage is an Abstract class with one pure virtual function Name. It ...
5
votes
1answer
513 views

Designing an URL Shortener

Recently I was assigned a URL shortener design problem while interviewing with a well known organization. Here is the exact problem statement: Build a simple URL shortener service that will accept a ...
3
votes
2answers
198 views

Implement IDisposable correctly using object composition principle

Update at the end Is it possible to implement IDisposable pattern correctly while using object composition principle to promote code-reuse, reduce code duplication ...
7
votes
2answers
259 views

Constructing a DSL with properties instead of functions, for use in a type-safe pseudo-builder

As one step in a larger builder setup, I need to build a small collection of objects, each with a small number of required attributes, and each of those with a small set of possible values. The actual ...
2
votes
0answers
47 views

Embedded services using chain of responsibility?

I currently have a few "worker services" that wrap existing code to automate incredibly repetitive code. A few examples are: Method analytics. Iteration support. Exception logging. My ...
4
votes
0answers
84 views

License-holder editing application

I am building a WPF (Windows Presentation Foundation) application. And I'm trying to use the MVVM (Model–View–ViewModel) design pattern. It's fascinating and rewarding, even though it seems overly ...
6
votes
1answer
498 views

Using a generic call to access different variations of a method

In the code below, the primary purpose of class MyRNG is to create a single method getMyRandom() that will return a random ...
-1
votes
1answer
60 views

Proper way to Implement a Birthday Class in Object Oriented Python [closed]

I have the following class ...
3
votes
2answers
107 views

CLI-Client for interacting with daemon

I have a daemon which I am able to interact with through a cli-client. The daemon will perform some tasks in future e.g. monitoring the rate at which files are added to a directory. Right now when I ...
0
votes
0answers
18 views

Create Many Subtypes which are all exactly the same VS use just one type

Is it good practice to create many subtypes which are all exactly the same just for more descriptive class names? I did this but then I realised all my subtypes were redundant, and it seemed kind of ...
1
vote
0answers
41 views

Replace SingletonPattern by using IOC Container based architecture

I have a legacy winForms application that now I'm in charge of maintaining and developing. This app has a lot of singleton instance.... Some are very similar to service that wrap other component or ...
6
votes
0answers
74 views

Efficiently generate distinct subsets which sum to a particular value

Related: Find all distinct subsets that sum to a given number This code is supposed to efficiently generate all subsets of a list such that the subset's values sum to a particular target value. For ...
1
vote
0answers
67 views

Filtering what strategy to use in strategy pattern [closed]

I have a situation where I've used the strategy pattern but got many different strategies that are available to the client code that needs to select the appropriate strategy, this is because there's a ...
2
votes
2answers
107 views

Parking places design

I got a question: Design a parking system. There are 3 types of parking spaces: big, medium and small. Implement ParkingSystem class(int big, int medium, int small)....
1
vote
1answer
76 views

Minimal list definition in Rust

As a purely pedagogical exercise, I've been trying to use Rust's (very expressive) type system to define the bare minimum one might expect from an ordinary list type. While there's likely a higher-...
2
votes
1answer
67 views

Scrape multiple twitch IRC chats

I've always struggled to create and sustainable, organizated, clean code. I tried to use a Factory method and it's working better now that I created another class. I know I should write documentation,...
2
votes
1answer
72 views

Asp.Net overall design pattern integrating REST, dependency injection, and Hosted Services (See full project at Github)

I'm new to C#, and want to conform as much as possible to good design patterns. This code is the beginning of a Microservice, running as Asp.Net. It is based on a Microsoft tutorial doing similar work....
6
votes
2answers
286 views

Usage of Factory pattern for maintaing bookshelf having books, magazine and notes

I have tried to achieve the following task using Factory Pattern with php-7.0. Define the classes and their methods (including parameters and return types) for a system that consist of a bookshelf, ...
0
votes
0answers
70 views

Python - Pagination class

I built a small flask app and a lot of routes do need some kind of pagination system. However, in some cases I would like to just display n-2, n-1, n, n+1, n+2 ...
2
votes
1answer
102 views

Stack Exchange Marathon Bot – Part 1: Bot structure

This code review is for my Stack Exchange Marathon Bot project, a Telegram bot for playing a dumb little game involving the Stack Exchange network. Since the codebase is not that small, in this post I ...
1
vote
1answer
62 views

How can I refactor for handling multiple proto generated service clients by eliminating double await and the DRY code?

I'm having doubts about which is the best strategy to manage the many service clients in this web app. "Best" in terms of a good compromise between user's device RAM and Javascript execution ...
2
votes
2answers
73 views

Web scraping and design pattern lifting

I would like to get some feed back on my code; the goal is to get all agencies address of banks. I wrote a pretty simple brute force algorithm. I was wondering if you would have any advice to improve ...
0
votes
0answers
32 views

Implementation in Azure Blob Function Trigger for Insert into Database

I have created Azure Blob Trigger function. If file is inserted in Azure Blob Container at that time this function is trigger and based on that file data we need to insert into our database table. My ...
2
votes
1answer
98 views

Python: separation of concern User Model and User DB

I am working on a small side-project since a couple of weeks, I am using Flask but trying to use as few libraries as possible and no ORMs (for learning purposes. I am currently working on the User ...
5
votes
1answer
145 views

Anemic class that binds functionality

I have cleanly separated functionality of a message bus - namely the diagnostics (optional), sending, decoding and the bus driver, I need to now bind this together and have done so with a ...

1
2 3 4 5
28