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
votes
0answers
10 views

Wrapper for object to avoid ambigous boolean in method [on hold]

I recently thought if wrapping an object in a method that returns that object only when a method inside it is called is a good idea. I have a User object with fields like username, email, avatar etc. ...
1
vote
0answers
41 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 ...
-3
votes
0answers
23 views

Is this a reasonable way to represent a test instrument that supports SCPI? [on hold]

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

update field when others fields are motifed [closed]

I have a class Installment and a method executeTransaction. The field totalBalance ...
4
votes
0answers
78 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
64 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
130 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
49 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 ...
-2
votes
0answers
30 views

anti-patterns on implementation of dependency inversion principle

See Edit below I am practicing on clean architecture with 3 layers data, domain, and ...
5
votes
1answer
31 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
430 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
159 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
65 views

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

Lets say I have the following interfaces ...
1
vote
2answers
61 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
206 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
54 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
59 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
97 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 ...
0
votes
0answers
27 views

Server Design with GraphQL.Js

To learn graphql I'm creating a server for queries to a local postgres cluster. The pg cluster is populated with sample data from postgresqltutorial.com and I wanted to use GraphQL.Js instead of ...
2
votes
2answers
73 views

Logger adapter with a configurable chain of responsibility of middlewares

I use my own logger adapter that collects data into a dictionary: public class Log : Dictionary<string, object> { } This is really all I have. I then pass ...
3
votes
0answers
35 views

Adapter pattern to support multiple file storage systems

I am just getting in to following design patterns. I have create a class that allows for performing a couple operations on different remote storage systems: drive, dropbox, .etc (I call these ...
1
vote
0answers
26 views

Encrypted network protocol in NodeJS

This is just an exercise. I know I should not implement encryption protocol myself. I know I should use Node's TLS package. I know I do not authenticate other side, but merely encrypting traffic. I ...
1
vote
1answer
31 views

Adding Length dimension to a Crate Object

Consider Crate::addLength() in the following code: ...
4
votes
0answers
95 views

Toggle any application feature ON or OFF - follow-up (v2)

This is the second version of my FeatureToggle service (see previous question). It still has the same purpose which is to help control whether a feature is ...
-2
votes
1answer
47 views

Simple First Come First Serve Scheduling Simulator [closed]

My goal is to write a CPU Scheduling Simulator in C++ using the STL features as far as possible. So far, I have only written the code for FCFS and have not provided any input method. What sticks out ...
3
votes
2answers
128 views

Implement The Singleton Pattern for Persistency managers Swift [closed]

I am creating an iOS app and I want to implement Singleton Pattern. I have created "Singleton" LibraryAPI to act as an entry point UserManager object to get data from web API. after that I used a ...
5
votes
1answer
45 views

A view for Python list slices

As you probably know, Python slices like arr[1:3] etc. do NOT provide a view onto list and instead creates a copy of the list, what can be not optimal performance ...
-1
votes
1answer
77 views

Class Inheritance in C# (possibly generics) [closed]

I'm working on a segment of code where it runs a number of tasks and then combine individual task results to construct a complete task result object, there's no concurrency involved so it's purely a ...
0
votes
1answer
99 views

Abstracting an Email Notification Service & testing the the logic of the used abstract factory

In my application I have an Interface IEmailNotification that represents an Email and the concrete implementations have nothing to do with ...
1
vote
1answer
26 views

Command Design Pattern Implementation: Moving Robot with Undo-movement (Python)

I'm learning about the command design pattern and would like you to critique it for division of responsibility, especially with regards to how the robot "undoes" commands it previously executed and ...
3
votes
0answers
61 views

Object Oriented Chess Design In Kotlin

I know there's a similar question to this: See here. And I have taken the points mentioned there into consideration. However, I wanted to learn Kotlin and thought of writing OOP based Chess myself. ...
-4
votes
1answer
66 views

Is it a proper implementation strategy pattern? what's better to use enum or define? [closed]

The idea is that when we want to create an object of some type, we will only use a robotcreator and enum from the interface. the goal is to decides what type of robot to use internally, based on a ...
1
vote
0answers
40 views

Lightweight, modular Discord bot - tips and feedback on the code?

The full project is up on GitHub. The codebase is super small as it stands. I'm brand new to reactive programming and Spring, and would mostly like insight on those two things. Asynchronous ...
3
votes
2answers
83 views

Simple OOP currency converter - follow-up

This is a follow up question on this post This is what I changed on my previous code: I use Exchanger and PairCurrency class ...
3
votes
3answers
124 views

Thread-safe “singleton” that destroys object when not used anymore

I'm working on some legacy code which uses the singleton pattern. The problem I have with the traditional singleton is that the instance lives until the program terminates. This is messing up the ...
2
votes
1answer
49 views

Abstracting a SQL Server Table builder

I'm working with SQL Server 2008 and wanted to make table builder, similar to Laravel's migration classes. I would like to be able to expand this down the road but the main purpose of this code will ...
3
votes
1answer
76 views

Parsing Game Entities

Could use some help with my presentation in Software Development. I'm presenting how I reworked a game's parser (SpaceTaxi). Basically we take in a .txt file with ASCII characters and convert them ...
4
votes
1answer
84 views

How to group custom events [closed]

I have a number of custom events that a class might or might not subscribe to. ...
1
vote
1answer
45 views

Inter module communication

I have two modules, Notification which basically contains SignalR hubs and CoreSetup which contains core setup logic in it. I have a class in CoreSetup module which keeps track of employee location . ...
1
vote
0answers
116 views

C# Generic Repository and Unit of Work Implementation for Northwind [closed]

I have created 3 projects to implement layered architecture design mainly the - Presentation Layer (Web) - Domain Model Layer - Infrastructure Layer For simplicity, I have only two domain model ...
1
vote
1answer
44 views

Map client application's DTO to service-proxy's DataContract

My idea is to not not expose/use service's Proxy everywhere throughout the application, rather exercising all service communications(using client Proxy) from a single class. To achieve this I have ...
2
votes
0answers
53 views

Querying based on condition

I am using Entity Framework Core as ORM in my ASP.NET Core 2.1 project. I want to perform server-side pagination in Career Controller for getting list of careers. I have a model which looks like: <...
3
votes
2answers
158 views

Strategy advisor for a Yahtzee Roll

I'm implementing a Yahtzee app and i have a class StrategicAdvisor that is responsible for deciding which strategy should be followed. The ...
1
vote
0answers
54 views

Near immutable, thread safe Builder

I'm writing a torrent streaming client. The plan is to wrap WebTorrent-cli and provide a Java interface to observe download state, cancel or pause downloads etc. Anyways, I came up with the following ...
9
votes
2answers
314 views

Userform Event Listener and Emitter

It has been a royal pain that MSForm controls are missing simple events such as MouseOver and Blur, and I find myself often ...
3
votes
1answer
204 views

Implicit Async and none async event handlers

I have implemented a event aggregator for our backend. ...
3
votes
1answer
42 views

Subject group creation/selection using multiple filter tags derived from multiple databases

This is part of my research project with the main objective to select patients from various characteristics that are modeled as filters. The main filters include ...
7
votes
2answers
531 views

Strategy pattern for four arithmetic operations

I am studying design patterns, I was wondering if my approach makes sense. I am trying to implement the strategy pattern. I think I have captured the essence which is Define a family of algorithms, ...
1
vote
1answer
71 views

Repeatedly open and close a PDF document to perform various operations [closed]

I am trying to implement the Execute Around pattern described in Kent Beck's Smalltalk Best Practice Patterns. An example in Java could be found here. Basically, I am repeatedly opening and closing ...