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
3
votes
1answer
29 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 collection can lead to severe consequences. ...
2
votes
2answers
100 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
40 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 ...
2
votes
0answers
26 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 ...
-1
votes
1answer
101 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: ...
3
votes
1answer
92 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
56 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
80 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 ...
5
votes
1answer
73 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
130 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
97 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
61 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
50 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
67 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
72 views

Opposite access to enums

Consider I have many enums (Java) that looks somewhat like this: ...
1
vote
1answer
98 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
92 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
136 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
36 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
62 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 ...
4
votes
1answer
153 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
73 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
35 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
122 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
35 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
88 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
44 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
60 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
120 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
36 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
50 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
votes
1answer
37 views

update field when others fields are motifed [closed]

I have a class Installment and a method executeTransaction. The field totalBalance ...
5
votes
0answers
104 views

Extending VBA classes with Behavioral Patterns

I want to learn about Design Patterns and be able to apply them in Excel VBA. So to learn about patterns I bought a book that seems promising: Head First Design Patterns; it presents the material ...
1
vote
0answers
89 views

Clean way of passing parameters in swift

I am creating a user request model to pass-params for web service call toRegisterParams() is used call register web service request toLoginParams() is used call register web service request so my ...
4
votes
1answer
139 views

Factory pattern for creating embossing machines

I'm working on a program that creates a file for a specific embosser machine (machine that creates plastic bank card for example). I have 3 embosser machines and all of them create different files. ...
4
votes
0answers
53 views

Mapping abstraction? (Node JS) [closed]

There will be a huge object mapping (transforming) with a lot of calculations and logic for some fields. I would like to refactor this to classes or some kind of separation so it will be easily ...
5
votes
1answer
35 views

CandidateArchive for model-assisted multi-fidelity global search algorithm

For my research I'm working on global search methods where a candidate solution can have it's fitness (=score) evaluated in multiple fidelities (=accuracy levels). The goal of the ...
8
votes
4answers
555 views

DDD Architecture for an e-commerce website (uploading images)

Problem Description I am working on an e-commerce website, when a user wants to sell a product, he would open the product page and he can upload up to 12 photos: Image Upload Process This is the ...
3
votes
1answer
160 views

Consistent and extendable way to store data for session

I am making session store which will store some data and read some, This session store can store multiple data( SessionInfo) to the map. Data Structure ...
-2
votes
1answer
69 views

Is using generics like this a type of code smell? [closed]

Lets say I have the following interfaces ...
1
vote
2answers
62 views

Header file for accessing components globally in library

In my project I have a header file which contains only functions which are put into a namespace, the purpose of these functions is to be used from another class of the framework I'm working on, or ...
3
votes
1answer
221 views

Bank ATM Mockup App

This is a follow-up on bank ATM mockup app in .NET Core framework and Entity Framework Core. I have 2 user interfaces: Console and Web. Previously I have UOW and repository layer but I have removed ...
0
votes
1answer
80 views

Builder pattern in C# supporting subclassing with nested classes [closed]

[Posted yesterday on Software Engineering, but was apparently "disappeared"...maybe better here] Background: I am just starting to get my head around the idea of separating the domain model from the ...
16
votes
2answers
2k views

Singleton Design Pattern implementation in a not traditional way

For implementing Singleton we can use Traditional way like this Article, but i think that to write it in another way: ...
1
vote
0answers
65 views

What pattern can I use to write CRUD functionality? [closed]

I am writing a console application. CRUD functionality.I would like to try to apply the pattern. Is it possible to apply a "state" pattern? In the AddCustomer () ...
2
votes
3answers
132 views

Simple middleware pipeline builder (similar to asp.net-core)

I created a simple middleware pipeline builder that I want to use for my frameworks. It is similar to how ASP.NET-Core middleware works and uses the same conventions: A public constructor with a ...