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
12 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,...
1
vote
1answer
38 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 ...
-1
votes
0answers
30 views

PHP class about acts for municipal property with many properties, getters and setters

Can someone tell me is this good practice or somekind of design pattern. I want to avoid big class with many properties, setters and getters, and other methods. Object properties match database table ...
5
votes
1answer
480 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
137 views

Implement IDisposable correctly using object composition principle

Is it possible to implement IDisposable pattern correctly while using object composition principle to promote code-reuse, reduce code duplication and hide verbose &...
7
votes
2answers
229 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 ...
1
vote
0answers
40 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
82 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 ...
5
votes
1answer
490 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
52 views

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

I have the following class ...
3
votes
2answers
75 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
17 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
39 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
67 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
62 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
103 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
75 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
67 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
183 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
43 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
81 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
59 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
68 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
31 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
93 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 ...
0
votes
2answers
80 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
41 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
55 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
68 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
83 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
67 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
53 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
47 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
74 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 ...
3
votes
2answers
72 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
69 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
124 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
123 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
197 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
55 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
165 views

Applying functions to decorated objects

I have an interface Animal with a class that implements it, Cat. ...
7
votes
1answer
147 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
41 views

Transform Data from JSON and CSV to another JSON format

I have 2 files wholesaler_a.csv ...
2
votes
0answers
69 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
81 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
90 views

1
2 3 4 5
28