Questions tagged [design-patterns]
A design pattern is a general reusable solution to a commonly occurring problem in software design.
4,519 questions
1
vote
1
answer
487
views
How can one combine two system architectures, say client-server and repository architecture?
I have a situation where I think it would be best to combine two architectures but I am not sure if this is possible or that it is a good thing to do.
By combining them I mean taking certain parts of ...
1
vote
0
answers
124
views
Splitting an object's state into multiple objects
I'm writing a virtual CPU, and I decided to create a class for each command, to make it easier to replace/add/remove commands without changing too much.
The original idea was that ICommand would be ...
0
votes
2
answers
466
views
Which strategy to use to create object instances
I have this use case (I've simplified it):
Each student can apply for one or multiple activities. As of now we only have Swimming activity onboarded on the system, but we expect to have more. Base ...
2
votes
2
answers
333
views
What is the best way to compartmentalize complex logic problems?
I am working on a problem with lots of if-then-else calculations. I am trying to compartmentalize the logic to make it more maintainable and less error prone. But, as I try options, I don't see what ...
-2
votes
1
answer
225
views
Are there real examples of using reflection design pattern to achieve partial deployment? [closed]
This site mentions such thing: http://software-pattern.org/Reflection. It says that it is possible to replace part of the application behaviour dynamically. Does it mean that we can achieve partial ...
2
votes
2
answers
359
views
"Returns true if changed" pattern [closed]
The Collection interface in Java has, among others, these methods:
boolean add(E e)
boolean addAll(Collection<? extends E> c)
boolean remove(Object o)
boolean removeAll(Collection<?> c)
...
1
vote
3
answers
2k
views
Storing count of child rows in parent table
I have two tables, parent and child. Parents can "have" multiple children—in our case they are related through a third table, parent_child_mapping rather than the child storing its parent id ...
1
vote
2
answers
405
views
Maintainably converting flowchart ideas to an architecture
My team is communicating proposals for the interaction of several processes as a flowchart. I've been drafting a codebase architecture we can use as a starting point. There are two ways intended ...
0
votes
1
answer
74
views
Design a non replayable endpoint for a service
I am trying something out in Springboot and stuck with a weird issue where I want to send some data from my frontend (react app) to backend (SpringBoot) and make that request non replay able by users (...
2
votes
2
answers
536
views
Should you create your own Interface for all (most/many) Api Calls? (Adapter)
I am currently reading Clean Code by Robert C. Martin and in Chapter 8: Boundaries one can find this paragraph:
We wanted to tell the transmitter something like this:
Key the transmitter on the ...
2
votes
2
answers
602
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 ...
5
votes
2
answers
737
views
Permission Design - Allow/Deny vs Allow Only
I've come onto a new a project and the permissions are done with an allow and a deny option for every permission. Until now i've only ever seen/build allow only permissions.
What is the advantage of ...
2
votes
3
answers
393
views
Use abstract factory (or an alternative way) to produce an instance of a subclass?
Context for this question
I'm currently working with small data storage media (e.g. RFID tags) that contain some fixed number of bytes that can be manipulated. The drivers that allow reading bytes ...
1
vote
1
answer
787
views
Builder design pattern when creating object between many layers
I stumbled on following problem, and I'm curious if it could be done better.
A while ago I wrote a factory class that looked something like this:
public class Foo
{
private IDbContext ...
5
votes
1
answer
213
views
How can I create a workflow for physical unit safety in Python?
I work for an engineering firm which builds most of our physics models in Excel with VBA. For myself and many other younger mechanical engineers in the company, this is not a good solution - we grew ...
0
votes
4
answers
674
views
Adapter or pure interfaces?
I got a bit strange 'future ready' scenario. And I'm not sure if I got it right in regards to C# adapter design pattern.
The scenario is that to be future ready, 'to use the adapter pattern' to easily ...
2
votes
4
answers
310
views
What is the middle ground between understanding basic OOP concepts (inheritance, composition, aggregation) and design/architectural patterns?
I've been coding in python for about 6 years now. I am proficient enough to understand a good amount of the language features. When I look into source code for a number of libraries such as pandas or ...
0
votes
3
answers
980
views
Composite Pattern get part of the tree
I use java and I have structure with a class that contains id, title and perhaps some children of the same class. So I decided to use the composite pattern.
I need to have a method getChildren() that ...
1
vote
1
answer
592
views
Hierarchical State Machines - Ortho Regions
I am rather unclear about how an event gets processed when a state machine has orthogonal regions. I did read that
With composite states, that an event should be sent to the innermost state, and if ...
-1
votes
1
answer
162
views
Design pattern for a task which involves subtasks [closed]
The task is, Given a list of files, for each file do some processing (sub-tasks) like encoding and encrypting.
In the following implementation, I used Composition where MultiFileProcessor uses ...
2
votes
1
answer
142
views
Proxy Pattern in Python
I'm reading a book on design patterns. On proxy pattern the code are following:
class SensitiveInfo:
def __init__(self):
self.users = ['nick', 'tom', 'ben', 'mike']
def read(self):
...
5
votes
3
answers
254
views
UML Composition parent association end
The Wikipedia article on the Composite Design Pattern includes the following diagram:
As you see, there is an association relationship which is child 0..* – 1 parent (association).
However, shouldn't ...
0
votes
2
answers
650
views
How to solve an issue when a decorator needs variables from the base class?
I have a service class that does some magic. I want to introduce a new type of functionality - raise an event. I am absolutely sure that decorator pattern is great for this scenario. The problem is ...
1
vote
2
answers
576
views
Difference between Front Controller and Mediator patterns [closed]
I was reading about these patterns and noticed that they seem to be basically the same, but in different contexts? If that's the case, why isn't Front Controller just considered as a Mediator pattern ...
2
votes
2
answers
147
views
Procedural configuration code to object oriented code
Lets say we have an Webserver-Framework and a Database-Framework, and now i want to configure that Webserver and the Database, then it could look like the following
class Start
{
public static ...