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
0
votes
1answer
79 views

Is it an antipattern to pass an object that stores the application state from one function to another?

The program is written in JavaScript. To give you a rough idea what I am thinking of: function State() { return { color: 'green', size: 100, // ... there are other properties here } } ...
-2
votes
1answer
70 views

What architectures allow for letting users author custom domain logic?

Are there any prescribed patterns or systems for allowing a user to create custom domain logic? Consider the following scenario An application exists that allows users to run complex calculations on ...
0
votes
1answer
73 views

Combining synchronous and asynchronous commands when using the command pattern

Let's say I'm building a simple console app which has three commands: Create category. Download recipe from API to category. Display all recipes in a category. Assuming the app will grow, I use the ...
-2
votes
1answer
119 views

To return or not - redundant data from method arguments

Which code should I prefere and why? Is there some general rule? Code 1: var apiLicenseInfo = GetLicenseFromApi(string userId, string deviceId); var localLicenseInfo = MapToLocalLicense(apiLicenseInfo)...
1
vote
1answer
72 views

Strategy Design Pattern vs Inheritance

I have to write a code where i have send some data (call it List of cases) using one of two integration tools (Jitterbit, Mulesoft), with possibility of adding more tools in future. Integration tool ...
-2
votes
3answers
111 views

Code optimization tool [closed]

Would it be possible to develop a program that could optimize algorithms, detect design patterns and then rewrite the code? For example: Detect a Bubble sort and transform it into a Quick sort or a ...
-2
votes
0answers
28 views

Highly Available System | Transfer State Between Two Instances

If we had a highly available service running and that service required an update, I typically see that the service goes down for sometime, and then the new service comes up. For discussion's sake, let'...
1
vote
2answers
75 views

Prove that Feature Flags turned off Items in Production Environment

We want to implement Feature Deploy Flags, so Development Application Environment will have a new Product feature Toggled on. And Release and Production Environment Webpage, it is turned off. Its ...
-3
votes
2answers
51 views

What pattern for different data descriptions

We need to call a webservice which registers a shipment with either UPS or TNT. You fill in some details, call the function to register and pass json for details. Pretty basic stuff. Shipment shipment ...
-1
votes
1answer
62 views

Setter dependency injection or locator pattern

Let's say that I have the following class. class Application { protected $dependency; public function setDependency($type) { $this->dependency = ServiceLocator->...
-3
votes
2answers
77 views

What Design Patterns for encouraging component reuse?

One of the major issues that I am facing as a Website and App developer, is that certain components / features have to be redeveloped over and over again with a new project. For instance login, signup,...
-1
votes
0answers
58 views

design pattern to simplify nested if statements

I'm implementing a search functionality and based on the query parameter i use a different class to search. I will only illustrate one SearchStrategy which is the SearchThreads, just to make the ...
1
vote
1answer
128 views

Using lambdas to decouple the client code

The ISP says that the client should not depend on things what are not needed. As a solution small focusing interfaces (contracts) can be used: interface RegisterUser { User register(String username);...
3
votes
2answers
209 views

What design pattern best describes COM's queryInterface pattern?

In COM programming, each COM object exposes a queryInterface method. You provide it a type that you want to "cast" the COM object as, and if it supports it it'll return you a reference to ...
0
votes
0answers
48 views

Is gRPC a good choice for my scenario?

Im starting to develop a visually-simple but infrastructural-ly robust real time multiplayer game to show off my backend skills and hopefully get a job at Blizzard or something like that. The game is ...
0
votes
0answers
32 views

Multitenancy - Multischema DB and should we handle by individual microservice basis?

I am looking into the revamping my organization's application by moving from a monolithic into a microservice-architecture. My database is a multi-schema shared in one database. Each of these schemas ...
4
votes
3answers
387 views

Is this extensive usage of closure a known (anti-)pattern? And does it have a name?

I often use function closures for storing data (e.g. database URL), which doesn't change between function calls. Is this an (anti-)pattern? Does it have a name? While developing apps, which recieve ...
1
vote
4answers
207 views

Pattern / solution for Boolean decision making chains

I need a solution for decision making chain. There are number of criteria that may return true, false or be inconclusive. A non-functional code (Java) would look like this: Boolean res = ...
0
votes
1answer
64 views

Versioning of data handling pipeline elements

I have developed a custom-made Python package, which provides 2 classes to play with: Stage and Step. They operate based on a Chain of Responsibility design pattern, and behave in a way where: Both ...
2
votes
0answers
33 views

Designing a filtering function

This question is not so much about how to implement a solution as I've already implemented a working solution, but more about how to improve how I implemented it. The implementation process of the ...
1
vote
2answers
145 views

Composition vs Aggregation: is this a “hidden my dependencies” case?

I have been thinking about this for a while and could not get to a conclusion. I need to convert a object to another (that will end up serialized as XML). Both objects have many fields, let's have an ...
1
vote
1answer
81 views

Why would I use the proxy instead of direct call to RealSubject?

I'm actually reading about the Proxy design pattern (https://refactoring.guru/design-patterns/proxy) and I'm wondering about what does prevent the Client to call directly the RealSubject class. I give ...
4
votes
3answers
257 views

Should the DTO be able to parse itself from and to Domain?

Let's say there's the class Book, with different models in different endpoints: Endpoint A (consumer): class Book{ Map<string,string> chapterName_content } Endpoint B (provider): class Book{ ...
-4
votes
1answer
34 views

Small scale document management system architecture / patterns

Im usually working with line of business desktop software. Mostly based on a single database. Pretty often one of the requirements is to keep track of some files. Or the only way to implement a ...
0
votes
1answer
47 views

Pubsub model - publisher broadcast to remote subscribers

With a single publisher(go-routine) and multiple subscribers(go-routine) on same machine, below message hub help create pubsub model: type PublisherHub struct { subscribers map[*subscribmediator....
0
votes
1answer
128 views

Modular code how do they really fit together?

Let's say I am developing an ecommerce application. And I have modules organized in certain way. Products Coupon Tag (can be used as brands and linked data) Offer Now what I want to achieve is user ...
-1
votes
1answer
87 views

Refactoring: Pythonic way of reducing the subclasses?

background: so, I am working on an NLP problem. where I need to extract different types of features based on different types of context from text documents. and I currently have a setup where there is ...
0
votes
1answer
94 views

How does a database update trigger a notification to application layer?

Application component 1(ap1) record/insert/update a new state in graph database(neo4j) For every new state change in the database, application component 2(ap2) needs to be informed/notified that a new ...
0
votes
1answer
58 views

design pattern for ensuring that a container object has at most one instance of an editor

My application (VSTO/C#) handles excel files editing some cells and inserting some rows. My problem is more generlaized than this though, and is about defensive coding the class that acts as edtior. ...
0
votes
1answer
97 views

Can I enforce “functional core, imperative” shell with a framework?

The design pattern known as "functional core, imperative shell" is about separating side-effects from pure calculations, where business logic is supposed to be pure and then coordinated by ...
-1
votes
1answer
43 views

Efficiently keep different data structures synchronised - tree, list of objects

Problem description I have a pet project to translate TEI XML to standoff JSON and back: https://github.com/standoff-nlp/standoffconverter and I am currently thinking about a rewrite/restructuring. ...
1
vote
0answers
27 views

Orchestrator or coordination pattern in Azure?

I am designing a background web job in Azure that, given a list of users it retrieves from a database, makes calls to a separate messaging microservice (for each record) that will end up sending N ...
0
votes
2answers
100 views

What is it called when you assign a new instance to another class property?

Example Code class HumanEye { wink() {...} close() {...} } class Human { eye = new HumanEye(); } Example Usage var jose = new Human(); jose.eye.wink(); jose.eye.close(); My understanding ...
2
votes
2answers
111 views

Can Object pool design pattern cause memory shortage?

When I am using the Object pool design pattern, and allowing the pool to grow, by creating new objects when they are required but not available in the pool, and placing them in the pool after they ...
-5
votes
3answers
93 views

What is the best way to learn design patterns as a student

I am a student who currently learning design patterns. One of the major problems I faced when I started learning design patterns is forgetting the pattern immediately. Even though its crystal clear ...
4
votes
3answers
322 views

What are the pros and cons of using a reference/pointer vs an ID

I'm writing in C++, but this problem applies to any language without GC and even to languages with a GC as well. I have a structure in memory in which I create/add objects. The structure takes ...
0
votes
1answer
111 views

Have the same logic in two different class hierarchies

I have the following class hierarchies abstract class Base<T> { abstract T getRelevantType(); } class A : Base<AType> { AType getRelevantType() } class B : Base<...
-2
votes
1answer
95 views

Patterns for multi tenant systems [closed]

Ok so first I want to describe the anti-pattern anti-practice. Company creates system for customer number 1. Then customer number 2 comes along they fork the codebase customize it. (Say for variations ...
0
votes
0answers
28 views

Multiple external API calls and only one valid response depends on the parameters value

In my microservice I need to call several external API. The problem is that I do not know which of them to call to get a proper response, but I am sure that one of them return a successful response. I ...
0
votes
1answer
136 views

Discount calculation pattern

I am implementing a discount calculation model. One item PER order. I do have a Product class: public class Product { public string Name { get; set; } public Size Size { get; set; } public ...
1
vote
0answers
56 views

What is a good design for accumulating temporary data stemming from several processing runs?

I would like to compute cycle times for some manipulator movements. These movements consist of different phases. I have a class that models these phases and this is its constructor to give an idea: /**...
0
votes
2answers
38 views

Should my DenyQueryException extend a exception in a DAOException or Exception

need some advice...I am fully aware that Validation/Syntax Checking, etc. should happen above the Data Access Layer. However the powers that be would like the DAOs to do an extra check. Should when ...
0
votes
2answers
119 views

Should I declare motivation when commenting? [duplicate]

When commenting code, which of the two approaches considered good practice? Explain the content of the code, "translate" it to human - readable language, but not provide any explanation ...
-2
votes
1answer
44 views

Inheritance and domain-specific logic loses its independency?

Im sorry in forward, Im sure I wont be able to express myself well. Its a game system: abstract class GameType { private $score; public __constructor($score) { $this->score = $...
0
votes
1answer
151 views

Is it ok to Inject a whole object instead of only the dependencies

I'm working with the Dependency Injection Pattern in Unity3D (an engine which uses MonoBehavior, a class that doesn't have a constructor, as the base class for all of its game components), and I ended ...
-2
votes
1answer
56 views

Unexpected shutdown before a saga completion

Suppose we have some microservices and a saga will run to do a transaction in 6 microservices. What if the whole system dies(unexpected shutdown), on middle of saga process in the step number 4?(...
4
votes
5answers
228 views

How to fix a pair of tightly coupled classes that store references to each other?

I have the following situation: class User { public Thing curThing; } //each thing can only belong to one user at a time //And vice versa class Thing { ...
-1
votes
1answer
60 views

Making a GUI for receiving/checking user input - how to arrange GUI and validation checks

Sorry if my question sounds general, I'm new to GUI and frontend/backend ideas and all that (mostly I just do scripts for math hw and such) but I make it more specific here. I have a program that runs ...
39
votes
1answer
3k views

How to design a REST API that can “prompt” the client about long-running operations?

Say you were to develop a REST API that provides access to a set of complex, long-running, operations. The typical paradigm for an API like this (as I understand it) usually involves (the client) ...
2
votes
2answers
114 views

Should base class include unused properties of sub class?

I was looking at the angular documentation and noticed this code: export class QuestionBase<T> { value: T; key: string; label: string; required: boolean; order: number; controlType: ...

1
2 3 4 5
79