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
0answers
25 views

Design decision for clone scenario [closed]

As part of my application, I am maintaining a cache which is structured like below, ...
3
votes
1answer
63 views

Building an email generator using abstract factory pattern

I'm trying to build a customer email generator in java using the abstract factory pattern. I understand how to use the factory method pattern; however, I'm a bit confused about the abstract factory ...
1
vote
0answers
26 views

Design to separate client API from internal API in Kotlin for a chess engine

This is a follow-up from my previous review on this site. To be clear, the code is stand-alone, and does not depend on the previous review. As before my goal is to come up with a design for a chess ...
2
votes
1answer
43 views

Iterator-Pattern for an iterator that returns one objects that changes

I wrote an algorithm that returns all k-sized subgraphs of another given graph. Because I don't want to make the runtime of the next() call of the iterator depended on k, I don't want to return a new ...
0
votes
0answers
11 views

Alternative to Sort Order field? [closed]

I have predefined order I want to display my items. However, I am wondering if there's a solid alternative without too many tradeoffs to having a field called sort order. For example: ...
6
votes
1answer
69 views

Design that avoids undesired dependencies in Kotlin for a chess engine

I'm trying to come up with a design for a chess engine in Kotlin that hides implementation details, and that ensures that such an implementation cannot accidentally become spaghetti. Client side ...
0
votes
2answers
122 views

What's wrong with this design in C++?

So I wrote this a while ago and yesterday I was going through it and trying to remember every line of code and how it works. Well, the program simulates a online bank account as well as an ATM. You ...
1
vote
1answer
26 views

Using generators on Observable class

I've decided to implement a simple case of the Observer pattern. I've gone about this considering you can only register 1 single observer in the Observable, instead of allowing multiple ones. I ...
9
votes
3answers
835 views

Refactoring multiple boolean conditions?

I have a Predicate which takes employee object. Predicate<Employee> getPredicate() { return emp -> filter(emp); } Now the filter method is very ...
6
votes
2answers
383 views

Implementing web scraping in a function and in a class

The goal of my code is to implement a web scraping routine to obtain the name and the price of a product. I want to put this routine separated from the main program file. Sample url to scrape: https://...
2
votes
0answers
30 views

router system like laravel, how to manage routes creation and router handler?

i'm trying to create a url router system, for educational purposes, that has a similar usage like Laravel has, but i'm curious about how i can register the routes like laravel does (with single calls ...
4
votes
1answer
53 views

A Python tkinter Activity Planner (To-do List)

I have created a simple Activity Planner that allows adding tasks and associated sub-tasks. It is mainly based on the Treeview widget. This being my first GUI-based ...
2
votes
0answers
63 views

implementation of a mvc url router with low coupling and solid principles

i'm building an url router and i want to improve it to respect SOLID principles, i want suggestions of how can i make it less coupled. here's my current code: Router.php ...
5
votes
1answer
60 views

Strategy pattern in C++ - the Duck simulator

I'm studying design patterns from Head First Design Patterns and, in order to get confident, I plan to implement the each pattern in C++ after studying the corresponding chapter. As regards the ...
0
votes
0answers
28 views

Is it good practice to create an instance of system under test class with dependency injection using @autowired in spring boot projects? [closed]

I am .net developer. I don't have much knowledge on good patterns on java. I just started working on existing spring boot rest service using java. The junit tests are developed using ...
4
votes
1answer
186 views

Utility for Python date ranges

I'm trying to write something that can take a description and a date range and return all the dates that satisfy that description. Descriptions can be anything from the following... ...
11
votes
5answers
1k views

Generic Heap Implementation in C#

This has been done a thousand times on here already, but here's another binary heap implementation. The implementation is generic in terms of heap elements, allows for injection of any type of ...
1
vote
0answers
34 views

Simple Unity program for a research experiment

I'm developing a small C# Unity application to display stereoscopic images as part of a wider research study. Since the experiment consists of unique stages (Start, during a trial, between trials, ...
2
votes
1answer
54 views

Serializable and extensible API implementing the Command Design Pattern

I am currently trying to implement an extensible way to create commands that can be sent to some type of executor. In my case, there would be two of them (server and client). As I posted here, I had a ...
1
vote
0answers
23 views

Design pattern for logger implementation

I have two classes ExceptionLog and DebugLog ...
2
votes
1answer
57 views

Decorator & Visitor Pattern in Python

I have implemented Visitor and Decorator Pattern in python. I am much used to java design pattern style and hence thought would try in python as well. Could anyone tell me if this is the correct way ...
3
votes
2answers
289 views

WebService to calculate transaction statistics

Recently got rejected in a code challenge that was a very simple WebService with 3 endpoins: POST /transactions to add transactions with an ammount and timestamp....
0
votes
0answers
47 views

Making a parameter struct that preserves const

Given a group of functions that all take similar arguments, eg. ...
1
vote
0answers
65 views

Create and traverse a graph

I have a class with three similar methods. I can't consider which a pattern to use better for refactoring: template method, strategy or something else? I don't know. Can you help me? Update: This code ...
-2
votes
1answer
62 views

C++ generic task interface for delayed execution

I want to rework my current game-server engine to use some global queue of tasks which will be distributed through all the working threads. I started with task interface. I want it to be able to ...
3
votes
1answer
119 views

Attempting a Strategy design pattern in JS

I'm going through the Head First Design Patterns book and I want to check whether I'm understanding some aspects of the first chapter. Does the code below program correctly to interfaces, encapsulate ...
0
votes
2answers
74 views

How to handle same code parts in Factory Method?

I have classes: ...
2
votes
0answers
20 views

Object oriented behavioural project structure in Typescript

This code structure allows me to quickly create and manage behaviours on p5.js sketches. I'm planning to move to Java but wanted feedback beforehand. The behaviour interface: ...
2
votes
3answers
122 views

Online Book Reader Object Oriented Design

I have designed and Online Book Reader System. You can find the classes below. I would be appreciated for the valuable reviews. Assumptions: "Online Book Reader System" is a system includes online ...
0
votes
1answer
47 views

Basic asio framework using epoll

I created an asio framework using epoll. Full project: https://github.com/arkceajin/EpollSocket.git I wanna know is there any potential issue. Below is the core ...
2
votes
0answers
15 views

React-Native Account screen with a modal for updating details

Just looking for advice/thoughts on the overall AccountModal and how its written. looking to achieve better written, more legible, less repetitive code, more concise, cleaner etc... AccountScreen.js: ...
0
votes
0answers
34 views

Implicitly passing client context to services in Node.js

In node.js I have been trying to find a way to pass client context from the Express routes into the services without every service function to have a context. By ...
5
votes
1answer
70 views

Command Pattern: Does my implementation make the point?

Asking for a review of my implementation of a command pattern. In a Editor, words can be entered and the entering of words can be undone. General purpose Interface ...
0
votes
2answers
71 views

Descriptor to restrict input [closed]

We start off we the following Person class: ...
6
votes
3answers
164 views

C# Event Manager without allocations

I'm using my own Action-based Event Manager for a while and looking for ways to improve it. Mainly it's used in game development, where excessive garbage generation can lead to severe consequences. ...
2
votes
2answers
141 views

Is it good to use the builder design pattern for HttpWebRequest?

I've a C# WinForms application that relies heavily on sending HttpWebRequests. I've build an HttpWebRequestBuilder, and ...
0
votes
1answer
41 views

Refactor the method which is the sequence of the similarly looking steps to (or towards) the design patterm(s) [closed]

I need some help to understand if the code below could be refactored to something less straightforward, less repetitive and more towards any appropriate pattern. What I feel uncomfortable with in ...
1
vote
1answer
76 views

Laravel 5.8: prevent duplicated code

Sometimes we have this code blocks that is repeated in the same controller again and again, I reviewed the Repository Pattern but I didn't understand how to deal with some kind of these duplication. ...
-1
votes
1answer
109 views

Fast efficient C++ Singleton template with proper constructor and destruction order

I wrote a Singleton template, with examples, google tests and README https://github.com/erez-strauss/init_singleton/blob/master/singleton.h The usage can be as simple as: ...
4
votes
1answer
122 views

Elevator Design

I want to design an elevator system, which has functionality for pressing button from outside of the elevator (Not selecting a direction - Only calls the passenger’s existing floor). And also select ...
3
votes
2answers
60 views

Organise method flow

I have something like a shop. It is limited to a checkout page, which will send an email. Nothing big, but a nice thing to learn more OOP. Almost every time I develop new classes I am wondering how ...
4
votes
1answer
92 views

strategy pattern, good practices on how to switch between classes

i'm using an external API that posts products and orders into a marketplace, and it provides a class that in each request i have to specify an endpoint, ...
2
votes
1answer
66 views

Data structure manager implementation

I am a beginner Java developer, and I am self learning Java by developing a real life business desktop application intended for management in repair shops. It is unimaginatively called Repair Shop ...
6
votes
1answer
123 views

c# Factory Pattern Generic Exception Handler using dot net core

My task was to create exception handler on some system that has multiple types of database and big business behavior. At first, I had done a switch/case that handled the exceptions by type using the <...
1
vote
1answer
155 views

C# Simple Poker Game - Is a good Design?

I want to make a simple poker game. What I pay particular attention to is design: I look for suggestions to improve the quality of the design and also suggestions on possible improvements in style ...
5
votes
4answers
1k views

Updated: Questions on implementing Builder design pattern

I am in the process of using Java Builder design pattern to write a connector class that has optional member variables and need some suggestions. My question from here Standard practices for employing ...
0
votes
1answer
46 views

Use of Factory pattern — how to implement it

I am trying to figure out how Factory pattern works. I implemented it with TypeScript in this github repo: https://github.com/emilecollin/factory_pattern Basically this is emulating spaceships gaming ...
4
votes
1answer
113 views

Simple circuit breaker implementation

I am trying to implement a basic circuit breaker design for my internal API calls. I would appreciate some criticism and feedback about my code. I am also planning to implement an interface off of the ...
4
votes
0answers
67 views

Multi-platfform process handling

The goal of this code is to handle processes in multiple platforms, Linux initially. Windows later. The high level handler starts and stops a process or a list of processes. The platform specific ...
4
votes
0answers
52 views

Enables markup to instantiate objects, call methods, and generate HTML

I'm looking for a code review for the package PXP. https://github.com/hxtree/PXP/ PXP enables markup to instantiate objects, call methods, and generate HTML. It works similar to a server-side ...

1
2 3 4 5
25