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
2
votes
2answers
344 views

destroy object once it won't be used anymore in flyweight pattern

I want to use flyweight pattern to return the same instance of my object each time. public class ThingFactory { private static final HashMap<UUID, Thing> things = new HashMap<>(); ...
2
votes
5answers
276 views

Optimize non-trivial searches in vector of object pointers that share base class

I have an array that contains over 150,000+ object pointers of over 300+ different classes, but they all inherit from the same base class. Obviously that's very inefficient when we need to search for ...
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 ...
0
votes
1answer
82 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 } } ...
0
votes
2answers
207 views

How to design a wrapper for a large, multi-response API?

Lets say there exist some service at some organization that exposes information on a company's assets, from employees, company-issued devices (laptops and issues) to the the large xerox printers on ...
-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 ...
-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)...
0
votes
1answer
74 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
3answers
112 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 ...
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
vote
1answer
74 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
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
76 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 ...
10
votes
5answers
3k views

Can we completely replace inheritance using strategy pattern and dependency injection?

For example: var duckBehaviors = new Duckbehavior(); duckBehaviors.quackBehavior = new Quack(); duckBehaviors.flyBehavior = new FlyWithWings(); Duck mallardDuck = new Duck(DuckTypes.MallardDuck, ...
3
votes
1answer
479 views

Is Enum Polymorphism bad for DAO Methods?

I have been going back and forth in a discussion about polymorphic enums to call different DAO methods depending on enum entry, and I haven't been able to get a common agreement on this subject. Lets ...
-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 ...
-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
vote
1answer
846 views

Architecture for message processing with scheduling, at scale

I have to design the architecture of a system that processes messages in a distributed manner. If this were the only requirement, I would use a message queue like Kafka and distribute the work with ...
-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->...
-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 ...
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
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
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);...
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 ...
3
votes
1answer
224 views

How to handle errors from back-end in front-end and different languages?

I have a rest api and a reactjs front end, in some cases, the api will send an error to the front end and I need to display that error. My app will support multiple languages, so the error must be ...
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 ...
0
votes
1answer
150 views

Call library functions with varying number of inputs while keeping API simple

For a ASP.NET Core application, I'm using a library which performs calculations using objects that have a similar interface but their constructors use different inputs. The inputs are market prices ...
3
votes
1answer
279 views

How to set up a sql database to cater for user records, group records and default records?

Outline I have an application that loads data from a database. I'm not talking about client data here though, I'm talking about application configuration. The database will therefore come with some ...
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 ...
0
votes
2answers
80 views

How to implement a chain of events on a tree's CRUD operations?

I am working on a project in which I have a tree with 4 layers and the hierarchy is like this. Customer -> Site -> Location -> Guardroom In DB each entity has its own table and the child knows its ...
0
votes
2answers
135 views

Chain of responsibility or simple dependency injection for Querying API

I am working on refactoring a project code that is wired up in a tangled way. It was started with decent dependency injection and over time with all custom requirements it looks it got tangled up. ...
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 ...
1
vote
4answers
208 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 = ...
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 ...
3
votes
2answers
357 views

Designing a flexible search API response

Quick Summary I'm building a search micro-service that will allow searching across different types of resources in a particular system (e.g. blog posts, users etc.). The API that will be exposed will ...
4
votes
2answers
728 views

Handling common code among presenters

I'm facing some issues related to code duplication when following MVP architectural pattern in an Android project that I'm working with. My project structure is separated by packages: data, domain, ...
3
votes
3answers
427 views

Pattern for endpoint that routes requests?

I am building a service that will push notifications to many other services. It has a couple of different notification types that each consumer may care about, but likely will not care about all of ...
6
votes
2answers
2k views

Loose Coupling Presenter to View in MVP

We work in a Java shop here and our web application uses an implementation of the MVP architectural pattern. Our manager comes from a .NET world, where he has been exposed to the MVVM design pattern. ...
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
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 ...
9
votes
2answers
4k views

Observer pattern over HTTP and TCP/IP (Server-Client)

I have a server and many clients (around 50 clients) who connect to that server based on a web application, which is of course based on HTTP protocol, which in turn uses TCP/IP (correct me if I'm ...
0
votes
2answers
620 views

How should I manage user session in CLI application?

I'm developing a CLI based application. It has a "login" command to perform authentication: $ myapp login $ Type username: hector $ Type password: ***** $ Login success! Internally, myapp login ...
-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
59 views

Creating a internet gateway for bluetooth low energy device

I have a device that connect using Bluetooth Low Energy. I would like it to be able to communicate with a server over internet using a smartphone as a gateway. As I approach this I am coming up with ...
1
vote
1answer
54 views

Should the View pass data inserted from user to Controller or should the Controller get data from View's fields? (MVC Pattern)

My View has a textfield and a button. According to MVC pattern on button click should be called a function of the controller. This function should do some operation on the View's textfield content. It ...
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. ...
3
votes
1answer
54 views

Need technical advice about passing data through UINavigationController

First of all a small introduction, im relatively new to Swift and to programming in general, been doing it for the last year and loving every and each new thing of this vast world. My post is about ...

1
2 3 4 5
79