32,168 questions
Best practices
1
vote
0
replies
26
views
DIP is justified when I have at least three volatile inputs /outputs to/from some system, is this ok generalization?
I'm computer engineering student who is new in the realm of design patterns, for some reason I started with Dependency inversion- higher level policy should not depend on lower-level policy, but ...
Best practices
0
votes
1
replies
64
views
Decorator Pattern with DI
I'm learning about design patterns and I stumbled upon the Decorator pattern. I did my research, and implemented a working version.
public interface IWriter{
void Write(string text);
}
public ...
Advice
0
votes
2
replies
94
views
Designing a Python API: list of coordinate tuples vs separate parameters?
I created a Python toolkit called `cartons` that wraps RoutingPy and OSRM.
Currently, my API looks like this:
cartons.route(lon1, lat1, lon2, lat2)
For version 1.2.0, I want to support multiple ...
Advice
0
votes
7
replies
118
views
Is it considered an anti-pattern to use nested static classes for service commands and responses?
I am structuring the command and response models for my service layer. Currently, putting all models into a single, flat folder (like /commands or /responses) is becoming hard to manage due to the ...
Best practices
0
votes
3
replies
128
views
Is using Singleton pattern in Python viable for global Configuration object?
I've read quite a bit on SO and elsewhere on Singleton being anti-pattern (hard to test, thread unsafe etc), e.g.: https://www.michaelsafyan.com/tech/design/patterns/singleton
However, there still ...
Best practices
0
votes
0
replies
34
views
next js reuseable apiservice cofig
i am building a Next.js application using the App Router and I want to implement a clean, scalable, and reusable API service layer. My goal is to avoid repeating fetch logic in every Server Component ...
Best practices
2
votes
2
replies
54
views
"A Philosophy of Software Design" vs "Grokking Simplicity": how do you decide on their contradicting advice on function design?
I would like to ask you to help me clarify a situation regarding two different coding philosophies. Tell me whether they don't in fact contradict and I am missing something, tell me whether these two ...
Best practices
0
votes
0
replies
81
views
Best pattern for Mapstruct updater when a field can't be constructed/built without parameters
A simple mapper which also provides and 'update' mapper
@Mapper(componentModel = "spring", uses = "EngineMapper.class")
public interface CarMapper {
CarEntity carDtoToCarEntity(...
Best practices
0
votes
1
replies
51
views
How to implement idempotency across multiple servers with non-shared databases and private caches?
Server A → DB1A
↕
Private Cache A (Redis/Memcached)
Server B → DB1B
↕
Private Cache B (Redis/Memcached)
Problem
I have a POST endpoint (e.g., domain registration) where the client sends:
{
...
Best practices
0
votes
0
replies
51
views
Architectural pattern for binding user authorization to demonstrated comprehension before system execution?
In many distributed systems, user authorization is treated as sufficient proof of intent.
Examples:
Clicking “Approve”
Signing digitally
Submitting a confirmation request
Triggering a smart contract ...
Best practices
0
votes
4
replies
52
views
Apply list of functions over enum encapsulated variants
I have an external data in the form of:
enum Foo {
Foo_1(Foo_1T),
Foo_2(Foo_2T),
...
Foo_n(Foo_NT),
}
I would like to apply bunch of processors over the Foo, which have more or less the same ...
Best practices
1
vote
3
replies
57
views
Reconciliation from DB -> Kubernetes or DB as a caching layer
I have encountered this very non-trivial problem of managing state drift and was wondering what your opinions were.
Basically I am trying to create a managed-hosting provider (Gameservers) and I'd ...
Best practices
2
votes
17
replies
6k
views
how to separate break conditional logics from while statements for readability, encapsulation and DRY
General question
I wonder how to express any code of the form
while True:
state_before = some_function(my_object)
# algorithmic code goes here
state_after = some_function(...
Best practices
2
votes
4
replies
71
views
How do I differentiate each device so that each one has its own unique refresh token linked to the same account?
I am designing a mobile application with a user login system.
I am going to implement refresh tokens in order to allow for users to only have to log in once every 30 days.
How do I differentiate each ...
1
vote
0
answers
46
views
What is the difference between Abstraction and Facade in flutter? [duplicate]
I am a beginner and learning flutter through roadmap.sh which led me to fireship video of design principles and according to his explanation of facade design principle it feels very similar to ...