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
2
votes
1answer
58 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 ...
0
votes
0answers
21 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
54 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
28 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
83 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
134 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 ...
0
votes
2answers
61 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 ...
0
votes
0answers
17 views

Flask blueprints and context_processor - Best approch?

I am working on a Flask application (side-project) to send text-messages to customers using Twilio. There is two different list of customers, 1 for testing and for ...
4
votes
1answer
50 views

Improving Mancala Game

https://www.mastersofgames.com/rules/mancala-rules.htm I am trying to create a working Mancala Game in scala, Currently, I have 3 classes, Board, ...
2
votes
0answers
53 views

Design a parking lot [closed]

I have tried to design the parking lot problem. Here is the problem statement. Design a parking lot with multiple floors where customers can park their cars. Each parking floor will have many parking ...
4
votes
2answers
79 views

Housekeeping script improvements

I have built a housekeeping script and I would like to improve it. I have a JSON file with the details such as directory path, number of days after which the directory or file should be zipped, ...
3
votes
2answers
52 views

Python Back-end registration validation

I'm working on a personal project (Flask CRUD app) and I am currently building the user service. I am trying to use as less as libraries as possible (that's why I do not use WTF-forms for example, ...
2
votes
1answer
33 views

Python (Flask) - User registration system

I am working on a simple CRUD app as a personal project using Flask. I am currently working on the user service and I just finished the registration process. I am also trying to use as less as ...
0
votes
0answers
8 views

DI container class

I have created this DI container class lib to be used to in any other external project as a learning exercise. Please review, and suggest any improvements or comments you have. ...
2
votes
0answers
39 views

Cron expression parser

Problem Write a command line application or script which parses a cron string and expands each field to show the times at which it will run. ~$ your-program "*/15 0 1,15 * 1-5 /usr/bin/find"...
2
votes
1answer
67 views

Python - Inheritance: sharing objects across instances

Use case - motivation & challenge Hi all! I have been working with Python for the last two years, but never learned proper object-oriented programming and design patterns. I've decided for this ...
2
votes
1answer
44 views

Replace words from a file with words from a dictionary based file

I'm working on a coding challenge that tasks me with taking a file with a dictionary, reading from it, and then replacing the matching words from the input file with what is found in the dictionary. I ...
0
votes
1answer
65 views

Calculate tax return [closed]

Please consider this code for a TaxReturnCalculator (and ignore both the suboptimal use of float instead of ...
2
votes
3answers
107 views

LRU Cache Implementation in C++

I am learning C++ by implementing small design problems. I have tried to implement LRU cache and the implementation that I have attached here works fine. However, I am not sure whether my code is in ...
2
votes
1answer
87 views

writing a generic object pool in C++

For a hobby project, My aim is to design and implement a generic system for pooling an arbitrary class of object. I tried implementing it using templates. This pool should support 4 actions: "...
3
votes
1answer
77 views

Board game design in C++

I'm trying to build a board game and solve it using algorithms such as Monte Carlo Tree Search in C++. My current design follows this python project, in which I have a class hierarchy for ...
2
votes
1answer
54 views

This code loops through a GlobalEmployeesList, eliminates duplicate email and phone records for the selected employee, and populates listboxes

I have a DataGridView which displays an employee list. I use the employee ID to filter my global employee list and display information about the selected employee in various listboxes. This is my ...
4
votes
1answer
163 views

Applying functions to decorated objects

I have an interface Animal with a class that implements it, Cat. ...
7
votes
1answer
125 views

Java service to convert xls files to HTML

I have a service that converts an Excel spreadsheet file into HTML. It is working just fine, but it is quite a big method that doesn't follow any SOLID principles. Therefore I would like to improve it ...
1
vote
1answer
36 views

Transform Data from JSON and CSV to another JSON format

I have 2 files wholesaler_a.csv ...
2
votes
0answers
64 views

Visitor pattern, Extensible visitor for custom implementation

I'm writing my own expression tree system, just for fun, but I have a few doubts about my code. My goal here is to create an abstract layer of expressions, and allow different "languages" to ...
2
votes
1answer
75 views

Builiding a Model from Stored Procedures

After reading that Data Classes can be considered a code smell, I am shifting from a pattern with many data classes and a single manager class that handles all the instantiation of the classes, to a ...
0
votes
1answer
77 views
0
votes
1answer
51 views

django multiple if else refactor

I have a function with multiple if else statements that I'm trying to simplify in Django Is there a pattern or maybe a better modeling approach that I could use here? The idea behind is to have a ...
2
votes
4answers
104 views

statistics classes with number and object inputs

I want to create two classes that accept values and perform operations on them. However, one of them is accepting numerical values - RollingStatisticsNumbers; and the other objects - ...
1
vote
0answers
40 views

How do I create an “Environment Variable Setter”?

I have a NodeJS/Typescript project. In server.js, I want to set my environment variables from a .env file. To achieve this, I am ...
5
votes
1answer
103 views

Generic Visitor pattern library for polymorphic virtual class hierarchies

Inspired by this cppcon talk from Fedor Pikus about design patterns and some real-world need I implemented a library that allows the user to add a generic visitor pattern capabilities to class ...
3
votes
2answers
78 views

A Python decorator for an “observable property”, that notifies observers when the data is changed

I have classes that have some data, and whenever this data changes, it should notify observers of that data change. There also should be a method to add new observers. My first approach was to use a ...
2
votes
0answers
30 views

Python - preprocessing dataframes data in a class

Context I am building an algorithm that automatically assigns a planning to drivers. However there is a lot of pre-processing and reused outputs. I try to structure it in a maintainable way. Questions ...
0
votes
2answers
40 views

on using the strategy pattern to switch between database layers

I'd like to build an app in Flask that can switch between talking to a PostGresql and a Mongo DB. As I understand it, the Strategy Pattern is about being able to switch algorithms that are referred ...
0
votes
1answer
30 views

Avoiding verbose compositional class design

I've written some code which features Eric Elliot's javascript factory function mixin composition (https://medium.com/javascript-scene/javascript-factory-functions-with-es6-4d224591a8b1), but since ...
3
votes
1answer
51 views

Design pattern for creating similar but different classes

I have a main-class that takes a list of sources and returns two objects for each source; one with the required data and one analytics tool. The Analytics-class has ...
3
votes
1answer
65 views

Revised console-based quiz application

This question is a follow up to my previous question, link to the post can be found here. I really appreciate the reviewers especially @Edward's review. They highlighted great points which were ...
6
votes
4answers
346 views

Console-Based Quiz Application

I wanted to practice more object-oriented programming and decided to write a console based Quiz Application. In one of my previous question, a reviewer left some links on SOLID design pattern, I went ...
1
vote
0answers
27 views

How to put my functions outside a class to get organized, Design pattern [closed]

I'm using Symfony 4, I have a class named Fiche, it contains the attributes and by default the getters and setters functions of course. Inside this Class, I have created over than 107 others functions ...
6
votes
1answer
59 views

MessageHandler handles different message subtypes differently (can visitor pattern be applied?)

Introduction I'm working with Java 1.8. There is a lot of repetition in the MessageHandler class that I would like to remove but I'm having trouble implementing a ...
10
votes
1answer
252 views

Snake Game Object Oriented Approach

I just completed a snake game using object-oriented programming. The focus is on the class implementation. OVERVIEW Snake game works by moving the snake in order to eat fruits whilst escaping ...
2
votes
0answers
66 views

Is this a good pattern design for a Unity dispatcher for creating thread safe methods?

Well, my intention here is to allow users to execute Unity methods/properties in other threads by using this Dispatcher implementation: ...
4
votes
1answer
116 views

How to refactor Symfony 5 controller to comply with SOLID design principles

I am trying to create this API endpoint that will accept JSON payload and will calculate quote based on provided factors and their ratings. I have Entities that contain information about: ...
5
votes
2answers
100 views

Object Oriented Library Management System

Library management system is a object oriented program that takes care of the basic housekeeping of a library. This is the third part of a series. The first iteration of the project is found here and ...
0
votes
1answer
74 views

Learning factory design pattern [closed]

I'm making the very common example of Factory design pattern which creates a factory of cars and return an instance of a car. I found a example here https://refactoring.guru/design-patterns/factory-...
4
votes
2answers
333 views

web scraper for emails and links

I created a class to scrape URLS, parse and validate emails and get internal links. How can I achieve the SOLID principles in this class written in Javascript to make a web scraper? ...
3
votes
1answer
69 views

refactor python strategy pattern to use abstract base class

I came across this strategy pattern implementation https://github.com/jtortorelli/head-first-design-patterns-python/blob/master/src/python/chapter_1/adventure_game.py ...
4
votes
1answer
121 views

Modular Design Patterns in C

I have created a modular design pattern which provide a single interface that can be used create instances with swapable back-end components, however I'm not entirely satisfied with it. My practical ...
1
vote
1answer
56 views

Soduku Generator and Solver

This is my approach on creating a sudoku generator and solver with backtracking. Is right for sudoku generator to inherit from soduku solver? What is your general overview on the class structure, data ...

1
2 3 4 5
27