Questions tagged [design-patterns]

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

Filter by
Sorted by
Tagged with
4
votes
2answers
183 views

How to design a SOLID pipeline with different inputs

I regularly have the situation that I have some complex logic that I break into steps. For example an import of an Excel file where I need to apply some logic or a complex calculation that I break ...
0
votes
1answer
35 views

General question on Pairing of Abstract Factory with Bridge

I am trying to get myself familiarized with the design patterns and I am reading through this line on the relationships between different patterns. I cannot get my head around this one though, You ...
0
votes
3answers
134 views

OOD vs MVC; Live Objects vs Everything in Database

How to make memory-efficient code, but still have all the possible code nicely encapsulated ? I have a feeling that the OO (object oriented) approach is more intuitive and the code is nicely ...
1
vote
2answers
137 views

Repository pattern - using information from other repositories

I am trying to understand what is the proper approach when the objects generated from a Repository have a reference to objects which are responsible for another Repository. Let's say I have terminals ...
-3
votes
3answers
142 views

How can I merge between two software architectures in software design? [closed]

I need to know what types can be merged together like can I merge MVC and layered architecture? so please can someone list what types can be merged together, and an example on how to merge. Can I ...
-2
votes
1answer
40 views

What's the best way to output optional information to the screen of a console application, throughout the entire program?

I'm creating a console program where the user has the option of making the output more verbose when the system processes their requests. There will always be an output, but the verbose output would ...
-2
votes
1answer
114 views

Seeking a Pattern [closed]

First off, I totally understand that an interface cannot contain a static method because what would the method act on - that is clear. Suppose I want an interface to mandate a method that is ...
-1
votes
1answer
42 views

Design solution for updating different lists with common items

I needed some design suggestions for a tricky workflow we have to implement in our system: At a basic level the application allows users to work on a "list" of "items" she cares about To work on any ...
1
vote
1answer
62 views

Can a GoF Builder implementation be considered valid without an explicit getProduct()?

For studying purpose, I've tried to create a simple PHP implementation of Builder GoF (not the Joshua Bloch's one) inspired on this slide. The main goal of this example is to encapsulate the ...
-1
votes
2answers
120 views

How to use Dependency Injection on repositories in Generic Repository Pattern with base class inheritance

How to dependency inject repositories that inherit an abstract class (that inherits another abstract class) which implements the interface? I will give you a simplified version of my current ...
0
votes
3answers
86 views

Is this the return type covariance issue PHP faced when type declarations launched, violation of Liskov principle, or flaw in my pattern?

I've been using a somewhat odd yet effective pattern for a current use case. The one issue is that I'm getting an undefined method notice on a method that is unique to the subclass. The method of ...
3
votes
1answer
117 views

Is there a pattern for choosing one of a set of options at random when their selection criteria are equal?

I want to choose between several options, and if the criteria I'm using for selection happen to be equal, I want one at random (reasonably so, so it's equal-chance each time, rather than arbitrary). ...
-5
votes
2answers
85 views

How to design a terminal?

Good day everyone. I am planning to build a terminal, which will support common commands like ls, cd, cat, etc. But I am confused on how I should structure my codebase so that if in future, I decide ...
3
votes
1answer
83 views

Should a service object be transient or persistent?

In a typical server software design, business logic will generally invoke "services" (such as a database or web service). When I design such a system, I tend to think of each service as a singleton ...
-4
votes
1answer
41 views

Best way to structure reusable code using Node.JS, EJS, and front end JS?

I'm more or less learning the MEAN stack (have yet to start on Angular, so currently using straight vanilla JS for front-end) and part of what I'm building for my portfolio is a drag-and-drop form ...
3
votes
2answers
139 views

Refactoring for removing explicit object construction inside class

I'm wondering if there's a standardized name for the following refactoring: class Foo: def do_something_awesome(self): my_bar = Bar(42) return my_bar.reticulate_splines() Here class Foo is ...
2
votes
1answer
58 views

How to determine whether the postcondition of overridden methods is weaker or stronger if there is no return value?

To reiterate the question - what does it mean to have a weaker or stronger postcondition when overriding a method that only does side effects with another one that only does side effects? P.S. What ...
-1
votes
2answers
89 views

MVC who knows about whom?

In the Model-View-Controller pattern, I do understand the role of each component. The Model represents our application's domain model. The View presents this information and the controller ...
1
vote
0answers
54 views

Should class dependencies be organized in tree structure?

Is it doable, desirable to organize project classes, dependencies in Tree/DAG structure? To be more specific. In applications (not libraries) we have always some entry point, am I right? Some main ...
0
votes
1answer
99 views

Object Oriented Design of Callback Methods

Assume that there is a library and it provides an interface to its users in order to callback them. Users implement this interface and receive notifications from the library. Let's say, ICallback is ...
0
votes
1answer
48 views

Class Design question concerning adding a new “DRAFT” state to an object

We have some entities in our code: -"View" and View has some attributes and also contains one or many "SubViews" -And each "SubView" has some attributes and contains one or more "Tweet" entities. ...
2
votes
2answers
113 views

Algorithm for rule-based sorting?

I am trying to plant a garden. Certain plants are good for some plants and bad for others, and I am trying to find the best order of plants: most adjacent friends and no adjacent foes, as defined in ...
4
votes
3answers
161 views

Approach for updating status of a function

When I call a function, I want to receive updates when the function reaches some milestones: def do_something(): start_with_something() # update for x in iterate_something(): # ...
25
votes
6answers
5k views

How to structure commits when unit test requires refactoring

I'm trying to get a review for my lists of pros/cons about how to structure commits that came out of a discussion at my work. Here's the scenario: I have to add feature X to a legacy code base The ...
1
vote
0answers
42 views

Am I structuring this correctly for a .net mvc web app based on onion architecture?

]1 I am new to MVC. Most of my career I have used Web Forms in Asp.net. Reading about MVC has been really confusing because from what I have learnt is that in Traditional MVC, models were supposed to ...
0
votes
0answers
54 views

Use of SQL Server with DDD in ASP.Net Web App

Hi I need to develop a new web application for my company and I must use DDD as per my senior-dev requirement. In addition I'm maintaining (adding new features and fixing bugs) a large brownfield web ...
0
votes
1answer
69 views

Is an antipattern returning differente objects in a single rest method?

I have seen around the Internet several rest web services with the following behaviour. In case there are any errors, they return a Error object, otherwise they return, say, MyClass. See the ...
-2
votes
1answer
44 views

Design to method chain across packages

So bascially we have a library that contains a series of bifunctions passed in the metadata and datum looking like: Transform1: package transformation1; import com.fasterxml.jackson.databind....
0
votes
0answers
53 views

Clean architecture and state pattern

I am working in an GUI application that would work as follows: It will retrieve and save data from any of the following sources: A "Cloud Library": This library would get and save data to a cloud. ...
1
vote
2answers
56 views

How to agree on message schema in a Publish–subscribe pattern

I'm working on a project that uses PubSub(GCP), my question is not specific to GCP, it's more regarding to the architectural pattern(I'm used to statically typed languages, and I have a hard time ...
0
votes
1answer
33 views

API Split for creating object with inheritance and behaviors

I have a web service which is exposed to UI owned by our team. This web service is responsible for creation of objects and saving it in the DB (NoSQL Database). The object being created has multiple ...
-2
votes
3answers
63 views

Is there a secure way to ensure a data in an API endpoint of mine came from an Instagram endpoint?

Is there a way through encryption/keys/jwt or anything else to ensure that the data being sent through a POST request is only data coming from another request I made on the client to a 3rd party ...
0
votes
1answer
39 views

What's a proper way to call a chain of methods that modify an instance attribute?

I've got an Algorithm class whose responsibility is to find if a given word is in a list of words. As part of doing that, the algorithm first has to lowercase the words, remove punctuation, and ...
4
votes
2answers
416 views

What's wrong with using a Singleton?

I'm working on a Python application in which there are two Singleton classes: App and Configuration. The former seems straight forward, only ever instantiate one App instance; the latter seems ...
0
votes
0answers
51 views

How do I decide if Domain-Driven Design would be applicable to this project?

I'm at the stage where I'm taking my MVP app and trying to refactor and structure it in a way that it is maintainable and extendible. I'm new to software architecture or design so I'm having early ...
-2
votes
1answer
59 views

How would you architect a simple cascading style sheet object?

How would you architect a simple cascading stylesheet like inheritance object? For example, I have Apple that extends Fruit. class Fruit { constructor() { this.total = 10; } } ...
4
votes
4answers
202 views

De-coupling business logic from POJO de-serialization design pattern

I've a JSON file which I'm trying to de-serialize into POJOs. public abstract BaseClass { private String baseClassField; abstract String execute(); } ClassA extends BaseClass public ClassA ...
0
votes
1answer
60 views

Problems with software layers in complex query methods

I desingned a rest api software with 2 simple layers: Controller and Service. The controller handles the coming http request and redirect to a service method. In the beginning of development every was ...
-2
votes
2answers
126 views

Dependency of program code on specific database values

I have two approaches to solving a problem but I don't know which one is better. I will give a simplified example. First approach The database will look like this: color | -------- FFFFFF | 0000FF ...
0
votes
0answers
28 views

Is it ok to have a mix of PubSub and Request/Reply in a WebSocket server (focus on unit-test)?

I'm using Node.JS to build a system where the data get consumed by WebSocket requests, instead of classical REST API calls. WebSockets were used for realtime bidirectional communication, but then were ...
0
votes
0answers
72 views

Best design pattern to map functions/wrap functions that will be used by client apps

Abstract: I'm attempting to create a "data interoperability API" or in other terms "high-level query interface API" that will be consumed by (data scientists, web apps, any who wants to query ...
-3
votes
2answers
82 views

What are some use cases for creating child processes? [closed]

I am trying to understand processes and their use in software engineering. Not processes in general but rather creating a process from within a program. It seems a really powerfull tool and i have a ...
-3
votes
1answer
35 views

What do you store first in a CQRS + ES architecture

I've recently started reading about CQRS, DDD and EventSourcing. From what I've read one of the best ways to do ES is to have an event store and then a regular DB or cache for easier querying. However,...
1
vote
2answers
71 views

design problem handling a dynamic object

I am writing an application for different geometrical types of fuel tanks. I have a design problem that only at runtime I will receive the exact type of tank from the end user; and I don't know how ...
1
vote
3answers
161 views

What is the best object-oriented design approach for a tree with two node types?

I have a tree-like structure as shown in below picture (as one small example). The tree consists of two different node types, that are: Data Nodes: These nodes that are colored in yellow contain ...
-2
votes
2answers
106 views

Which Design Pattern to use to avoid conditional adding of elements to list?

I have code in the following form: public void drawObject(MyObject myObject) { RootElement root = new RootElement(); if (myObject.hasA()) { root.addElement(new XElement()); } else { ...
-2
votes
1answer
57 views

Design pattern for a switching between APIs with no code changes

I'm trying implement in JavaScript/Node.js a data upload functionality. I want to be able to switch between different storage providers, e.g. AWS, GCP, Azure, with no code change, for instance, via ...
-4
votes
1answer
33 views

Is there a design pattern for transferring “partial” or related data objects?

I am writing a program in Kotlin which parses some input data and writes it to a MySQL database (through JDBC). The database includes tables such as users and each table has a corresponding data ...
0
votes
0answers
14 views

How to preserve dynamic Configurations for a Process to historize it, load it and use it again for another process?

I want to Store a "Strategy" or "Set of Rules" on how a process is done. In a custumer Base, each User has certain orders. These orders depend on certain other Values. I want to store all User ...
0
votes
1answer
97 views

Fruit Ninja Design Decisions

I'm doing a Fruit Ninja clone in java (language not really relevant). It's not completed yet, but here is the point I'm in now: Currently I've: Difficulty interface, where several classes will ...

1
2
3 4 5
78