Questions tagged [design-patterns]

A design pattern is a general reusable solution to a commonly occurring problem in software design. Use this tag for questions when you're having problems with the implementation of design-patterns. Please don't use this tag on questions about text pattern matching. When using this tag on implementation heavy questions - tag the code language the implementation is written in.

Filter by
Sorted by
Tagged with
-3 votes
0 answers
20 views

How to use interface and embedding (or other mechanics) to implement a specific function

I got stuck in a specific design issue. I'am using Go for a project. I have two class A and B, and A is a member of B. Now, I need to modify a function of A a little, let's call this function A.roll, ...
tangyao's user avatar
-2 votes
0 answers
38 views

Is there a common design pattern to model equivalence of records?

I am looking at a table/dataset with N records. Some of these records are to be treated as equivalent in certain situations, i.e. interchangeable. Consider this data structure: In here, if records x ...
F-H's user avatar
  • 733
0 votes
0 answers
29 views

Why does typescript subtype work with class generics but not with method generics?

I have this code here, with one type extending another one and one interface typed to use the former and a second one typed to use the latter: interface BaseType { a: number; } interface ...
heapOverflow's user avatar
  • 1,205
0 votes
0 answers
18 views

Admin service in microservices paradigm

So to be shorter my problem sounds like this: I'm trying to design microservices so I have multiple domains like (users, items, sales, surveys, comments etc.). Each microservice has its own database. ...
Dinar_sd's user avatar
0 votes
0 answers
27 views

SQS consumer - message handlers and delegation [closed]

I'm working on a SQS consumer application using Spring AWS Cloud and Spring Boot. I have listeners and handlers for different types of messages. I want to know which design pattern to use for ...
Siva s's user avatar
  • 1
0 votes
1 answer
81 views

What the primary difference between control coupling and common coupling?

There are several level of coupling between modules (according to this article): According to the article: Control Coupling: If the modules communicate by passing control information, then they are ...
Bondarenko's user avatar
0 votes
2 answers
38 views

Is there a name for the design concept in which a function's parameter type enforces the constraints to eschew guard clauses?

Suppose I have a (pseudo-code) function divideTwenty. fn integer divideTwenty(int divisor) { return 20/divisor; } This function is simple, but error prone. Specifically, what if divisor is 0? What'...
AJ Snow's user avatar
  • 21
0 votes
1 answer
32 views

Push and Pull Communication Styles in oop: why Push style is not flexible?

I'm trying to learn Observer Design Pattern and I started to watch the series which belongs to codewithmosh called "The Ultimate Design Pattern Series". in the lesson which was about ...
Mehdi's user avatar
  • 93
-2 votes
0 answers
25 views

Loading models on construct of other models in MVC causing infinite loop [closed]

A design pattern question related to MVC. I have an application which has a number of models. In some cases, models need to pass/get data to other models. This is traditional MVC, no service layer. ...
David's user avatar
  • 16.3k
-2 votes
0 answers
37 views

Is using a thread-safe (or mostly thread-safe) C or C++ shared library for maths with the Java FFM Api a good idea [closed]

I am writing a modular dynamic calculator app in Java (for personal project), and I was thinking I could boost the overall calculation speed by using the new Foreign Function and Memory API library in ...
Ricardo's user avatar
  • 145
-3 votes
0 answers
39 views

Design a budget based capping system for customers [closed]

I am developing a real-time loyalty system where customers earn points for transactions, subject to a monthly/yearly budget for the entire loyalty program, rather than individual customers. With a ...
Muddassir Rahman's user avatar
0 votes
1 answer
44 views

What is the design approach for this problem statement?

Currently there are 200 customers and each of them have their own code base which has almost exact same code. The level of differences are as follows There are values in app.config and based on that ...
Auro's user avatar
  • 61
0 votes
1 answer
39 views

how to make logic for pattern "*" question in python

Make the pattern * ** *** **** ***** using loops in python There is some problem in the logic of this for loop can u check and please tell for i in range(0, 5): for j in range(0, i+1): ...
Shivam Raj's user avatar
1 vote
0 answers
32 views

Dynamic BLoC Implementation Switching in Flutter Using Bloc Pattern and Custom Class Loader

I'm facing a challenge in designing a Flutter application with the BLoC state management pattern. The app is intended to be generic but used by multiple clients, some of whom have specific needs ...
Hedwin's user avatar
  • 345
0 votes
0 answers
29 views

Cyclomatic complexity issues with Simple Spring boot Rest Controller

I am using SonaQube scans for my Java project and trying to understand cyclomatic complexity issues. However this is very know design issues, I am trying to understand why simple return statements ...
sandeep's user avatar
  • 71
2 votes
1 answer
72 views

Modelling Gof Observer patterns in UML

I am in the process of modeling my project, which I will subsequently implement in Java, utilizing UML. The focus of my project is the management of a gym. Currently, I am working on modeling my GoF ...
Luca Martorelli's user avatar
-8 votes
0 answers
68 views

How do I create a pattern using an array? [closed]

I have to create a pattern using an array, but I have no idea what to do. Class videos aren't helpful, if someone could please help me with this i'd appreciate it. The pattern I need to make looks ...
brainhuuurts's user avatar
0 votes
0 answers
14 views

Security flow diagram to protect confidential information for external user

I am working on a POC to create flow diagram to secure protected data for external user. We are planning to work on market place where external user will login via external application and paired with ...
Sandeep Matolia's user avatar
0 votes
0 answers
38 views

Composability: Iterator vs Lambda

I am having trouble understanding the concept of 'good' functional composability. Assume the following approaches for deleting files with a specific extension: Using Lambda functions: def ...
newbnoob's user avatar
-2 votes
0 answers
28 views

What the way for transferring data to the factory classes? [closed]

I want to understand how best to pass data to factory classes Hello! Situation: 1)I have a class with records for orders. For example, class Order 2)Separately, I create a factory (simple factory) and ...
Mary's user avatar
  • 7
0 votes
0 answers
13 views

Designing Generic Type Dropdown/Bottom Drawer component

this is the first time I've run into an issue like this as I don't often use generics and was looking for some advice. We have an existing Dropdown component in our codebase that takes in the ...
user23023951's user avatar
0 votes
1 answer
64 views

How to solve multiple class inheritance without duplicating code in my case?

My concrete classes can be one of the type permutations shown below. But, since I cannot inherit from two classes (case 4 and 5) I had to convert one of them to interface which introduce code ...
theateist's user avatar
  • 14k
-1 votes
0 answers
21 views

Java design pattern for mod system(Minecraft mcp) [closed]

i'm coding a minecraft client at the moment but I don't know how to write efficient a modular mod system. Until now I have one superclass called mod and subclasses with the implementation in it and ...
Quotschi's user avatar
-3 votes
1 answer
45 views

Why my pyramid pattern code is not working? [closed]

So I tried below code for pyramid pattern and in output pattern first star is getting misplaced.can you tell me why this is happening? This code I used This is output i am getting This is output i am ...
Vaishnavi Maske's user avatar
0 votes
1 answer
33 views

cannot use object as interface value in argument to function: oject does not implement interface in golang [closed]

I was trying to implment strategy design pattern in golang. Currently, my code looks like this: package main import ( ca "github.com/Kieraya/test/test2/cache" "github.com/...
Aditya's user avatar
  • 29
0 votes
0 answers
25 views

How can I use, in the same project, old and recent python librairies which respectively need old and new python version?

I'm a researcher in cartography and some specific librairies are sometimes only working with python 2.7 while others need python 3.X. I have some projects that need to use multiple of these librairies,...
Quentin Potié's user avatar
0 votes
0 answers
15 views

Design Strategies for Integrating Enroll Plan-Specific Features in a Django Project

I am working on a Django project that comprises three main components: nkb_assessment_backend: Handles assessments and exams, featuring apps like nkb_exam and nkb_exam_extensions. ...
Lalam Rajesh's user avatar
0 votes
0 answers
52 views

Having trouble to design the data pattern in swiftui

I am creating a camera app I have a CameraService which is an ObservableObject and it runs the session. and update some UI according to session status.Then I inject it using .envrionmentObject() in ...
Perry Wang's user avatar
-1 votes
0 answers
22 views

Refractor of generic method that returns single type [closed]

I have working code. This, provided below, is a very simplified version of mine. The main point is that I have two classes that are somewhat different, however they provide the same information needed ...
busido's user avatar
  • 11
0 votes
1 answer
45 views

Decorating class having methods internally calling each other

I have a class IMessageProcessor public interface IMessageProcessor{ Task ProcessMessages(); Task ProcessMessage(Message message); } with simplified implementation: public class ...
tabs0n's user avatar
  • 15
1 vote
2 answers
79 views

How to write generic CRUD controller for all entities in golang?

I am creating a Go server using GoFiber to return data from MySQL database. I am using GORM library to save and fetch data from the db. I have 8 entities in total. I have defined model for these ...
Anmol Garg's user avatar
1 vote
0 answers
58 views

Looking for design pattern for flexibile generic serialization

I have a header-only library that provides three class (templates), namely an abstract DAGNode, struct DAGNode; using NodePtr = std::shared_ptr<DAGNode>; class DAGNode { public: virtual ~...
joergbrech's user avatar
  • 2,288
1 vote
1 answer
35 views

Is a "delayed reference" a known programming pattern?

I'm trying to understand JZZ's API. One of the pecularities is after you obtain a port (a place to send MIDI instructions to), you can do this: const a = port.noteOn(0, 'C5', 127); // plays note ...
Steve Bennett's user avatar
0 votes
0 answers
36 views

Creating a service layer with Django Rest Framework

I am fairly new to web-development and just studing design patterns and code architecture. Now, I am developing service layer for business logic. And here I have a dillema. One approach is to use ...
Mihail Bury's user avatar
0 votes
2 answers
38 views

handle methods in a class calling shared sub-methods with varying order and frequency in Java/Kotlin

How can I implement multiple methods in a Java/Kotlin class that invoke the same sub-methods but in a different order, or sometimes a method calls more sub-methods than another? Is there a design ...
abdel's user avatar
  • 29
-1 votes
1 answer
65 views

Java : generics, inheritance and best design

I have a basic processing interface : public interface Processing<T> { void appendTo(T t); } And this inheritance tree : public class Animal { } public class Dog extends Animal { ...
AntonBoarf's user avatar
  • 1,241
0 votes
0 answers
29 views

Django Model Structure for products with Multiple Categories

I want to know if it is possible (and if so, what is the most pythonic way) to have a product that belongs to multiple product categories. e.g. an avocado belonging to [Food->Fresh Food->Fruit &...
ATee's user avatar
  • 1
1 vote
2 answers
107 views

Java Factory pattern

I have module A and module B each one have some specific services and i have a module C that don't have any dependencies to A and B so what i want is to call services from modules A and B and I want ...
Ramzi Mrabet's user avatar
0 votes
1 answer
101 views

How to Implement Decorator Design Pattern in JavaFX Controllers?

I'm working on a JavaFX project and would like to apply the decorator design pattern to my controllers to enhance their functionality. Specifically, I want to add additional behavior to existing ...
Kosz3's user avatar
  • 3
0 votes
1 answer
43 views

Use an "external" variable in React to remember a value between different render

I'm learning React. I have a counter that auto-increment. The user can cancel with a button the counter component and with the same button can re-render the component and in this case I want that the ...
Nick's user avatar
  • 1,499
0 votes
0 answers
16 views

Shell Script Design Patteren: Source a library file VS Call different files?

We discuss about POSIX compliant shell script here. While we are writing more and more shell scripts, we build some helper functions to reuse the codes. We are considering putting a few helper ...
midnite's user avatar
  • 5,197
0 votes
0 answers
27 views

Flutter: How to listen/get characteristic of a Text widget?

So, I am trying to make a border/stroke effect for Text widget using Stack and Positioned. class BorderedText extends StatelessWidget { BorderedText({ super.key, required this.text, ...
Sri Kavipriyan's user avatar
1 vote
0 answers
36 views

Viable solution to handling long running query in Java

I have a Spring API which invokes rest call to an enterprise payment platform which calls into JPM Chase. All is fine on that and when taken we save response in our SQL Server DB. Our Spring API is ...
Kevin Quinn's user avatar
1 vote
2 answers
99 views

Is this UML diagram violating the Interface Segregation Principle?

I have created this UML diagram which applies the Template method design pattern: Both concrete classes share a lot of the logic whithin the template methods createTask and completeTask, with small ...
Jose Robles Villares's user avatar
2 votes
1 answer
34 views

Filtering inside a processing method vs. filtering outside

In my application I am processing a List of IMyInterface instances. Not all, but some of them in addition also implement IAnotherInterface. Note that IAnotherInterface not derives from IMyInterface. ...
stefan.at.kotlin's user avatar
0 votes
1 answer
43 views

Generic implementation that can pass parameter to choose which code to use

I have an interface like so: public interface IIdentifierManager { Task<bool> Method1(string identifierName, string identifier); Task<bool> Method2(IEnumerable<string> ids); }...
Bohn's user avatar
  • 26.3k
-1 votes
0 answers
38 views

How can I add pattern in only one color ggplot?

How can I manually choose colors to my pallete and also create a pattern in only one color? (I want transparent to be white color with some lines to differentiate from white color). mp20 <- data....
oceanpath's user avatar
0 votes
0 answers
18 views

create include dependency graph for non-header files

I try to create an include graph with doxygen v1.8.9.1. In my project I have .c and .h files. But also other file extensions (e.g. .abc) that could have an include statement like #include "common....
Dr. Joe's user avatar
  • 33
0 votes
1 answer
59 views

Command pattern design in Spring [closed]

I have more or less implemented the command pattern in my Spring Boot application. I still have some doubts and would like to get second opinion on them. I have a CommandFactory which - when given a ...
IceMajor's user avatar
  • 162
0 votes
1 answer
48 views

How to prevent coupling between our code and third party libraries?

Imagine we want to use the following library like this: use GrahamCampbell\GitHub\GitHubManager; class Foo { private GitHubManager $github; public function __construct(GitHubManager $github) ...
Ali's user avatar
  • 327

1
2 3 4 5
641