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

Class design supporting many payment methods

Suppose originally a Person class supporting a single CreditCard for purchases a user can do. ...
4
votes
1answer
33 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
64 views

Class Inheritance in C# (possibly generics) [on hold]

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
83 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
23 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
38 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
55 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
34 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
65 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
97 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
46 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
74 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
81 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
39 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
73 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
39 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
48 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
150 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
42 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
263 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
41 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
523 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
68 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 ...
-2
votes
1answer
35 views
1
vote
1answer
35 views

View for logging telephone calls

As part of a web-based claims system I have created, there is a view for logging telephone calls. If a call is incoming, the claims handler asks the caller a series of data protection questions to ...
3
votes
1answer
97 views

Implementation of Strategy Pattern (photo gallery example) [closed]

I'm learning design patterns and I thought that it would be a good idea to make my examples of each pattern. This is my example of the Strategy Pattern. Can you tell me is it good and what to improve? ...
2
votes
1answer
182 views

Generic UnitOfWork

I am trying to create a Repository & UnitOfWork for Data Access Layer. In my current implementation I have to modify my UnitOfWork everytime I create a new repository. I would like to avoid that ...
5
votes
2answers
174 views

SOLID principles breaking in interview task (file parser)

Originally asked on Stack Overflow I recently had an interview where interviewers asked me to Rewrite following code with SOLID principles. Add a new file handler (...
1
vote
0answers
54 views

Proper separation of behaviour and data structure when the data structure is complex

The code in its full glory, complete with unit tests is here (and some discussion of the issue). I am struggling with how the principle of separating data structures and behaviour applies here. This ...
1
vote
1answer
162 views

Command pattern for simple text editor

I was asked to code a TextPad with following functionality: display() – to display the entire content display(n, m) – to ...
0
votes
0answers
37 views

ROR - Point of Sale (POS)

I've the following scenario: the user clicks the "Sales" button which redirects to the creation view of the Shopping Cart. Then, the user enters the EAN code and the Quantity, presses "Add" and the ...
0
votes
2answers
114 views

Binary Search Tree implementation with unique pointers

I have implemented a binary search tree using templates and unique_ptr in C++ 11. At present, only insertion and deletion are implemented. Please provide your feedback for improvements. ...
1
vote
0answers
65 views

Further dive into filtering using IPredicate

Preface This is a follow up to my previous post from not long time ago about containers and filtering. This post can be found here. Now, I will attempt to expand what I have learnt from the answer ...
8
votes
1answer
155 views

Class containers, filtering and coding practices

Context Usually, when I have to deal with a collection of items (especially objects) I tent to create a container class for that collection (wrapper?). What I mean by that is: when I have to handle ...
-2
votes
1answer
24 views

List of abstract object that requires instanceof and casting [closed]

I Have a class which calls a method, that will convert an excel file, and each sheet will be a DTO, and returns a list containing those DTOs ...
1
vote
0answers
22 views

run different validation strategy based on condition

I need to execute different validators depending for different countries ($country_id), each validator should return error message variable in case of failure. One validator (CommonValidator) is ...
0
votes
0answers
105 views

Auto-registering CRTP Factory

I'm trying to write a policy based auto-registering class using the Curiously Recurring Template Pattern. I decided as design choice to not using registering macro. Factory Class ...
8
votes
3answers
1k views

Binary Search Tree implementation using smart pointers

I have implemented below code for binary search tree implementation using shared pointer. At present, I have considered only integers. It supports insertion and deletion of values. Also, a print ...
4
votes
3answers
511 views

Pass IEnumerable<T> as an argument of method and repository pattern

I've seen tutorials of Unit Testing and I've never seen that IEnumerable<T> used as an argument of method. All authors use ...
1
vote
1answer
56 views

Simple local cache that checks by date else get from db

I'm looking for feedback on how this can be improved. Basically what I'm trying to do is check if the cache has the object, else check from the database. I have a list of ids, then I separate them ...
1
vote
0answers
70 views

Image capture client - multi-threading + sharing data between services

I'm working on a small side project at the moment - like a homemade CCTV system. This part is my Python Capture Client - it uses OpenCV to capture frames from a connected webcam and sends the frames ...
0
votes
1answer
76 views

User class: getting user data, logging in, secure CSRF session handling, logging out

In reference to my previous code: User class: getting user data, logging in, secure CSRF session handling I re-wrote my SystemUser class, without the DI container (for now), I'm still trying to ...
0
votes
0answers
20 views

Go interface design for a cluster provisioner application

I'm fairly new to Go and working on an application to create VMs in a some cloud provider. I'm trying to design interfaces and I'd love some reviews. The application creates a cluster (group of VMs ...
2
votes
1answer
109 views

User class: getting user data, logging in, secure CSRF session handling

I wrote this class a few months ago and noticed from a few examples that it's better to break down these classes and separate them. I am not so sure what is the proper way to break it into parts. It ...
4
votes
1answer
85 views

Sourcing data format from multiple different structures

Problem I want to read in the data to dictionary person = { 'name': 'John Doe', 'email': 'johndoe@email.com', 'age': 50, 'connected': False } ...
1
vote
2answers
53 views

Map a set of types to unique IDs and runtime reinterpret back from ID and pointer in C++17

I wanted to create a relatively universal way of serialising an object, by doing a memcpy and generating a unique type ID. Stored together they can be used, for ...
2
votes
1answer
81 views

C++ smart pointers and the Service Locator (anti-?)pattern

So I'm working on a game framework and one of the things I need are access to stateful "services" that can be accessed from all over. I was initially going to use the Singleton pattern but decided to ...
4
votes
1answer
275 views

Defer pattern for constructors in C++

In some specific scenarios, I want to run code after the constructor for a class has run (namely: access std::enable_shared_from_this::shared_from_this()). To solve this without introducing an error ...
5
votes
0answers
83 views

Prototype GameManager for game written in Unity

I am self taught, so I'm consistently seeking ways to code better, and more efficiently. If anyone has the time, please advise me on what can be done better with explanations as to why the old method ...