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
-3
votes
0answers
4 views

Middleware based frameworks alternative in NodeJS

According to some sources middleware based frameworks are hard to debug. Then why there are no NodeJS based frameworks using a different pattern? Is middleware the only option? If not, what are the ...
0
votes
1answer
9 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 ...
-3
votes
1answer
24 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
77 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
54 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
79 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
50 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
88 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
43 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
103 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
0answers
48 views

What is the right design pattern for me to abstract this class?

I am working with some code that takes advantage of ControllerContext. See: https://docs.microsoft.com/en-us/dotnet/api/system.web.mvc.controllercontext?view=aspnet-mvc-5.2 My code looks something ...
5
votes
3answers
144 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(): # ...
8
votes
5answers
2k 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 ...
0
votes
0answers
39 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
49 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
64 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 ...
-4
votes
0answers
34 views

What kind of design pattern do you use to add new entities to a collection?

I've got a collection with a certain type of entities. Now I want to iterate through this collection to find matchting entities (of the same type) and inject them to this same collection. So you ...
-2
votes
1answer
41 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
46 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
53 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 ...
-2
votes
0answers
31 views

Can SOAP client can be considered as repository

I am developing a REST API, which will be used as a bridge/wrapper to get data from other legacy SOAP service, for this I have come up with a design as below with my previous experiences with DB and ...
0
votes
1answer
30 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
62 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
38 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
260 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
47 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 ...
-3
votes
1answer
41 views

Defining Database vs Service-level Entity [closed]

I have a demo application, which have customer and their order information. If I had a database, data will be stored in table as below, Customer : id | name | Address Order table : (for ...
-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
177 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
59 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
124 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 ...
-4
votes
0answers
25 views

How to have lombok builder handle incompatible configurations

How can I use lombok builder to enforce usage of only compatible configurations, like in this answer: How should I handle incompatible configurations with the Builder pattern? ? Maybe somehow extend @...
0
votes
0answers
21 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
70 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 ...
-5
votes
0answers
25 views

Refactoring a memory numbers game in ReactJS

I've been learning ReactJS by doing simple games. I'm doing a memory game which is, for the most part, finished and I'm not sure how I should refactor the code to be better. The user task is ...
-3
votes
2answers
68 views

What are some use cases for creating child processes?

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
34 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
68 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 ...
-5
votes
0answers
37 views

How to design a cashier system for plant nursery

I have been asked to create a cashier application where it's like any ordinary shop with a cashier system. So far so good the problem arises with the products let me explain this further. Imagine ...
-3
votes
0answers
43 views

Architecture design for data representations that records access during lifespan?

is there any software architecture that enables a representation of data to include every change the data has forgone e.g. method wrote a new date to the original field, and then also the include the ...
-2
votes
2answers
93 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
52 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
31 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 ...
2
votes
1answer
82 views

Python: Return or update object

Firstly I am new to Software Engineering and my last question was closed. I am doing my best to ask relevant questions and improve. If you are going to down vote my question I'd really appreciate if ...
2
votes
1answer
98 views

Is it allowed to include the composition in the compositor in the Strategy Pattern

I have a range of different animals in my zoo such as turtles, birds etc. As they all share a common trait such as either swimming, flying etc., I thought a strategy pattern would be appropriate to ...
0
votes
6answers
240 views

Dynamically knowing all the subclasses of a superclass

Say I have a class to model my customers class Customer { public static customerType = 'customer'; } And a subclass class CorporateCustomer extends Customer to model my corporate customers. ...
1
vote
3answers
63 views

How can the relationship of these objects be modelled, so that when given a set of objects I can determine what other objects are compatible?

Consider the follow entities: Bob, Sally, Apples, Oranges, SupermarketA, SupermarketB. The relationship between this is as follows: Bob can buy Apples from SupermarketA and SupermarketB Bob can buy ...
1
vote
1answer
49 views

Doing data manipulation on server side vs client side

Im building a project that stores time series data on a per user basis. On the dashboard of the user it'll show some simple statistical analysis like averages but more importantly, it'll create charts ...

1
2 3 4 5
77