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
1
vote
0answers
42 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: ...
-6
votes
0answers
42 views

Call center modelling [closed]

I have a requirement to deign a call center. Details: -using OOP design a tech center apps -the user may choose options from a menu(language,problem type(hw/sw)) -the user can choose one of the ...
-3
votes
0answers
47 views

Java: class inheritance and generic types [closed]

I'm currently working on inheritance in Java. I would like to discuss the following case with you. In my example, I have numerous animal and enclosure classes. All animals are derived from BaseAnimal. ...
4
votes
1answer
79 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
80 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
64 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
309 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
50 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
93 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
45 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 ...
3
votes
1answer
65 views

Implement Factory pattern with multiple parameters and each parameters are interface

I am a little bit confused on Factory Method with multiple parameters in which all parameters can change from GUI by user as seen below picture. For each combobox item I have an interface and ...
2
votes
0answers
13 views

Pre setup script to get user metadata and check supported api's within the browser/device

Can this code be shortened or optimized, Written out this script to be used before node.js starts a few canvas elements and some vide streams. wondering if the initial checks can be shortend or ...
0
votes
0answers
9 views

Tree design in db with same child twice and value store

I have a non-cyclic tree like the below sample representation. It has nodes and edges connecting them. The tree has the possibility of the same node connected multiple times to one parent. Like in the ...
1
vote
0answers
36 views

Instantiation logic within a specific object vs factory object

I want to program file lines transformation in a game initialization context and I am asking about best OOP practice. I have a MockConfigFile that implements a <...
25
votes
1answer
2k views

A Pong Game using C++

I wrote a simple, 2-player Pong game for a Udacity Nanodegree in C++. The program has the following class structure (relatively new to UML so any tips on here would be very much welcome too): ...
2
votes
2answers
95 views

Reactor pattern in modern C++. Please comment on coding improvements to be done

The reactor possesses its own thread to wait for messages in an event loop. Users should be able to start or stop the reactor at any point. These two operations are not required to be thread-safe. ...
6
votes
1answer
126 views

Testing lower- and upper bound values in Python

Code functionality The following code tests whether the values that a user specifies for a lower bound and upper bound on two properties: The lower bound is smaller than the upper bound. The values ...
4
votes
3answers
161 views

Many DB queries and conditions [closed]

I don't know it is some design pattern for it or I can't do it in a different way the code looks like this: ...
2
votes
1answer
66 views

Defining a finite set of instances of a class to check against [closed]

I have a Type class that will have many instances. I get the instances from a web service. The Type class has a ...
2
votes
2answers
88 views

Loan application service based on user credit score

The following microservice is just handling loan application and response the result of the application is accepted or rejected. It is part of my assignment for an interview. The project description ...
8
votes
1answer
220 views

Making argument parsing more streamlined and readable than if-statements

I am working on an API wrapper for calls to a website. Each of several types of calls can take a large number of optional arguments, some of which contradict. In the interest of preventing the user ...
1
vote
1answer
61 views

Prototype Design Pattern C++

I have just started reading the GO4 book to learn the OOD concepts. In order to practice the Prototype pattern, I implemented a small example (the idea for colored shapes was taken from "...
2
votes
1answer
57 views

Implement Strategy pattern for 1. Print Report. 2. Movie type [closed]

I need to know whether I have implemented Strategy pattern correctly for below 3 classes provided to me for 2 tasks.1) Report Generation 2) Movie Type. Below 3 classes were provided to me Rental.java ...
2
votes
1answer
46 views

Typescript design pattern for rendering different objects with similarities

It's a web project. The code is working. The question is a design pattern question to write code that's more elegant, you know. I've created a Codepen of this question. I created a ...
0
votes
0answers
23 views

Discord bot file requirement and object instantiation d20pfsrd follow-up

I have written a series of parsers for a discord bot that each reside in classes in their own files. Each parser class has 3 functions, 2 of them are for generating the response to the discord message ...
4
votes
1answer
204 views

Representation of data record for an employee (generic method vs design pattern)

preface: I have a part of my code that is repeated more than once and I want to create a generic method or follow a design pattern to make the code cleaner. What I'm trying to achieve is: I have a ...
3
votes
2answers
135 views

C# One type to represent multiple types (including generics)

Our monolithic WinForm application is getting a face lift. One current challenge that we are restructuring how we setup events. I rolled my own event manager class to handle the subscriptions and ...
2
votes
0answers
41 views

Structuring Service and DAO Layers in Go

I am having a bit of difficulty in designing my Go code. I'll try to demonstrate things with a very simple example of adding a new user to the database. My Handler is only doing one thing: Calling a ...
5
votes
1answer
47 views

Instantiate multiple classes in another class, invoke method from multiple classes

The goal here is to pull all alerts from a single iterable: obj = Alerts(db, args) for alert in obj.alerts() pass Now, I need to add a few more sources and I'm ...
3
votes
0answers
69 views

Providing a connection pool

I need some opinions about method naming and single responsibility principle. First of all, let's talk about method naming. The class below was created to provide a connection pool and whenever a pool ...
1
vote
0answers
57 views

Self Running iterable state machine with Enums in Java

During development I needed to design a state machine with decision which runs to completion and performs state transition without the need to wait for events. So i come up with the following ...
4
votes
0answers
52 views

JS Stopwatch - Is this a good way to implement the observer pattern?

I'm learning oop and also trying to learn and implement some design patterns. This question is a follow up of Stopwatch interface OOP (Vanilla JS) The app is available in https://nacho-p5.github.io/ ...
10
votes
2answers
109 views

Using Method Chaining To Alter Last Item Added To Collection

There is a Name class with properties that represent different components that make up a person's name. A Name object requires a FirstName and ...
2
votes
0answers
24 views

A task to store user's favorited projects in postgres using python

I am not happy with two functions calling get_user() since while testing I mock get_user and to test with get_user_returns_null case, it returns Null for both ...
2
votes
0answers
65 views

Swift Struct-based Factory Pattern

Edit: I added another configuration vector to CardView, a size attribute, which may be .small or ...
2
votes
1answer
33 views

I have a input grid with more than 40 input-fields hardcoded

I am new to flutter and i managed to build a working Grid which does what i want it to do but the code is a duplicated hell and i didn't manage to create it dynamically while still keeping track of ...
3
votes
0answers
42 views

Game Event Messenger based on the Observer pattern

I am making a game event messenger based on the observer pattern and I'd really appreciate some feedback on this please. The intent behind it is that I am sending in a function pointer so that it can ...
3
votes
1answer
96 views

Python REST API and Mongo - Aggregation Pipeline/Stage classes

This has been my approach for "simplifying" MongoDB aggregation queries in a pythonic syntax - was my intent, at the very least: ...
6
votes
2answers
201 views

A proxy replacement for getters and setters

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: ...
3
votes
0answers
58 views

File parser for csv and xls files

I made program for parsing CSV and XLS files, I just want to know if there is some space to improvement and is it all written good? My goal is when I got CSV or XLS file to parse that file and got ...
1
vote
1answer
54 views

Best practice for URL's architectural Design in Django [closed]

I have been designing websites with Django for a while and I have also designed various sites. But here is a question that comes to mind at the beginning of any new project: What is the best URLs ...
5
votes
2answers
102 views

Pin and Password Generator JAVA

I am reaching my one year on programming and decided to create a simple pin and password program to better help me understand arrays. As far as coding standards, best practices, and functionality what ...
6
votes
1answer
146 views

Return payload in service layer

In my project I am using the ADR architecture, a branch of MVC. In my actions (Controllers) I handle only data that comes from the request. When there is a business rule that defines which status code ...
10
votes
2answers
372 views

C++, sort integers using knowledge of entire vector

I am solving the "Sort" problem on Kattis. Mirko is a great code breaker. He knows any cipher in the world can be broken by frequency analysis. He has completely the wrong idea what ...
2
votes
1answer
53 views

React programming pattern

I create https://github.com/storenth/react-redux-todo and ask to review my Todo-react-app for programming pattern: dividing components into presentational components and container components. Here’s ...
2
votes
0answers
18 views

Refactoring Golang to avoid manual fields updating between similar structs and other redundant code

I'm using GraphQL and go-pg. I have many entities like these: ...
0
votes
1answer
69 views

Is this implementation of factory design pattern in C#?

Here are my class library code which create credit card. ...
1
vote
0answers
44 views

Database connector in Python

I've been trying to build an ORM. I started with the connector layer, which is responsible for the database server connections and executes raw SQL as the code below shows. I have built the ...
3
votes
2answers
59 views

PHP Status class : pattern or anti-pattern

I want to abstract some code which does a bunch of checks and returns a boolean - since I am using the business logic in several places. But I also want to get back the reason why, if it was returned ...
2
votes
0answers
42 views

How to split and refactor a large function so it would do only one thing?

I am learning about clean and maintainable code. I heard that functions should be no more than 20 lines long (preferably 5 - 10 lines). I have come across this Bob Martin quote where he said: “The ...

1
2 3 4 5
26