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.

5
votes
1answer
116 views

Optionally runtime properties

I’m looking for information on a pattern that I have used recently. The basic idea is that there is a type with a property that can either be compile-time (template parameter) or runtime (member). std:...
-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 ...
5
votes
3answers
711 views

How to avoid two step initialization (C++)?

I'd like to follow the RAII(resource acquisition is initialization) idiom throughout my code but I'm also doing the template pattern where I'm developing generic versions of my classes and using them ...
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 ...
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" ...
19
votes
6answers
17k views

Is it good practice to use entity objects as data transfer objects?

I am wondering because if it is, why does Entity Framework not offer logic to create a new object with the same properties to transfer data between layers? I use the entity objects that I generate ...
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 ...
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 ...
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. ...
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 ...
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 ...
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 { ...
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 ...
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
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 ...
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 ...
4
votes
1answer
191 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 ...
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 ...
-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 ...
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
3answers
1k views

What is this (anti?)pattern called? (or how to describe it)

The case where a source-level operator actually describes an operation to take place at some future point, thunking the real operator together with its operands. I don't know if this has any kind of ...
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 ...
1
vote
1answer
109 views

Which scenario is the best for service worker architecture?

We know about using service workers in modern web sites. Consider a scenario back-end as node.js and SQL Server. Data is loaded from central database to local customer web app (DB is about 700 MB) ...
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 ...
1
vote
1answer
90 views

Managing heterogeneous data

The underlying problem is one I seem to run into a lot. You have a collection of objects with some things in common, but other information about the objects may apply to some of them but not to others....
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 ...
0
votes
1answer
318 views

IOC principle - Servlet container implementation

IOC principle can be implemented, using either: Dependency Injection Service locator pattern This article also supports these two approaches for implementing IOC principle. Spring IOC container is ...
1
vote
1answer
50 views

Writing Event Process architecture for multiple event handler interfaces

I am working on Java program which will listen multiple kind of events from multiple sources and store information to multiple sinks. Each interface will have its own source to listen and own sink ...
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 ...
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 /...
3
votes
0answers
305 views

Is it good to pass variables through methods?

I am working on a team where my mates introduced the service & repository pattern. We work on Lumen micro framework. So from the controller, the call is passed to the service and then to the ...
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 ...
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 ...
3
votes
1answer
186 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 ...
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 <%= %>. ...
4
votes
1answer
322 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, ...
4
votes
3answers
343 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 ...
0
votes
1answer
50 views

Pattern for sequencing steps in a job to run sequentially against external system

I am trying to understand how I can make the code for this easy to understand and debug too. The reason I'm asking is that it feels like the kind of scenario which has probably been tackled before ...
0
votes
1answer
577 views

The finer points of HMVC

I'm new to HMVC and whilst tutorials are great about dealing with the overall details of keeping modules separate and only letting controllers communicate, they aren't so great at explaining the ...
3
votes
3answers
1k views

How to share the same behaviour in different classes?

I have a class called Process, which is extended by some different process types called ProcessA, ProcessB, etc. class Process{} class ProcessA extends Process{} class ProcessB extends Process{} //.....
2
votes
1answer
745 views

Is the Model in Spring MVC the same of MVC pattern?

Studying some in-depth concept of Spring framework, I'm facing this doubt. Has the Model, as inteded in Spring MVC, the same meaning of the M in MVC? I mean: I always considered the Model of the MVC ...
1
vote
2answers
604 views

How Design a program that must handle multiple “products” like in a production line

I have some problems figuring out how I should design an application. On a production line there multiple stations. The products will move from one station to the next. Each station will execute some ...
-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, ...
0
votes
1answer
124 views

MVP (Model-View-Presenter) Drawing Application

I'm trying to make a simple drawing application with the MVP pattern. Let's consider I want to be able to draw a circle and drag (move) the circle around on a JPanel. After the drag, the model should ...
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..)...