Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [design-patterns]

A design pattern is a general reusable solution to a commonly occurring problem in software design.

-1
votes
1answer
15 views

Node.js / Express.js - Route consisting almost entirely of middleware

Is it a bad design pattern / anti-pattern to create a whole bunch of specific middleware to replace functions in-route. So instead of doing this router.post('/myRoute', (req, res, next) => { ...
0
votes
2answers
45 views

Managing multiple dynamic database connections

I'm working on a server, which you can pass some form of authentication as input (like connection string) and it will connect you to your database. So the DB connection is going to be dynamic. There ...
0
votes
1answer
51 views

Is a JSON wrapper an adapter?

Please let me illustrate with a simple example. Suppose we have a Weather object: class Weather: def get_forecast(self, day, place): forecast = "code that calculates forecast" ...
0
votes
1answer
37 views

how to ensure consistency for concurrent requests for same mutable data?

Consider an abstract example, just to illustrate - you have a service for loans, which gets requests to borrow X USD, checks if there’s enough USD to lend that, if yes - marks that amount as reserved ...
5
votes
5answers
217 views

Design pattern for 2 methods one has 70% arguments of other one

I am trying to do a design for notification part in the system I have 2 parts inApp notification and email notification so I used strategy pattern where I have interface NotificationSender with one ...
1
vote
3answers
126 views

Builder pattern: How to verify required fields before runtime

A language agnostic approach since I see this problem in both compiled and interpreted languages with the builder pattern. Let's say I have a Model that has 10 required fields and 5 optional fields. ...
1
vote
4answers
149 views

Which layer should have responsibility for rounding numbers?

I am developing a financial system and want to have a defined policy for rounding monetary values. Given the following layers: View API Entity Model Persistence If I am passing a monetary value ...
0
votes
3answers
69 views

Design Pattern for object that asks questions of another object

I'm looking for a design pattern that might work for this class I am working with. This main class is an entity using Domain Driven Design. public class TimeCard() : ITimeCardHeader { ...
0
votes
2answers
64 views

Is this a proxy or bridge or something else?

I have an object that acts as a "bridge" between objects and I'm not really sure if it has a name. Unity (the game engine) lets me build a concrete object and then link those objects in the inspector ...
1
vote
1answer
137 views

Why read and write API are good or why not?

While designing a complex system some of my colleges came back with the idea of having two separates APIs, one that will perform the writes into de databases and another one that will only do the ...
1
vote
1answer
110 views

C# .Net Core API design - interfaces vs DTOs

I'm designing a relatively simple web application using .net core. I've mostly done desktop development in my career so far, so I'm a bit new to the nuances between desktop and web development. In ...
-1
votes
1answer
56 views

Patterns for loading related objects in memory (without an ORM)

I am using ADO.NET to read a bunch of data from the database into in-memory objects. This is my domain model: // Question.cs public class Question { public int ID { get; set; } public ...
-2
votes
0answers
13 views

Design Patterns & Strategies for a code library with many combinations of settings? [duplicate]

I'm not exactly an engineer. Just a recent graduate of a software development program. However, I am aware of software design patterns, such as the singleton, factory,dependency injection, etc. I am ...
0
votes
2answers
124 views

Force field initialize not by constructor in c++

My parent class has a vector field I want to force child classes to push in that vector as many as items they have. At least one item example: class Options { protected: vector<...
1
vote
0answers
41 views

When not to use View Services in MVVM design pattern?

I'm using the MVVM design pattern in my application which is comprised of, A Xamarin.IOs project (View Layer) A Net Standard project (Common Layer) A Xamarin.Android project (in the future) (View ...
2
votes
2answers
98 views

Design pattern for similar classes that require different implementations

Edited: Update is at the bottom There could be a common or best practice for this scenario, but I am unfamiliar with it. However, it could very easily be a matter of subjective opinion on how one ...
1
vote
0answers
17 views

Spring Boot and Mustache app separation of concerns

I am wondering how best to slice up a Java Mustache web app which has: Data layer (JPA, Repos, Entities, etc) Service layer getting data from other company web services outside the package Web/...
0
votes
1answer
91 views

Do I include system dependencies when calculating Instability?

Given the formula to calculate instability... I = (Ce / (Ca + Ce)) with Ce = outgoing dependencies, Ca = incoming dependencies, and I = Instability, ...should I include system dependencies (such as ...
0
votes
1answer
42 views

Should libraries be packaged together based on similar traits?

I just started a new job and one of my first tasks is to create local nuget packages from the existing libraries, to help with versioning, maintenance, etc. This task had already been started by ...
0
votes
1answer
30 views

Deleting a list of dependent OPbject using chain of Responsibility design pattern

my requirement is i want to delete a Object A A-> B-> C- here if you want to delete A you have to delete B which is dependent on B , then If you Want to Delete B you Have to Delete C which is ...
0
votes
1answer
60 views

Implementing a pattern for maintaining changes of an entity over time?

I'm designing a system that acts as a master data service for what I shall here call boxes. The system is to be implemented in Java with a relational database (SQL) as the main storage. Each box has a ...
2
votes
1answer
95 views

Design pattern for an indeterminate number and format of questions

In my application, I have a finite number of question types, but the order in which they're asked and whether they're asked at all is not known up-front. An example analogy is a hotel booking process,...
0
votes
1answer
80 views

Which is better solution - having separate model class against each REST API or keep adding info in single object?

I have a class Person. Person { String firstName; String lastName; String Date dob; String email; String mobileNumber; String address; } To add a person, I have following REST APIs: POST /...
0
votes
1answer
57 views

decorator pattern for generating complete html

I am trying to figure out the best way to decorate html. What I mean is replacing specific syntax string with the actual content. Kind of like, razor syntax in Asp.net MVC using <%= %>. ...
0
votes
2answers
87 views

DDD enforcing business rules

New to DDD I have a simple case a I would like to model using DDD approach 2 entities Student and Course Relevant property for Student are StudentId and Budget Relevant property for Course are ...
1
vote
3answers
125 views

Pitfalls of Domain-Driven Design with Entity Framework

A lot of tutorials on DDD I studied are mostly covering theory. They all have rudimentary code examples (Pluralsight and similar). On the web there are also attempts by a few people to create ...
-4
votes
0answers
27 views

How to create reusable component-like views in javafx (mvc)

I know how mvc works, and what belongs into the different parts, but I am pretty new to javafx. Let's use the simple tic-tac-toe game as an example. I would probably end up creating a MainView, ...
2
votes
1answer
80 views

Problem with business and data access layer design

I am creating a library to interact with third party api.This library will be wrapper around that third party library and i want to expose my wrapper methods to client(webapi,winform,console,mvc etc..)...
0
votes
1answer
35 views

Java Design for Data enrichment based on logic defined in a database

I have the following requirement. Read data from a messaging Queue and process each message to enrich the message and then finally send the enriched message to a different system. The enrichment ...
0
votes
5answers
134 views

Data only class, other classes that read/modify it?

I have a class that only holds data, specifically Collections of data, it is called *BezierSplineData: class BezierSplineData { public List<BezierSplineControlPoint> ControlPoints; // ...
0
votes
1answer
67 views

Onion Architecture - Multiple Apps

Onion Architecture talks about separating the UI, Service, and Data Layers. All the samples usually given for this involve a single deployment model of the application. For example in .net most of the ...
46
votes
3answers
7k views

Using a “Pass-through (God) Service” is bad, right? [duplicate]

My team has developed a new service layer in our application. They created a bunch of services that implement their interfaces (E.g., ICustomerService, IUserService, etc). That's pretty good so far. ...
-1
votes
2answers
58 views

Design Pattern to wrap a series of step

I'm already posting this question on StackOverflow, but thought that asking it in different communities might give me different insight. So here's the repost of the question: Hello, I'm having a ...
2
votes
3answers
88 views

Reconciling MVC with a strategy pattern

I am working on a Rails application which employs a classic MVC as its fundamental structure. In that structure the controller is supposed to be responsible for "which view to render when". Now after ...
1
vote
0answers
29 views

What should be the code architecture to download and cache offline data (Images/Videos/3d Models)?

I'm developing an application which has a 3D room. Each room is a 3d model and can contain media boards. each media board contains image(s) as slides or video. I have created following Data Models : ...
1
vote
2answers
45 views

Pattern or framework for resolving simultaneous inputs

I am tracking the position of characters on a 2D grid (this is a computer game). At every step each character can attempt to move (stationary, up, down, left, or right). There are some rules that ...
0
votes
1answer
49 views

Using the adapter design pattern for a news application microservice

I am currently developing the backend for a news application, which fetches news from various aggregators (e.g. Feedly). I thought this qualified as a good use case for the adapter design pattern, so ...
0
votes
1answer
47 views

Pseudo-Factory Abstract Class

So I have a requirement for something like this: The client shouldn't be aware of how the actual classes are implemented or constructed. The classes implement a common interface So I used Factory ...
2
votes
4answers
130 views

Is Implementation class exposure fine in Dependency Inversion

Basically we should depend on abstractions instead of concrete classes, that's the Dependency Inversion main principle. interface ITest { void DoSomething(); } class TestImpl : ITest { ...
1
vote
2answers
56 views

Building a plugins-based code in Python

I have a program which perform different actions depending on the plugins that are passed. For example, python main.py -m foo -m bar will perform the actions of foo and bar. The structure of the ...
1
vote
1answer
56 views

Functionality design: Multiple sources, multiple consumers with configuration

It is a Design Problem which I am listing out here. I have multiple event sources in my app, each one produces events with the different set of data (but each source is producing only one type of ...
1
vote
2answers
92 views

Avoid mutable field in event handler

I have an event handler that creates objects for which it needs data from both before and after an event. The event handler itself implements Selenium's WebDriverEventListener interface and gets ...
2
votes
3answers
119 views

How to store objects with inconsistant properties

I have real-world materials that are defined by various properties, some common, some not, that I would like to map to objects in C#. For example, Concrete has properties A, B, C, and Metal has ...
1
vote
3answers
175 views

Intent of Command pattern?

In Elements of Reusable Object Oriented software by Erich Gamma, the intent for Command design pattern says: Encapsulate a request as an object, thereby letting you parameterize clients with ...
10
votes
1answer
210 views

Using friend classes to encapsulate private member functions in C++ - good practice or abuse?

So I noticed it's possible to avoid putting private functions in headers by doing something like this: // In file pred_list.h: class PredicateList { int somePrivateField; ...
3
votes
3answers
93 views

Opposite pattern of Template Method

Do we have pattern, which is opposite to Template Method? I mean, in base class we define parts of algorithm and abstract method which implements algorithm. Then in derived class, in that abstract ...
2
votes
1answer
65 views

How to propagate Setting Class throughout entire project

Here's my setup: Entity Framework Backend Large WPF project that has a main window with 3-4 user controls on it, each of which has 3-4 user controls on it (and so on, in some cases) What I currently ...
7
votes
4answers
215 views

Improved design for a turn-based multiplayer game using AI?

I'm trying to decide which is the best architecture for a turn-based multiplayer game where the players can be either humans or AI and the UI is optional, for instance because the game can just be ...
0
votes
2answers
44 views

Methods taking parameter of Collection should filter the collection themselves or be passed a filtered collection?

Say I have this reasonable contrived situation: public class Toast { public bool Toasted { get; set; } public int MinutesToHeat { get; set;} } public class Toaster ...
3
votes
1answer
46 views

Handling field masks on the statically typed client

Let's say I have a REST API, that has the ability to provide field mask (i.e. the API can return M out of N attributes where M is a subset of N). If a statically typed client (example: one that's ...