Questions tagged [design-patterns]
A design pattern is a general reusable solution to a commonly occurring problem in software design.
294
questions with no upvoted or accepted answers
7
votes
3
answers
1k
views
Balance between aggregate boundaries and domain consistency in DDD
Designing an Aggregate and choosing an Aggregate Root getting tricky for me all the time especially when it comes to ensuring right transactional contexts and consistency constraints so I'm wondering ...
6
votes
2
answers
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. ...
5
votes
2
answers
1k
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, ...
5
votes
0
answers
6k
views
Assembler vs Entity Translator and Entities vs DTO
I was hoping that someone could explain the exact difference between an Assembler and Entity Translator.
Martin Fowler describes the Assembler as a sort of Mapper(?) which converts DTOs into Domain ...
4
votes
0
answers
135
views
Global variables and common block management in Fortran
Background
The high level overview of my situation is described here. I am breaking it apart into smaller, specific questions, such as this one, regarding extensive use of global variables in a ...
4
votes
1
answer
245
views
Dynamic Object Abilities When Saving State
I have n classes that extends from a State class, the purpose of the State class is to manage the state of the extended classes. For each class we need to save it in the database, remove it and select ...
4
votes
0
answers
292
views
Best design pattern/approach for a Factory which needs multiple types of input
I want to develop a Factory of INotifications.
public interface INotification
{
string Text { get; }
string UserId { get; }
NotificationType NotificationType { get; }
}
The problem is, ...
4
votes
3
answers
538
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
0
answers
466
views
Separate settings and implementation class hierarchies
We use XML serialization to store class settings. Each setting-class has (but doesn't reference) corresponding implementation-class. Therefore we can easily make a "settings dll" without any ...
4
votes
0
answers
134
views
Environment that enables variable constraint checking and creation
Currently, I'm working on a system that enables users to add Tag's to available TagTypes on specific pages. For instance, we would have a TagType called "Installer" and the user wants his name ...
4
votes
3
answers
517
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 ...
3
votes
0
answers
82
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
0
answers
198
views
Efficient BACnet device polling strategy
Example BACnet network:
Some help is needed to solve a problem around architecting an efficient method of polling BACnet devices across multiple networks (i.e. MS/TP networks) where client software ...
3
votes
3
answers
917
views
Do I use Repository or Service Object to Perform Logging?
I'm working in Java Spring, and I have typical service and repository layers. The repository grabs a JSON; passes it along to the service; service maps the repository response to a DTO.
I also need ...
3
votes
1
answer
727
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
0
answers
114
views
How should domain model entities expose information about the current state of their properties?
I'm new to DDD, so please bear with me.
I am trying to design a domain model around an extremely large and complex existing system, where most of the current "domain" logic is either in the UI or in ...
3
votes
1
answer
208
views
Data processing pipeline design for processing data
I have a use case for which I need to build a data processing pipeline
Customer contact leads data coming from different data sources like csv, data base, api has to be first mapped to a universal ...
3
votes
0
answers
109
views
Python3: How to change the design of a class hierarchy to improve access to objects there buried?
I asked this question already at stackoverflow together with a serialization related part and at codereview for the design part only. Since the design related part receives no answers or comments on ...
3
votes
0
answers
64
views
How does "redux" decouple the different components so they can be tested separately in unit tests?
In the past we saw a big move from traditional MVC to MVVM for user interfaces:
One of the primary motivations for MVVM is that the view and viemmodel are competely indepedently of each other and ...
3
votes
0
answers
76
views
Memento and releasing resources
Let's suppose we have a class whose state has to be saved and later restored, and we resorted to the Memento pattern for that.
What if the state includes resources that have to be explicitly ...
3
votes
0
answers
53
views
Parse track meet output file result
I am building out a parser for a well-known track & field meet management software output file (sample output).
I can parse this manually, and put items into my object model (overview below), but ...
3
votes
0
answers
399
views
How to separate data layer from business layer?
My current .NET project looks like below:
Solution (.sln)
--BusinessProject A (.proj)
--BusinessProject B (.proj)
--DataLayer (.proj)
--A separate project calling ExternalService 1 (folder)
--A ...
3
votes
0
answers
643
views
Fetch data in parent vs fetching data in child
I know that I want to develop a React App like so:
<PhotoPage>
<FeedFilter/>
<PhotoFeed/>
</PhotoPage>
Without using Redux, I know that I need to fetch a dataset of ...
3
votes
0
answers
91
views
Nested containers with subclasses
I have nested containers A and B. The attributes are there to show that classes have some other members. One of my functions f takes another container of such containers (let's say vector again).
...
3
votes
1
answer
329
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 ...
3
votes
0
answers
2k
views
Dependency Injection and class Inheritance
The project I am working on for about a year now was used to create a new mysqli connection to the database each time there was a Query to the database. In order to quickfix this problem at places ...
3
votes
0
answers
691
views
Two-way adapters
In GoF there is a two way adapter concept:
A potential problem with adapters is that they aren't transparent to
all clients. An adapted object no longer conforms to the Adaptee
interface, so ...
3
votes
0
answers
321
views
Anemic Domain Model Developer thinking about a rich domain model
Martin Fowler talks about the Domain Model where the Business Logic Layer contains classes that contain state and behaviour. As far as I am concerned this means:
1) Controller calls a class in the ...
3
votes
0
answers
483
views
Mocking third party web service
I am working on a project to create a wrapper library which will be used to interact with a web service provided by the client's IT team. The reason for this library is that we interact with this ...
3
votes
0
answers
2k
views
Multiple inheritance in ASP.NET MVC Controller
In one case BaseWizardController should implement background functionality of BaseController->BaseConsumerController, in other case it should implement only BaseController.
Any ideas how can I do ...
3
votes
0
answers
694
views
Building a generalized notification system: passive vs. active
Recently, I've tried my hand at building a notification system, but I quickly found that notifications are tricky things, especially in the context of building a general model. The diversity of what ...
3
votes
0
answers
70
views
Should my application call statsd directly or should I call statsd based off logs?
I'm planning on incrementing counters in statsd based of various events within my application. I have logging in place for these events. So, from my viewpoint I have two options:
Update the ...
3
votes
0
answers
633
views
Hierarchical ViewModels and tracking IsDirty/PropertyChanged events
I have a set of ViewModels depicted like in the below picture.
And, I have a couple of commands AcceptCommand, CancelCommand in the Top Level View Model that are bound to Apply, Cancel buttons ...
3
votes
0
answers
983
views
ZeroMQ and Majordomo protocol
I am learning ZeroMQ and came across the Majordomo Protocol. I am wondering if I'm understanding this correctly, is the use case the same as.. for example.. the Microsoft Azure AppFabric service? ...
3
votes
0
answers
532
views
How can I put multiple hierarchical forms in a single web page and avoid making it a mess?
We are a group of developers working on a web application that accepts forms filled and sent by our users and present it in an overall view. Our main form view looks like this:
There are multiple ...
3
votes
0
answers
89
views
Pattern for data types that are related yet fundamentally different in utility
Background
I'm currently working on a codebase for what is to become a forthcoming website's content "engine", where it will take in different types of standardized data (implemented with XML), parse ...
3
votes
0
answers
38
views
PaypalCheckout object is composed of PaypalQuery objects. Hide PaypalQuery objects to users of PaypalCheckout?
I have a PaypalCheckout object that handles the checkout process: from initiating API calls, to providing an interface for front-end code (e.g. View/Controller).
The PaypalCheckout object handles: ...
3
votes
0
answers
256
views
Looking for design pattern to represent shared state in music sequencer
I like to give lots of context, but also to state the basic question up top as concisely as possible. Feel free to read a little or a lot.
I'm working on a music sequencer, and have been happy so far ...
3
votes
1
answer
132
views
How to model workflows
I'm building a helpdesk-type system, where there are:
Customer - can submit/resubmit tickets;
Manager - can review submitted tickets, assign to developers (one ticket to multiple developers), review ...
3
votes
1
answer
189
views
Message Mapper Design Considerations
Long question context, skip to tl;dr for the meat of it.
I am designing an integration between two web applications, and have come to the conclusion that a message pattern would be an appropriate ...
2
votes
1
answer
119
views
Best way to refactor service with too many dependencies
We are creating the backend for a web app using a sort of layered architecture. The service layer is supposed to handle the business logic and passing data to the repositories. This service layer is ...
2
votes
2
answers
263
views
Design of a modular application
I'm developing an application (Java) in a modular architecture. I have two approaches in mind and I'm not sure which one will be "better code" in case of maintenance and conventions.
I have ...
2
votes
2
answers
90
views
Design pattern to create a shared lib architecture
I am making a renderer as a hobby, one thing I thought to try is making the low levelAPI be dynamically swappable, i.e. you could have an opengl or vulkan backend and switch between the two without ...
2
votes
0
answers
92
views
Is there an elegant way to handle run-time dependent object composition without using dynamic_cast?
Context
I'm attempting to design a modelling framework that is modular and easy to extend and test. (I'm trying to follow open/closed, dependency injection, and composition over inheritence principles)...
2
votes
2
answers
208
views
Exposing methods for polymorphic children from the aggregate root
Consider the following fictitious toy example:
There is an aggregate root DayChecklist that holds a list of Tasks planned for the day:
class DayChecklist {
String id;
DateTime today;
...
...
2
votes
0
answers
193
views
How to handle a bunch of nested ValueObjects?
I'm writing a PHP web application (or actually a Symfony module). One part of it is a nested structure of ValueObjects (meaning: they are immutable and have to be validated on the creating). Such an ...
2
votes
0
answers
1k
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 ...
2
votes
2
answers
527
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
0
answers
122
views
Design Pattern to unify similar generated classes
I have a project where I work with generated classes for some web interfaces. Some of these classes are (almost) identical and most of the functionality I need them for only use the identical parts. ...
2
votes
0
answers
363
views
Third-party API wrapper in Java: how to design
Suppose, there's a site that provides an API, such as this:
Users post questions, answers on that site
You can make GET and
POST calls
There are two types of authentication: weak (only gives
read ...