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
vote
1answer
67 views

Building object with arbitrary functionalities

I am trying to look for the right design pattern for the below scenario. I am trying to create an object/binary with different modules, a module is a functionality that I want to provide to that ...
2
votes
0answers
57 views

Coupling form fields to functionality: using a Command Bus?

I built an app where the app owner can build custom forms for each of his clients. The forms have default fields like "name" and "message" as well as custom fields for each client requirement, like "...
3
votes
1answer
104 views

Is good or bad practice to share reporting modules between systems/apps?

At my new work, a few people want to share modules between systems/apps, and I'm a bit skeptical about it. Context: we have a lot of little apps living in different servers, some of them are ...
1
vote
2answers
285 views

Is having a general_code section a bad idea?

I'm working on a small python project and have a general_code.py file where I have functions that I use throughout the project. Some examples: def to_boolean(var): return var in ['True', 'true', ...
2
votes
3answers
506 views

What is the name of this pattern (if any)?

There's a sort of pattern that I've sort of stumbled myself into "discovering" that seems extremely useful, but I've never seen it described before. It's sort of a way of achieving inheritance through ...
6
votes
4answers
261 views

Passing around large value objects vs converting to smaller value objects

Let's say I have a project that needs to do the following: Multiple calls to read from the database where each call is a different query and returns back a value object (just has getters/setters). ...
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 ...
-1
votes
1answer
123 views

Separating common logic into an interface

I order to achieve the DRY principle I want a functionality that logs processing time of some other functionality for example for each group of classes with a Base class. So the most logical way is ...
0
votes
1answer
81 views

Evaluation of (a)synchronous design of ledger interface

I'm currently designing a ledger API, that should work with different implementations (e.g. based on Blockchain, traditional databases, or files). Its purpose is to add/get messages to/from a ...
1
vote
3answers
169 views

Is the Factory pattern good for this situation?

Im developping for my company a software where clients can requests app deployements and upgrades. Each request has 3 status (Validated, Started and closed). For every type of request (deployment ...
4
votes
1answer
158 views

Alternative to Reflection

I will directly come to our current working flow so that you can understand the problem in a clear picture. I am attached in Laboratory Automation System in which Analyzer (a machine that performs ...
-1
votes
2answers
161 views

What design pattern(s) would provide a better solution to this problem?

I have a document object and a list of operations that can be applied to that document in sequence. The types of operations are known in advance, but not their parameters, the order of operations or ...
5
votes
3answers
139 views

Process an undefined number of class states

Let's say I have an entity Foo. That entity could have a 5 states: A, B, C, D, E(in real application number of statuses can be larger). I store that entity in a database and map it to class. Every day ...
2
votes
1answer
80 views

Configurable sorting strategies

I need to be able to sort an object by multiple conditions, and these sorts need to be configurable from the application.properties file (as in it should be possible to specify in the file the sorts ...
3
votes
0answers
990 views

Unit Of Work with multiple database context

I have created an application (net core 2 & ef core) with Unit Of Work and Generic repository pattern. I used to have one database context but due to some business logic I had to create a second ...
1
vote
2answers
66 views

Factories and event binding

Factories are used to create objects. I was wondering if it's against the purpose of a factory, if I would bind couple of objects together in the factory. Let me illustrate this with an example. Let'...
0
votes
1answer
99 views

Guidance for Client side

We have created software for Rugged and mobile devices, and it gets deployed on the device. Admin has a provision to send an update to those devices. We use GCM or WNS for sending a notification to ...
0
votes
1answer
67 views

Design Pattern for Classifying a set of Data

I am working on some legacy code that involves Orders placed by Customers. There is a new requirement to classify each Order by Business Unit. The Business Unit Name will be stored in a new column on ...
1
vote
3answers
134 views

Is it ever a good idea to have classes intermixed/reliant on helper classes? C#

I have a simple class that has a private field and a public property. The property also calls a static helper method which it is kinda dependant on and i feel this might not be a good thing. This is ...
0
votes
0answers
56 views

Factory methods for converting one tree of objects to another

I have a tree of objects that I need to convert to a similar (but not isomorphic) tree of other objects and the creation logic is quite complex. The object types are in a hierarchy where only the ...
2
votes
3answers
100 views

How to build rest calls dynamically to interface with different APIs?

Lets say I am building an application where clients can book bus tickets. The only thing they do is select, origin, destination and the type of service (express or standard). The system will then book ...
1
vote
3answers
160 views

When implementing new features that are similar to other features, do you make the older features more generic?

This may come off as a bit confusing, but it's a question that I keep finding myself asking as I pile on more and more responsibility to older systems and features that I designed previously. Trying ...
0
votes
3answers
108 views

Stop a process for human control if some score is reached (Screening System)

Say I have a blogging system. Users can create posts that will get automatically published unless some score is reached. So when users save a post, we do some calculations and add up some numbers ...
0
votes
0answers
95 views

How can I gracefully handle this addition of animation?

I have the following setup in a GUI library I'm making (for fun). Ignore the colors and positions being integers, it's just to serve the purpose of illustration. // Example program #include <...
3
votes
2answers
172 views

Name of this pattern

I create an object that holds the status of a job. The job has many stages, some concurrent. Worker threads constantly monitor the status object to see if it's ready for the next stage to begin, if it ...
4
votes
2answers
112 views

How would you go about designing a structured log pattern for systems?

My web app generate log entries on hooks such as model.save. Right now, I have a class Entry (representing a log entry) with a string field content to contain the text of the log entry. Examples of ...
0
votes
0answers
39 views

How do I abstract out HttpResponse creation but still allow for custom status codes

I have build a custom back-end in NodeJs using the chain of responsibility pattern so that the system can easily be extended to handle new kinds of requests without modifying existing RequestHandlers. ...
-1
votes
1answer
114 views

MVC / MVVM principles

I'm currently working on updating some old projects (inherited stuff) and I keep running into various small issues with the architecture. Namely monolithic classes too tightly coupled. One example ...
1
vote
1answer
235 views

Is it okay to transport a DTO inside of a DTO?

Let's suppose we have to entities, X and Y where Y is part of X, being this: class X { private int fooX; private List<Y> fooY; } class Y { private long barX; private int ...
0
votes
2answers
171 views

Is this Singleton-like design pattern a feasible framework to build on?

I am posting this question here after it having been determined to be "off-topic" for stackoverflow, and "too hypothetical" for codereview. I am experimenting with different singleton-style design ...
1
vote
0answers
79 views

What Design Pattern to use to render PDF pages for a PDF Proposal?

I want to create a set of patterns to use for rendering a PDF Proposal (a set of PDF pages). I have made a good start, but not clear on how to proceed when more complexity is involved. I am using ...
3
votes
3answers
249 views

Abstract Parent and Inheritance vs. Strategy Pattern and Composition

I'm currently refactoring a class that looks (after some refactoring and very much simplified) somewhat like this: class Foo { public: Foo(bool someFlag) : m_flag(someFlag) { }; void ...
4
votes
6answers
271 views

What pattern can be used instead of these if statements in starbuzz (head first design patterns-Decorator pattern)

Reading Head First Design Patterns. I came to the chapter 3, the Decorator Pattern, Decorator Pattern is very clear for me. but one of the "sharpen your pencil" Our friends at Starbuzz have ...
0
votes
1answer
79 views

How to properly wrap my data layer to communicate with business logic

I have an EF Core data layer and i want to wrap it around an interface to separte it from the business logic. Now the issue is that i am not sure i am doing it correctly. First, i was just using ...
3
votes
1answer
68 views

Auto-Initializable Objects Pattern

I'm working on a system where we consistently apply "patterns" or approaches such as Dependency Injection. I'd rather not expose the current underlying technology as not to get biased solutions, ...
5
votes
1answer
155 views

Approach for Constructing View Models in Complex MVVM Application

I'm struggling with the design in a WPF MVVM application. In a few courses I've taken, they say that having a lot of parameters in a constructor is a code smell, but they never address how to deal ...
2
votes
1answer
213 views

Multiple Facade Classes must be combined in 1 Facade Class

Is this some rule that if I have multiple Facade classes they must be combined in 1 Facade Class? For example, I have a Hospital System with different classes, like Appointment, Patient, Doctor, ...
0
votes
0answers
64 views

Nested vs. Non-nested Types in GraphQL (or recursively-nested types)

I am starting to dive into GraphQL, and one thing I haven't been able to find a solid answer on is how and if one should use nested types or not, or even effective design patterns when using GraphQL. ...
1
vote
2answers
174 views

Calling a method with different parameters and iterate

I have a method that inserts into the Android Calendar an event. You can see a simplified snippet in two steps: 1)declare the variables 2) I put them into a kind of array that in the end will insert ...
-1
votes
1answer
42 views

Is it good practice to use data API for access cross platform

All, Question: Should I have a common data access API between various cross platform applications or keep the data access specific to the UI even though it would result in duplication? Background: ...
1
vote
2answers
93 views

Practices for encapsulating collections in aggregate roots

How exactly should AddSomething methods in aggregate roots look like? Should I construct the objects in a call to the method, or should they be constructed inside the method?: For example: public ...
1
vote
3answers
376 views

Is an OS kernel a singleton?

In my understanding, a singleton design pattern is where we have only one instance of an object in a system. I am not sure on this part of the definition, but I believe in an OS there is only one ...
1
vote
1answer
107 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) ...
3
votes
1answer
64 views

View-model architecture

I have two screens: A screen with a list of items, where every item in the list has "Show Details" and "Update buttons" An item details screen. The "Show Details" button navigates to item details ...
4
votes
2answers
340 views

Why do I need a game loop with states, instead of init the next state in current state directly?

For example, it is common to see games with game loop and states: stateChanged(){ switch(state){ STATE.PLAYER_SELECT_CHARACTER: this.currentController=new PlayerSelectCharacterController()...
5
votes
4answers
1k views

C# has no friend class - what are better options

I return to this question every couple of years, so now i decided to solve it once and for all, by asking here. So, the sequence: I'm writing a simple application that parses Json file (...
2
votes
1answer
71 views

How do I refactor a graph service to where I can encapsulate if/then/else statements?

I have a graph service where I use if/then/else statements. class GraphService { function getGraphData(array $products) { foreach ($products as $products) { $...
2
votes
2answers
191 views

Which design pattern for combination of objects in Java?

I am looking for the best approach to design the following system : I have a class of object, called Compilers (C, Go..Etc) I have another class of object, called Protocols (HTTP, RPC, WEBSOCKET..Etc)...
2
votes
3answers
192 views

Passing a context object to the constructor or to the method

I am writing a recursive descent parser. Let ParseContext specifies the context for parsing. Pseudocode: class ParseContext { Logger logger; // logger for error/warning messages Locale ...
1
vote
2answers
291 views

How should the service layer be done?

so I have this android app at work, if I understand it right the DAO/services/UI layers is to "decouple" the UI from the database. I have 2 problems with that : 1/ Decoupling Like this if things ...