32,160 questions
Best practices
0
votes
0
replies
44
views
Testing in MVVM architecture. What to test and how to approach TDD?
I’m currently working on a personal Android project using Kotlin and Android Studio, following a basic MVVM architecture:
─main
│ ├───java
│ │ └───com
│ │ └───example
│ │ └───...
1
vote
1
answer
78
views
What is the most Pythonic way to create a subclass of an object based on a string parameter
What is the best practice for creating an object based on the value of a string argument?
I am loading my configuration from a file and passing the string as an argument that gets mapped to a specific ...
Best practices
1
vote
2
replies
53
views
What is the best pattern for SwiftUI Document Application?
I am trying to create a full SwiftUI Document app (using swift 6, as it matters).
Apple doc says that the Document init(configuration:)and fileWrapper(configuration:)are called on a background thread -...
0
votes
0
answers
80
views
How to register function delegate with interface that has a generic type?
I wanted to create a flexible MessageProcessor, depending on the SupplierType(= enum) and depending on which MessageProcessor comes out a different Message-object will be used.
The current situation ...
Best practices
2
votes
4
replies
105
views
When is it OK to use a singleton?
Follow-up on this question: Singletons: good design or a crutch?
It is true, that using singletons can make testing harder, and bugs can hide behind them. GoF defines singleton to use when:
Global ...
3
votes
1
answer
80
views
In Laravel’s Repository pattern, should I pass an Eloquent model (User $user) or a DTO to keep it framework-agnostic?
I’m refactoring my Laravel application to follow a clean architecture approach with clear separation of concerns:
Controller → Service → Repository
The Controller handles the HTTP layer,the Service ...
-1
votes
1
answer
67
views
SQLAlchemy session initialization in Command pattern [closed]
A question on consideration for case/approach choice.
Let's say we have an app that has an ORM model and also uses simple realisation of the Command pattern. Inside of each command we need to ...
0
votes
1
answer
156
views
Passing reference of this class instance in its constructor to other class instances
In Java, I can write something like this:
public class Brother {
private final Parent parent;
public Brother(Parent parent) {
this.parent = parent;
}
public void annoySister() {
...
2
votes
0
answers
212
views
Design dilemma with enum_dispatch in Rust
I'm designing my system which consists of three parts, abstract layer (al) where traits and generic data structures are defined; implementation layer (il) where different structures implement traits; ...
5
votes
2
answers
198
views
Improve implementation of a "widget tree structure" in Qt6 [closed]
Let me introduce first the problem. I will present a simplification of my QT6 project app (in C++) to not make it too difficult to read, as the original code has lots of unnecesary things for this ...
1
vote
1
answer
108
views
How to return both early result and final async result using Promise?
When I make a POST request, the server responds immediately with an id, but the actual result is delivered later via a server push event (e.g., WebSocket or Pusher).
Here's what I'm trying to do:
When ...
1
vote
1
answer
74
views
How to pass contextual data to a decorator without modifying the command interface?
I'm working on a feature where I need to send analytics data whenever a command is executed — for example, whether the command was triggered via a hotkey or a UI button. However, I want to achieve ...
0
votes
1
answer
83
views
How to implement a Multiton pattern with user-supplied factory methods?
I’m building a Rust library that manages multiton instances keyed by strings. Users of the library provide factory methods to create instances implementing a trait, and the library should:
Return the ...
0
votes
0
answers
114
views
Designing a Flexible FSM in Haskell with Typeclass States
I'm trying to build a simple Finite State Machine (FSM). Intuitively, I've described each finite state as a typeclass:
class FS st where
fsUpdate :: st -> StatefulEntity -> StateMondad st
...
6
votes
2
answers
152
views
How can I generalize a unit conversion method for different Enums in Java?
I’m currently building a unit converter app in Java (as a beginner), and I want to avoid duplicating logic for each type of unit.
Right now, I have different enums like Length, Weight, Time, etc., and ...
4
votes
2
answers
98
views
How to pass values from application.properties to a java abstract class?
I'm new to Java class design and need help with the following:
Example scenario:
I want to pass the company name and email to the BaseEmailMessage class, and fetch these values from the application....
1
vote
1
answer
99
views
How to properly reuse heavy calculations performed in the Parent class within the Child class?
Suppose I have a Parent class in Java:
public class Parent {
protected int value;
public Parent() {
value = performHeavyCalculations();
}
private int performHeavyCalculations(...
0
votes
1
answer
59
views
How can I maintain transactional integrity across distributed microservices using a hybrid event-driven and REST-based architecture?
I'm currently working with a distributed system composed of multiple microservices, some of which communicate via RESTful APIs and others through asynchronous messaging (Kafka).
My current challenge ...
0
votes
1
answer
160
views
Java does not allow using private final class member in lambda under certain pattern
A private lambda function is accessing a private final class member that is initialised in the class constructor. However, this code pattern compiles with error: variable num might not have been ...
-5
votes
1
answer
73
views
Confusion about EF Core intended work process
I have a simple form a user fills out. He selects some things from the DB like other users, etc, to fill in some entries, types other things manually, and submits it.
So I have a question: the docs ...
0
votes
0
answers
71
views
Handling input requests in MVC pattern with an FSM
As a university software engineering project, my group has to make a videogame out of the board game Galaxy Truckers (rules summary, if it helps), using the MVC pattern (we're using Java as a language,...
1
vote
0
answers
126
views
Reading Health Connect Data Simultaneously Without App Pausing or Delay?
I'm developing a workout tracking app that integrates with Health Connect to collect and process sensor data during a workout session. The expected workflow is:
The user starts a workout.
Health ...
-2
votes
1
answer
120
views
Enum and Array vs Separate Variables to store multiple instances of a class [closed]
The following is a toy example:
An image stores a width, height and filepath, represented by the struct IMAGE:
#include <cstdlib>
#include <type_traits>
struct IMAGE {
int WIDTH;
...
-1
votes
1
answer
45
views
Can a Single SPA UI interact with many Backends?
I'm working on a company project where the UI interacts with multiple different microservices instead of a single fronting api microservice. Is it the right architecture? We also have an Authorization ...
0
votes
1
answer
301
views
Vertical Slice Architecture big number of models
I am playing with VSA and I encounter something that seams wrong. I want to build a Web Api using MediatR and CQRS. Now, let's say I want to implement some CRUD operation on an entity called User, ...