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
24 views

Design pattern for logger implementation

I have two classes ExceptionLog and DebugLog ...
2
votes
1answer
78 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
291 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
48 views

Making a parameter struct that preserves const

Given a group of functions that all take similar arguments, eg. ...
1
vote
0answers
67 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
75 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
121 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
21 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
130 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
51 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
17 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
38 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
71 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
72 views

Descriptor to restrict input [closed]

We start off we the following Person class: ...
6
votes
3answers
196 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
158 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
107 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
113 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
154 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
61 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
94 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
68 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
169 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
188 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
124 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
vote
2answers
74 views

Generic Implementation for Paging Class in c#

I have created one generic Page class for store paging information with its data. The class look like: ...
6
votes
2answers
81 views

Opposite access to enums

Consider I have many enums (Java) that looks somewhat like this: ...
1
vote
1answer
103 views

Implementing Decorator Pattern

Context I'm looking into design patterns. My first try is using the Decorator Pattern. Question: Is there another (maybe standard) approach to applying modifications in a decorator other than ...
3
votes
2answers
104 views

Adding/removing songs to a playlist

This is a simple Java application, which adds songs to a playlist, removes songs from playlist based on indexes. A database is not used in this. I am creating dummy data through a ...
10
votes
2answers
141 views

System design - Jaipur board game learning agent

Link to my previous question. I've implemented the other features of the board game, and made a simple learning method that stores state values and makes optimal moves based on that. I've used some ...
8
votes
4answers
2k views

A new type of builder pattern

The fact is that I wanted to apply the builder pattern. But this could not be achieved, since I could not create an instance of the class with an empty constructor - this is dangerous. The goal is to ...
1
vote
0answers
42 views

Python - Checking for errors [closed]

How would I go about checking to make sure only valid results are entered/How do I create a loop that will continue to ask one of the questions until answered correctly? ...
1
vote
1answer
109 views

How well does this ECS implementation follow these principles?

I'm currently learning about Entity-Component-System architecture Data-Driven design as a way to counter bad OOP design and optimize data fetching as a CPU friendly operation. I'm trying to write a ...
5
votes
1answer
157 views

Is this code SOLID?

I have recently learnt SOLID patterns and started practicing them. I did follow all the guidelines but was thinking for a final review from experts if possible. What is the code about ? It encrypts ...
1
vote
1answer
79 views

Parsing xml files, ideas to design my code

I begun to work for a company which do not have enough time to practice code review. As a beginner programmer I would like to improve my skills on real working cases. I have been asked to facilitate ...
2
votes
1answer
36 views

Find closest elements in an array relative to given index with a bias to distance from index and direction

This function determines which images should be loaded based on which image is currently in the viewport (array index), what direction the user is scrolling, and if the image has yet to be loaded. It ...
2
votes
0answers
123 views

Access a variable after several references

I have a team lead that used to write references in a single script then access it in every script. Like for accessing a variable he has to write code in this way ...
3
votes
1answer
37 views

Calculating direction based on index of array

I am comparing the index of the current component displayed in the viewport against an array of all the components on the screen to determine to direction the user in scrolling. Does this function ...
3
votes
1answer
91 views

MVC pattern in my Repair Shop application

I am currently learning Java programing by building real life business application for repair shops. I am posting this code so I can get critical review, and change my application architecture if ...
1
vote
0answers
50 views

Tree Structure using Composite and Visitor Pattern

I have the structure Corporation/Company/Facility/Storage and only Storage could be part of Facility, and Facility could be part of Company, and Company part of Corporation. My main problem is for the ...
2
votes
0answers
124 views

Is this an acceptable MVVM Model with IEditableObject implementation?

I'm trying to follow MVVM pattern in a VB.net WPF application, and I would like to implement IEditableObject. Is this code acceptable for an MVVM application? In ...
3
votes
3answers
133 views

Detecting overlapped boxes and the color of overlapped area in a View

Recently, I applied for a job that required skills in object-oriented programming. Although I have coded in Java at odd times, those were very small assignments. I have been mostly programming in C ...
1
vote
0answers
37 views

Pattern decorator with template class [closed]

I'm trying to create a generic class for decorator pattern. I successfully did it with the example code by metaprogramming: ...
2
votes
0answers
54 views

Implementation of SCPI for control of test instruments

I work with electronics test equipment. I like to be able to automate tests using their remote control interfaces. I have built a pattern, a few base classes, that I can apply to all devices that ...

1
2
3 4 5
25