All Questions
62,889
questions
0
votes
1
answer
113
views
Is interleaving local variable declarations with assertions and function calls a bad practice?
In my experience, it is customary to place local variable declarations at the beginning of their scope. Several questions in this forum ask whether this needs to be so, and their answers tend to agree ...
7
votes
2
answers
2k
views
How can I make code that is both DRY and fast where intermediate values in a calculation may or may not be needed?
How can I make DRY (lacks repetitive patterns) code that also avoids inefficiencies from using intermediate values in a calculation that might not need to be used?
Here is an example:
In this code, I ...
0
votes
1
answer
77
views
How could I apply the strategy pattern to a react component? [closed]
For the following component, how would I extract the unit logic to allow for composition? In my actual app I am trying to reduce the amount of logic encoded in the component and I have decided that ...
0
votes
1
answer
65
views
REST - Adding a new field
I have an object with fields like ID, CODE, NAME, etc., and it has its own database table with each field. And I am working on implementing the REST API for this object. I want to expose all these ...
65
votes
8
answers
13k
views
When to *not* use SOLID principles
Coming from a math background, counterexamples are equally, if not more, helpful to me for understanding concepts than examples. I've seen many, many examples of when and how to use the SOLID ...
1
vote
2
answers
179
views
Best practices for unit testing when breaking down functions into smaller ones
Say we have a function of the form
def func(num: int) -> int:
num = num + 1
num = 2 * num
num = num**3
return num
and let us act like each line is a long computation so that we ...
0
votes
1
answer
69
views
C++ creating a class with self referencing custom comparator [closed]
This is the node for a tree
class Node {
public:
string name;
map<string, string> attribute;
Node* parent;
set<Node*, customComparison> children;
};
Where customComparison in ...
2
votes
2
answers
206
views
hexagonal architecture vs clean architecutre
I am trying to improve the architecture for my React app project that has grown in size lately.
I'm looking at Hexagonal architecture and Clean architecture, and I couldn't really see the difference ...
2
votes
3
answers
125
views
Please help with this maze of fencepost problems ( vector across window )
I'm trying to implement LOGO with a physical turtle. I got all the basics done, but I got completely sunk when implementing the "Window" mode.
Original LOGO had 3 modes: "Border" - ...
2
votes
9
answers
2k
views
Is it an anti-pattern to use interface for entity?
I read an article about that using an interface for an entity is an anti-pattern for these reasons:
Your interface signature is identical to your class.
There’s only one implementation of your ...
1
vote
0
answers
40
views
Why must a safe configuration be reached in `n^2 + n` rounds in Dijkstra's Self-stabilizing mutual exclusion algorithm? [migrated]
In the book Self-Stabilization (Dolev, 2000) the author provides a proof (p.19) of Dijkstra's self-stabilizing mutual exclusion algorithm. An excerpt of the book showing the proof is found below.
At ...
-2
votes
3
answers
138
views
How is exception handling implemented in software architecture? [closed]
I am currently learning about software architecture and I have some questions about exceptions processing as it is an important part of the software.
In which document and how should I describe how ...
0
votes
1
answer
83
views
What C# Object Composition strategy would you apply for CoreObjects with a governing 'ObjectType' property
In a C# ASP.Net Core Web Application I have a Domain Model CentralDesignObject made up of many component objects & properties, producing a significant amount of derived/calculated values.
This ...
0
votes
1
answer
88
views
Options for designing a generic library
During development of libraries (mainly for use in internal projects) I have come across the "problem" of how to design them in a generic way. I am going to demonstrate with an example ...
0
votes
1
answer
86
views
Looking for the name of the meeting that anticipates system failure during feature design
In my organization, we often have meetings to discuss potential points of system failure, prior to implementing much / any of the actual code. This helps us to identify points of architecture, and ...
-1
votes
0
answers
29
views
Spring Reactive Restful APIs - Is it really a non-blocking model?
I know that is possible to build my entire Spring boot application in reactive way.
So if my application uses R2DBC, I can do something like:
@Repository
public interface PersonRepository extends ...
2
votes
3
answers
235
views
Should Acceptance Criteria be mapped to unit tests?
My organisation is adapting a new SDLC process, and a part of this is to force engineers to map acceptance criteria (AC) to unit tests written for each user story in the pull request (PR).
To satisfy ...
1
vote
1
answer
117
views
How large and thorough should the domain layer be?
TL;DR: Should the domain layer span the entire breadth of the app such that everything can be simulated, from point A to point Z, or may the application layer be used as the orchestrator and serve as ...
-2
votes
0
answers
60
views
Approach to storing variations in schema in SQL database?
I am working on a simple dictionary app built on PostgreSQL. I have the idea of "lexemes" or what I'm calling "flows", which are basically any word, word fragment (prefix/suffix), ...
0
votes
2
answers
186
views
Clean Architecture: Loading data for the domain layer
Let's say my domain has a User Entity that has a many to many relationship with itself representing "Friends"
public class User
{
public int Id;
public IEnumerable<User>? ...
0
votes
0
answers
48
views
How do you decide what is worth writing a unit test for [duplicate]
In an app I'm working in there's a service class(among others) which is used just to call methods on other classes. Recently I've had to work in that area and add another method that does what all the ...
-1
votes
0
answers
61
views
Design of Complex Java Filters
I have a collection of DTOs and would like to filter the collection on a complex set of criteria. For example:
//modelIds is a Collection<String>
cars
.stream()
.filter(car -> {
modelIds ==...
26
votes
8
answers
5k
views
What is a good way to indicate that a number is not something you can count with?
What is a good way to indicate in programming that the sequence of digits you see is not a value you can do math on?
I use a lot of numbers which aren't "numbers". From account-numbers to ...
0
votes
1
answer
120
views
How can I trace back the original table of a column?
New to a software engeneer job and I am kinda blocked on the way to go with my new project
To explain this in a scheme.
I have a source of data in a custom app that is for most part of the time the ...
0
votes
0
answers
40
views
how to design shared settings in a multi user application
I am looking for a software design to solve the requirement that is the title of this question.
I want to keep this deliberatly open, i.e.even tho we're implementing this in C++ I am open for any ...
1
vote
6
answers
311
views
How encapsulating what varies can help us?
I have a question about encapsulation and I read these two topic (this & this) but I got more confused.
I've been reading Head First Object-Oriented Analysis and Design book and I'm trying to ...
0
votes
0
answers
39
views
Correct way to represent acquaintance enforced by interface in UML class diagram
Suppose I have the following client code:
using System;
namespace InterfaceCompositionUml
{
internal class Program
{
static void Main(string[] args)
{
...
-1
votes
0
answers
63
views
Array Indexing Using Wrapper Classes
Is there a reason why we, as software developers, do not use specialized types for array indexing? Typically, I use the "int" primitive type to perform array indexing, but I was thinking ...
0
votes
0
answers
20
views
React Design - Parent / Child Interaction with Async State
I have a situation involving a parent component, children, and async fetch operations, and I am wondering how to best structure it.
The current code structure I have is as follows:
I have a parent ...
0
votes
0
answers
49
views
Organizing screen resolutions?
Does it make sense to organize screen resolutions?
I write a lot of selenium tests, often which I need to choose a resolution for the browser. I ended up creating a dictionary with some of the more ...
0
votes
1
answer
92
views
How do I mock API responses with security in mind?
My team and I are beginning to mock our API responses in our iOS app so we don't have to worry about our backend being up when testing.
I have conditional compilation directives based on the ...
0
votes
2
answers
133
views
Is this a bad pattern for reporting/audit?
We have a large code base with lots of workflow data (camunda) that does this:
Create a reporting event in the codebase
Give it a code + payload
Put the item on a message queue
Consume queue ...
3
votes
6
answers
453
views
Marketing team's term for ubiquitous language
We are working on a ubiquitous language; however, there are different terms used for marketing purpose and one used for product team and engineering team. The marketing team's term is more for PR ...
0
votes
1
answer
96
views
Should I use method overloading or method overriding when creating converter service
In a Java Spring API, I'm implementing GeoJson Conversion Service to convert different types to geojson, I have GeoJsonConversionService interface, and one implementation is ...
0
votes
1
answer
77
views
Why aren't mandatory options requested in the signature of ASP.NET Core "AddXXX" methods?
I've developing a .NET Core library meant to simplify the configuration of the authentication within our SSO system. It will expose two methods to be called in the Program.cs (or Startup.cs) of ASP....
0
votes
0
answers
24
views
Update notification through api end point to SignalR hub or directly in SignalR hub
For updates on a dashboard, I need to decide to make an extra api end point which creates a message in SignalR or let some kind of message broker (filewatcher1) do that. What would be good ...
24
votes
11
answers
7k
views
Why and how to write clear code comments and when will documentations be needed beyond code commenting?
I am learning programming on my own following standard programming language textbooks. I come from a math background. I learned C on my own, but never really got to the more advanced portions.
I ...
1
vote
2
answers
48
views
Table referential integrity varying according to application logic
I've come across a scenario where data in one table is related to another table but referential integrity doesn't seem to apply as I would usually expect. This is because table x uses data from ...
0
votes
0
answers
35
views
Client-Server Coupling in gRPC vs REST
Quoting this article - The Other key differences: gRPC vs. REST section (client server coupling):
Client-server coupling
REST is loosely coupled, which means the client and the server do not
need to ...
0
votes
1
answer
80
views
Comparing synchronization primitives (future, barrier, conditional var) - which one fits the best?
Trying to understand and compare synchronization primitives, like std::future/std::promise, std::barrier and std::conditional_variable - developing an intuition for which one to use when exactly.
I ...
1
vote
3
answers
99
views
Why does this use case diagram consider system behavior a use case
Please help me understand why, in this diagram, "Validate User" is considered a use case.
My understanding is that to qualify as one, a use case must:
Be initiated by an actor;
Represent ...
1
vote
4
answers
317
views
Is it worth unit testing hardcoded values? [closed]
I recently worked on a project where the team were writing lots of unit tests for hardcoded values, for example, unit tests that test the value of a string constant. The justification being that they ...
-2
votes
1
answer
73
views
UML relationships
Could someone explain to me if the relation in this class diagram is a "dependency" or "association" relationship and why?
I cannot edit the picture. The terms translate into ...
1
vote
0
answers
55
views
KRaft design architecture - Separation of Controllers and Brokers
We want to install Kafka Kraft cluster on 35 machines ( machines are DELL physical machines - type R760 And OS is Linux RHEL 8.6 version )
Since we are dealing with Kafka production cluster , we want ...
0
votes
0
answers
50
views
Java - How to build a library to record runtime data?
I'm working on building a library in Java which could provide the ability to record runtime data.
For instance consider the below code:
public interface ItemElement {
public int accept(...
0
votes
3
answers
156
views
Event-driven design with delayed consequences
EDIT: more direct situation
I need to design a program that will create particular objects and run computationally intensive procedures using its fields in order to update other fields. When a ...
0
votes
3
answers
90
views
How to build REST uri that fetches children by parent ID
I am building 2 REST microservices: ParentService and ChildService. I need to build endpoint to fetch all Child resources related to specific Parent, so I have these URI's as options:
GET /parent/{...
-1
votes
2
answers
222
views
4 Months of Code Rewritten in 2 Days Team Dilemma [closed]
I recently had a project that I took me 4 months to do , I hit some very significant bugs that where impossible to track down. I said this code is absolute garbage and started from scratch, drank a ...
1
vote
1
answer
87
views
Servlet Development Best Practices
I am developing a web application using Java servlets, and I would like to know what the software development community thinks of the following programming practices:
Use static member variables for ...
2
votes
2
answers
125
views
Where to put interface files for mocking aka what are best practices for organizing interfaces in a C#/.NET Core project with NSubstitute, Moq etc.?
Question
I'm working on a C#/.NET Core project, and I'm looking for guidance on organizing interfaces, especially when it comes to using NSubstitute, Moq or other libraries for mocking, because there ...