Stack Exchange Network

Stack Exchange network consists of 175 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
votes
0answers
40 views

Is defining a Service like this a good idea? MVC architecture [on hold]

This intends to represent a base service interface for services that act as an API for an Entity related operations. T -> the Entity class type ID -> the Entity Id class type DTO -> the Entity Dto ...
1
vote
2answers
79 views

Observer reporting to multiple layers up from the bottom of hierarchy

There is a swarm of objects. When a new unit of certain kind appears on the frame, the swarm integrates this object by calling some add_new_unit method. Above the swarm is a controller abstraction, ...
-2
votes
0answers
24 views

Extending a data class consumed in various place because one of the consumers requires a new field [on hold]

I have a class A that is the return type of a process (let's call it M.getData()) that is consumed by several procedures through the code base (lets call them P1, P2 and P3). This class A is part of a ...
3
votes
1answer
77 views

Heavy task exposed via a REST API

A part of a system I am currently reviewing, consists of a master node which calls several slave nodes using REST APIs. The slave nodes are scattered throughout the world on different servers, and ...
2
votes
2answers
67 views

How to implement change log of a ticket in complaint management system [on hold]

One of the requirement, in the complaint management system were are designing, is to implement complete history of the ticket. For example Status was changed (new to pending to work in progres to ...
2
votes
1answer
41 views

Architecture design for Linux administrative interface

I've developed an IoT device utilising OpenWrt so my design needs run a on a shoe-string budget of resources. I need to be able to push small amounts of data, up to 300bytes to my app on a very ...
2
votes
3answers
138 views

C# Pattern for Creating/Hiding Object Graph Creation

I'd like to get some advice on what would be a good approach at hiding the creation of an object graph. In the code below I would like SomeClass to not be directly responsible for the creation of the ...
4
votes
2answers
175 views

Doesn't repository pattern in clean architecture violate Dependency inversion principle?

From what I have read and seen clean architecture assumes that you have some entities which know nothing about persistence though at the same layer as they reside there might be an interface which has ...
1
vote
0answers
35 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 ...
2
votes
0answers
43 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 ...
1
vote
0answers
10 views

different data connectors for different objects and users

I have an application which needs to store different objects in different data stores based on the user's authorization credentials. I.E. the user may need to save object 1 to their BI postgres ...
3
votes
4answers
204 views

How to get a decoupled design without injecting repositories inside entities

I am facing the following situation: I have to develop a system that has to calculate the price of a car so i need to calculate the prices of all the Pieces that make up the car and then total them. ...
7
votes
5answers
425 views

Best Practice - Wrapping if around function call vs Adding early exit if guard in function

I know this can be very use-case specific, but I find myself wondering this far too often. Is there a generally preferred syntax. I'm not asking what is the best approach when in a function, I am ...
0
votes
1answer
130 views

How to connect two objects that communicate with each other?

I am writing a simple chat using Node.js, Websockets and Vue.js. Specifically, I have a Vue instance and a Websockets Client. When a user presses a "Submit" button, Vue asks the Client to send a ...
2
votes
2answers
56 views

Swappable state object or decoupling data and functions

I come from OOP pradigm and I also know a bit about functional programming and its advantages. Over time I came to like the separation of data and transformations that are applied to it using pure ...
5
votes
1answer
109 views

Working with “external” object IDs

I have often encountered a situation in which users of a program (not necessarily human, just an external agent) need to be able to reference objects of a class with a certain "external" identifier, ...
2
votes
2answers
134 views

Strategy pattern and different implementation

I am still learning Design Patterns and I have a situation in my hand. I am developing a simple employee management Python program. An employee can be a Developer, Senior Developer, Lead Developer, ...
0
votes
1answer
102 views

How to bring a code to conformance with tell, don't ask without creating tons of methods on other classes?

It used to be fairly common for people to call a getter, do some calculation on it, then call a setter with the result. This is a clear sign your calculation actually belongs to the class you called ...
1
vote
1answer
62 views

Why do some eShopOnContainers Service API Unit Tests not reference API classes only WebMVC? [on hold]

I have been trying to learn more about MicroServices architecture and I am using Microsoft's eShopOnContainers as a reference because I am familiar with .NET. I am getting into the part about testing, ...
1
vote
0answers
39 views

How to join two sets of 6 tables and select the list into another set of 6 tables

A1 |__A2 |__A3 |__A4 |__A5 B1 |__B2 |__B3 |__B4 |__B5 C1 |__C2 |__C3 |__C4 |__C5 Given a list of A and a list of B, we want to "join" ...
10
votes
5answers
671 views

Pure functional vs tell, don't ask?

"The ideal number of arguments for a function is zero" is plain wrong. The ideal number of arguments is exactly the number needed to enable your function to be side-effect free. Less than that and you ...
0
votes
1answer
45 views

Pipeline design pattern with context for chaining REST API calls

Just like the title says, I want to use the pipeline design pattern for chaining related API calls. The context will store the data that will be used to create a payload. For example, I have the ...
0
votes
3answers
102 views

Designing a class whose dependancies require “starting”/initializing step

I have Facade class which requires an Endpoint instance to function (it uses it in most of the functions). Endpoint is attached to Platform that is passed in Endpoint's constructor and has to be ...
3
votes
3answers
87 views

Open Close Principle is applicable when requirement is to add new operation(s) to existing type?

I understand OCP in SOLID can be applied when we have same set of interfaces defined via abstract type, so that we can have varying implementations of those interfaces via concrete types. For example,...
0
votes
7answers
297 views

Good object oriented practice to use an object to build itself?

Do you think its a good OO practice to use parts of an object to build itself? Here is an example. var car = new Car { Make = BuildMake(), Model = BuildModel(), Vin = ...
0
votes
2answers
98 views

How to handle command line parameters

I am writing a gui that is supposed to replace a fairly large shellscript in order to make the usage easier for not-so-technical people. The script calls a certain program (saga_cmd) multiple times ...
0
votes
3answers
192 views

Responsibility of a Factory

I am trying to refactor a huge chunk of our software, and it requires to set up a factory. However, I am not sure where lies its responsibility. (PS: The code below is shown simply as an illustration ...
1
vote
0answers
37 views

Should I use gRpc in my business layer?

I'm moving from REST APIs to gRpc but having a hard time figuring out how to structure my logic. The basic layout of my solution is having a business layer/API and a few different front-ends (Windows ...
-2
votes
1answer
57 views

Design patterns for migrating a legacy database model [on hold]

I have a product which has a un-normalized legacy data model which contain millions of records. This has cause problems when adding new features and with performance. Also this contributes to high ...
1
vote
1answer
105 views

CQRS command that needs to work with multiple aggregate roots

I have have a business process that receives an order request which also includes full customer information. In the cases where the external customer ID from that order request is not found in our DB,...
1
vote
1answer
139 views

Building a MVC Framework: Should I get an instance of Database, or should I extend with a “general” model class that already has an instance of DB

I am trying to get a database instance via any model-class that uses the database. This is ideal in my opinion: class UserAuthenticator { private $db; private $customer; public ...
1
vote
1answer
55 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 ...
2
votes
4answers
138 views

What is the name of DB design pattern which support only soft-deletes and soft-updates?

I heard that there is some DB design in relational databases where updating a record will create a new record with different timestamp or status. Also, deletion will be soft-delete (it updates the ...
0
votes
0answers
54 views

Apply Value Object (Stringly Typed) in PHP

What is the best way to prevent wrong states in an object? This is the source of my question. Basically my curiosity started with the intention of not letting a class exist with wrong values. Prevent ...
3
votes
2answers
93 views

How to create a tree-hierarchical structure with unique behavior for every type combination?

Assume: There is some module whose interface is IA. There is some module B, that takes in a parameter an instance of IA, and whose behavior depends upon the type of that IA, meaning (pseudo code, no ...
1
vote
1answer
85 views

Have generic methods that transfer DTO's from different packages, but contain same fields

I have 3 services Service A, B, C which put and get data to/from Service D +============================================+ | Service A | Service B | Service C | +==============================...
8
votes
4answers
858 views

is this way of calling a function a bad practice?

I have the following code: public void moveCameraTo(Location location){ moveCameraTo(location.getLatitude(), location.getLongitude()); } public void moveCameraTo(double latitude, double ...
0
votes
1answer
52 views

Defining object definition scope based on domain

I had an architecture question about how to manage objects with different properties based on the services they are in. Is it okay to have an object defined in to different places with similar ...
9
votes
4answers
446 views

What is the best definition for Dependency Injection?

Every time someone reaches me and asks me to define the Dependency Injection in a conceptual way and explain the real pros and cons of using DI in software design. I confess that I have some ...
0
votes
1answer
60 views

What pattern should I use to implement a Message Routing mechanism?

I'm hoping someone can give some guidance on an issue I'm having. I have: A WebSocket service, where I have a single method on the server that handles all traffic. Lots of different kinds of ...
0
votes
1answer
90 views

Calling same method on different instance (Polymorphism)

I have situation that 3 different instances with the same method signature are doing their job repeatedly. interface IArgs{ //args stuff } interface IExample{ void Populate(IArgs); } class ...
0
votes
0answers
28 views

Good practices: using member routes or filter on search scopes?

I want to know which practice is more convenient having the following example, (my app is a Rails app but this can be applied on any framework) I am trying to create an endpoint which contains author ...
0
votes
1answer
68 views

Should there not be methods intended to be only called from inside of the package, but from the outside of the class they're defined in?

Note: This is a follow-up to this question on StackOverflow. I have to write a wrapper in Python to an external API, accessible through HTTP. The code is supposed to be publicly available on GitHub. ...
-2
votes
1answer
93 views

What's the best design pattern approach for introducing optional feature to current code base?

I had a class hierarchy with several classes that interact with each other. After introducing new feature that is optional (but it depends on external libraries) I have the following code (just ...
2
votes
3answers
102 views

Design: Where should methods specific to a model, but not an instance go?

Let's say I have a User model defined. It makes sense that methods for retrieving certain fields of this model lives in the model file. My question is where something that generates a unique UUID, or ...
-1
votes
1answer
55 views

How to build a custom intermediate operation pipeline in Java for a series of API calls?

I am working on a project which provides a list of operations to be done on an entity, and each operation is an API call to the backend. Let's say the entity is a file, and operations are convert, ...
0
votes
0answers
110 views

Decorator Pattern Java

This is an object-oriented design question that is specific to Spring Boot. I'm extending a Spring Boot application that has an interface that is being extended and used inside another service. The ...
1
vote
0answers
46 views

How to solve circular dependency scenario while executing http calls which require authentication?

I am working on a project which requires me to execute standard HTTP calls with session tokens. I am building a custom HTTP client, with a custom authenticator, something like this: Client client = ...
0
votes
1answer
78 views

Is singleton use acceptable for static single responsibility?

I have been reading into possible design patterns and have found the use of singletons always referred to as an anti-pattern. I am currently using a singleton for the sole purpose of gathering ...
3
votes
2answers
246 views

Should Entity Framework 6 not be used with repository pattern?

So I am asking this after reading the following: Why shouldn't I use the repository pattern with Entity Framework?. It seems there is a large split of people who say yay and those that say nay. ...