instruction stringlengths 34 36.1k |
|---|
Currently we are moving to an API driven architecture using SPAs and WebAPIs. We are also moving from SAML2 to OAuth 2.0 and if it is appropriate, OIDC.
We have a couple of APIs and one of the APIs can check if a user is under guardianship. This API is being called directly from the SPA and is used to detect which data... |
I need to work out the architecture for a NASDAQ frontend charting application (a desktop app in .Net). Note that this is NOT for real-time quotes.
NASDAQ provides an api that gives historical pricing, limited to one year's data, which is fine for our purposes.
First I use that API to get the data (it comes in csv file... |
The issue that I'm facing is on a banking app. There are two ways to register for internet banking.
A) Self Register
B) Ask for bank to register via their GUI panel backend.
Consider this scenario:
Say a customer is already registered MANUALLY (via bank).
Then he requests to change his mobile number to something else... |
Let's assume I have a batch job that needs to print orders. It will do so by getting orders from the order service and send them to the print service.
It uses HATEOAS to discover the link from the root on the order service to get the orders that need to be printed:
GET https://orderservice/
{
_links: {
ordersToP... |
While sending FCMs, I've noticed these two headers are important(message won't go without these headers), but what could be the cons of sending both of these headers as it is? I tried to read about these content-negotiation headers but could not find any information about them in internet. The internet says that we nee... |
According to Is this a violation of the Liskov Substitution Principle?, as I understand, the top answer currently says the code below is violating "Liskov Substitution Principle":
public class Task{
private boolean isStarted;
private boolean isClosed;
public void close(){
isClosed=true;
}
}
pub... |
I'm working on an Excel tool that needs to synchronize with a CRM via its API. The CRM's API authentication process involves logging in with a username and password, after which a session key is provided for subsequent API calls.
My primary concern is about securely handling this session key:
Authentication:
How can I ... |
I have more than 10 years of experience as a web dev. Mostly do Front-End stuff, but I also do backend for personal projects. I never had this kind of bug in my app that required clearing the cookies to fix the issue. And this happens a lot with a commercial website that I use, if something doesn't work the support say... |
Regarding my last question: Can 1.0.1 be launched right after 1.1.0?. I learned that releases can be maintained in parallel using SemVer and it is possible to apply it using Git Flow (Reference: Post of Vincent Driessen, https://nvie.com/posts/a-successful-git-branching-model/), of course, doing some adaptions to bette... |
At first I had the following logic of user creation:
class UserService {
constructor(userRepository, postRepository) {}
createUser({user}) {
this.userRepository.create(user);
}
}
Then I also got another use case when while creating a user we also have to create a default post for him. The new use case shoul... |
I am working on a code library containing data structures and algorithms for solving parameter optimization problems. A parameter optimization problem is a problem of the form: given a vector of parameters P, and a loss function L(P), find the vector components of P such that L(P) is minimized. The implementation of th... |
I am rewriting a streamlit app that is an interface to a laboratory management system (LMS). This means, that I have to make a lot of requests to that LMS through its python library (PyBIS). The way that library works is, that I import a class and instantiate it, and then call a method to login to the server. This logi... |
As an embedded developer, I often write drivers for hardware (though this question really applies to any shared resource). The "standard" interface I have come up with looks like the following. As an example, I will showing an interface for a "Voltage Probe."
class IVoltageProbe
{
public:
virtual void enable() =... |
I would like to have a series of small stand-alone services that would either consume a Kafka topic and output the data into a different system or the reverse: receive data from a system and produce Kafka messages. What would be the right approach for such applications?
Example 1: Converting a SQL query result into a s... |
I am looking for a complete pattern implementing cache-aside when used in a distributed system across multiple nodes read/writing from/to cache.
Specificly how to avoid making multiple requests to db and multiple writes to cache of the same data when all nodes concurrently encounter a cache miss
The problem described i... |
I need to refactor a class that became too messy. The class has a method that reads some raw data from one of our repositories, and another that "filters" it:
The data is in the form of level and on/off, for each X*Y of the units we have.
The filtering process lets some of the data pass in the raw form, changes a small... |
An asymptote in mathematics represents a value (line) to which the observed function constantly approaches. In other words, as the value of X increases towards infinity, i.e. decreases towards minus infinity, the value of the function approaches that value/line (asymptote).
When we talk about the big O notation, such a... |
I have to create a service/app which allows creation of custom report templates & schedules using those templates(like create the report daily) that will generate the report in a the specified format (CSV or PDF for now) and send it onto a fileserver through SFTP. The backend database is Oracle, rest of the stack is in... |
I'm working on a small project and I'm randomly generating "world maps", with nodes you can fast travel to along given routes.
The basics of this aren't complicated; throw random points on a 2D plane and run a Delaunay triangulation.
However, this leads to quite densely connected maps; there are convenient routes liter... |
I am new to Dart/Flutter and try to use the Bloc framework for my current project. I am now at the point, where the data, especially in states, is getting more complex.
For example: A certain state holds a big list of items. The items itself holding other items which are holding certain properties etc.
From other progr... |
UPDATE: Myself and the business unit leader were able to make enough noise with the bosses such that the vendor has agreed to prepare User Stories for the work they have done and also for all new work going forward. The bosses did NOT seem to ever care about the whole "Agile" angle so it wasn't a selling point for them... |
In my library I've got a Logger class that is a wrapper around spdlog, that I use internally for logging. Logging is enabled by default in Debug builds and disabled in Release builds, moreover user can force enable logging in Release builds via CMake option. Also logging level is spdlog::level::trace by default.
There ... |
I'm designing a database where a user can add notes on diffrent entity of the application.
For example, the user can add a note on the project and/or on the project line. The note added can have different type, even if are on the same entity.
For example, I add a note on project, I can mark it as "Customer follow-up".
... |
TL;DR I want to change the way our current enterprise code base is constructed to utilize NuGet packages for the inter-project references, but that seems to present some challenges when considering how that affects the team development environment. Please see the various sections below in bold for the details.
Forgive ... |
There's a section about use of checked exceptions in Josh Bloch Effective Java and I find it a bit abstract to understand what he means by saying "when a user can recover from it". Authentication eg. can fail if credentials are wrong, but I wouldnt want to crash a client if a user provides wrong credentials. So is here... |
In our company we have a monolith. Right now is not that big but we are already seeing some problems with the isolation between the modules we have. Our setup is pretty similar to other Django backends: we have a common User model and another UserProfile model where we store additional information about the user. As an... |
In chapter 9 (Testing) of the book Building microservices (2nd edition)
Author suggests using a Fan-in approach to have a single shared E2E tests for all microservices. This way tests of unchanged services doesn't have to run again and make the whole process faster.
Question is,
Lets assume "Web shop" service is runni... |
If you have an OO language, where every object always has a copy method, shouldn't that be deep copy by default?
In most languages I know, such a copy method is shallow, since a shallow copy is more lightweight, of course. It's faster, it requires less memory, and it's quite often sufficient. And when you ask for deep ... |
Question Summary
I am writing a program that will run on a Raspberry Pi 4b+ designed to manage hundreds of LEDs, as well as a few other devices (such as small motors). This is for a project I am a part of- a LEGO City designed to simply and accessibly demonstrate cybersecurity issues in a model city with the modern tre... |
For example, for base and child classes, if all child class need a class member, eg: baseHp, which represents the base hp to calculate the actual hp of monsters in a game:
public class Monster{
private int baseHp;
private int lv;
public int getHp(){
return this.lv*this.baseHp;
}
}
public class ... |
So this is a basic question that was asked by a junior developer (not in these exact words). He had worked on a feature which was used in multiple projects. The main feature can be easily isolated and written as a library and can be used in three projects. The feature was basically showing a regulatory dialog when the ... |
I am writing a API endpoint in NodeJs, The code is roughly like this:
function myApi(myUserId, userIdToDelete){
if ( checkIfIAmAdmin(myUserId) ) {
deleteUser(userIdToDelete);
}
}
Now, checkIfIAmAdmin() and deletUser() perform database operations, but as you can see, not atomically. This means that bet... |
This is the situation that I've seen two times in a row already.
A company makes software intended to be sold to other companies. So there will be relatively few clients, but each is an important one. An obvious, though by far not exhaustive example of such software is an ERP system.
Now each client company has their o... |
I am creating a C++ library (more of a passion project to be honest). Its aim is to enhance the existing unordered_map STL by giving it indexing abilities and range-based loops, based on the order of insertion.
For example, if I have an unordered map with the following order of insertion:
key1 -> val1
key2 -> val2
key3... |
Suppose we are writing an interface class which has some "properties" and "operations." Assume also that every concrete implemented of the interface must contain the same set of properties.
There are two ways (that I see) of expressing this interface in code:
Option 1
class Interface
{
public:
virtual void doSomet... |
I want to create an endpoint for posting different types of commands. I have the option to have one route /commands which can be used for every command type or one route for each command i.e. /commands/commandA, /commands/commandB etc.
Which one of these approaches is favourable or is it a "it depends" case? What are t... |
I am trying to get a better understanding of TDD. From a quick google I've found this:
In layman’s terms, Test Driven Development (TDD) is a software development practice that focuses on creating unit test cases before developing the actual code. It is an iterative approach combining programming, unit test creation, a... |
I know there are some questions about boolean flags: Is it wrong to use a boolean parameter to determine behavior?, Multiple boolean arguments - why is it bad? which indicates the following code is bad:
public void myMethod(boolean b){
doThis();
if(b){
doThat();
}
}
myMethod(true);
and should be re... |
I have a rabbit queue that I use to communicate between applications.
I have a chain of three message.
App 1 generate and push a message in rabbit(message 1)
App 2 catch the message and generate another message(message 2)
App 3 consume the message 2 and generate message 3
I have in each message
Correlation Id, is un... |
I have a specific domain entity that has a given type and some attributes. Based on the type, it can have another set of type-depending attributes. Normally, I would create a class for each type and define the type dependent attribute on the specific classes and the common attributes on the parent class:
class Abstract... |
I'm a self taught developer just in my teens about to start my first major project for myself. I'm looking for architecture advice as I want to do this the right way.
I'm worried I'm overcomplicating this by building it myself when something like gRPC can maybe solve this?
I'm looking for a way to have many application... |
Each time a user of my APP / website interacts with the APP such that it makes an API call to the backend, the backend will make an API call to the mongoDB database to retrieve the document that holds this user's data. This user object currently sits at:
Buffer.byteLength(JSON.stringify(req.user))
9871 bytes, which is ... |
The C++ "standard" method for serializing and deserializing a data type is to use streams with the insertion (<<) and extraction (>>) operators. This has some flaws, but it does neatly allow you to use the same semantics to write anything to/read anything from a stream simply by overloading the operators.
However, I s... |
Normally, when a static value is used multiple times in a Ruby context, you'd define it as a constant. However, in some cases, the context is a block for some DSL at the top level of a source file (not within a module or class). I've run into this in various situations, but recently it's been ActiveAdmin:
ActiveAdmin.r... |
At the core of my business (say, an online store) is a Postgres database that stores products and transactions. During day-to-day operations, the load on the database is not heavy.
However, there is now a need to implement dashboards, compute more metrics, generate reports and so on. Computing these statistics puts a ... |
I'm a software developer and new to data engineering, so this may be a newbie question, but I'm wondering why data integrity checks (for instance, dbt tests) are ran on the data warehouse, rather than on the data sources themselves.
For example, I have an app that runs on MongoDB. Let's say I want to do reporting on th... |
When I did a small project in school about writing a document for Online Auction System in OOAD (Object-oriented analysis and design) courses, I had trouble with multiple Auction viewing use cases that have similar functions.
My auction has 3 states, pre-approve (wait to approve by admin), open, closed. The bidder need... |
I am watching a tutorial about ECommerce Website with .Net Core - and the project is of type Web Assembly Blazor and I checked the .NET CORE Hosted, so the project spited to Client, Server and Sheared.
And the Cart model is consists of CartId, ProductId and UserId.
public class CartItem
{
public int Car... |
One major reason for using composition over inheritance is, that inheritance leads to higher coupling. How is that?
In both cases members are exposed to the subclass (in case of inheritance) or wrapper class (in the case of composition).
Compare the following modifications for the base class for inheritance (AnimalInhe... |
GIST:
PUT is idempotent PUT is used for updating/creating a resource.
POST isn't idempotent. POST is used for creating a resource.
So, I'm wondering what should I use in this case and why?
I want to send firebase cloud message notification (FCM). Should I use PUT or POST request? What'd happen if I use PUT or POST? Bel... |
For background, the question is to prepare some training material, which should also should explain a bit why the things are the way they are.
I tried to get some idea of how C began based on this tutorial.
However, this does not give the answer and already has more in the language than I expected.
I learned at univers... |
I am currently implementing a library in Rust that implements a proprietary serial protocol.
The protocol specifies several enum values, that mostly are returned by the hardware as u8s (bytes), but not any value that such a byte can take is a valid enum value, e.g.:
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Ord... |
Let's say that I have a class called Mission. This class is intended to represent a mission requested by a professor working in a faculty. Mission has a private enum field representing whether the mission is PLANNED, IN_PROGRESS, COMPLETED, CANCELED, ABORTED, etc.
There are some things that the specs require to be doab... |
I took out the request for a paper, thank you for spending so much time on this.
hopefully this edit is better.
I use the word "complexity" meaning "cyclomatic complexity" so if you want me to put that all in there i will. I am specifically looking for an academic paper also, and I think that's relevant to engineering... |
Consider the domain entity, Order, which can be persisted by the OrderRepository. Orders maintain state that is stored in the database. However, it does not expose all of it directly. That is, parts of its private state is not accessible in the repository, when it should be mapped to database records. How does one go a... |
Recently I've come to discover that I've inherited one of the internal auxilliary programs used. I've made a few minor fixes and features to improve it in the past, but now I've been given a major feature that requires significant overhaul in order to implement.
This code has a recurring issue with overzealous try/catc... |
I'm trying to understand how Auth flows work within VueJS/Express Server to a protected API.
I have a situation where I need to call an API that is protected by JWT. To get this JWT, a client ID and secret is sent to an auth server which returns a token which is then passed in the header when calling the protected API,... |
I need to pass exactly event (not a lasting state) over communication connection that can provide boolean or integer value, possible to set, clear and observe by both sides. It is OPC UA framework but I do not have access to OPC UA "methods", only to variables.
It initially looks simple: we can have the boolean that is... |
I don't know the name of this pattern but what is the purpose of such methods:
AddOrUpdate
GetOrAdd
instead of single-operation ones?
|
According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I know I should declare the most abstract type possible, so for example:
public interface Fruit{
}
public class Orange extends Fruit{
}
when declaring Orange, I should write "Fruit obj=new Orange();" instead of "Ora... |
I'm working on a module that handles colormaps and I want to make the mapping of pixel to colors as efficient as possible. It is a performance critical section of our app. Our current solution works like this:
I have a normalized double value x (range [0, 1]) per pixel that denotes the position inside the colormap. The... |
I am interested to know if there is an existing algorithm to start a multiplayer game, for example, poker. What steps do we need to take when the player enters the "matchmaking phase"?
I expect something like:
Player N enter the matchmaking room.
The player is saved in a database in "Waiting" status.
Every 10 seconds,... |
In my new job, I'm getting a hard time understanding how they want to model things... they are using Domain Driven Design. For example, I come across this kind of code:
$userRepo = new UserRepository($this->userModel);
$virtualClassRepo = VirtualClassRepository::fromModels($this->virtualClassModel);
$user = $userRepo... |
In my current Java project, there is such style of integration test:
@Test
@Transactional
public void testBusinessTransaction() throws Exception {
//...complicate set up code and execution code
assertEquals(expected, actual);
}
Question:
is using the @Test in combination with @Transactional suitable at all, e... |
We're building an application that needs to log into a website using built-in credentials. It's not optimal to say the least, but we're stuck with "knowing" the username and password beforehand (hence stick them into the application somehow) and can not rely on runtime user information.
So I went through this stack ove... |
I have a Post domain model object with the title, body, and author attributes. It is persisted in a datatable with the id, title, body and author_id columns. I have left the ID fields out from its domain object because these fields seem like a persistence concern, not something that my domain object needs to be aware o... |
I noticed how our codebase contains multiple versions of the same method, which unmarshalls the inbound byte-stream into java objects and that the only difference between the current and previous version is the one variable change. There are roughly 17 versions, which are all chosen based on one big switch case. Simila... |
I'm writing a Python CSS-selector library that allows one to write these kinds of expressions in Python as a pet project. The goal of the library is to represent selectors in a flat, intuitive and interesting way; all valid syntax defined by the Selectors Level 4 Draft must be supported, in one way or another.
# lorem|... |
I’m currently trying DDD with establishments’ opening hours:
OpeningHours is an aggregate root; it ensures its openings don’t overlap
an Establishment can be set many opening hours (like summer’s, winter’s…)
an establishment’s opening hours can change on specified dates. Such a change would be coded as an OpeningHours... |
Imagine that you have a large monorepo code base running as a monolith application. This application is backed by a database. Some of the data in the database is sensitive, so you want to restrict access to it to decrease the risk of developers mis handling it. Essentially, you only want to allow specific chunks of cod... |
A few years ago, I wrote a simple web application in PHP without a database. Until now, it was running on a basic Apache server. I'm not a professional developer; I'm more on the system side.
I haven't had the chance to work on contracts with DevOps infrastructures yet. To better understand containers' operation and be... |
I have a situation like the following:
int fds[2];
pipe(fds);
// Write lots of stuff into fds[1]
close(fds[1]);
do_stuff(fds[0]);
// Should I close fds[0] here or at the end of do_stuff?
Which one is better to do?
|
I have a replicaset with two pods in an onpremise kubernetes. Is it possible to setup an active standby setup so only one pod receive requests and the second one stay in standby mode and takes requests only if first one is down? I don't find anything on the web on how to setup this.
If we can do active passive pattern ... |
Since March I switched jobs and became the Tech Lead of two teams that work on a shared codebase and a separate codebase for "region" specific implementations.
This team works using NestJS, which encourages a sort of Onion Architecture / Hexagonal Architecture + DDD. At first, I saw this as an overengineered approach, ... |
I am developing a website somewhat like leetcode, however, it will be for website testing using Selenium WebDriver.My service will provide different websites, along with various tasks that describe what to test for on the provided websites. The users will write selenium scripts, which my backend will compile and execut... |
Let's assume i app have with basic flow:
Client send request to server
Server do some business logic
Server puts message into some message queue
Server returns success to the client
microservice A reads the message from message queue and process it - be it some email
microservice that generates and sends email to the... |
I am contacting you today regarding a recent problem with circular dependencies. It's about a Spring boot application that accepts data via a Rest API and then forwards it to an internal Spring service. When a new vehicle is to be created, then first a CarDto is submitted via Rest. The controller uses a car mapper (Map... |
On GitHub, when an issue in small project calimero mentions an issue in big project godzilla, a backlink message appears on the issue in godzilla. For example, suppose a hard-to-fix bug in godzilla affects many dependent projects, which all implement a workaround while referring to the godzilla issue in their PRs. Th... |
Suppose an application records a version marker on some data.
For example a database application might record UPDATE_TS as a datetime when a record was updated.
It could just be an integer version counter but the important point is it's guaranteed to change for each version and (for all practical purposes) never repeat... |
We deploy microservices in Kubernetes environment.
For providing a solution to a business use-case using microservices,
Is the idea of service registration and service discovery not an anti pattern? where the scenario of starting microservice depends on the availability of other microservice
For example, using API comp... |
I often write code to implement the dispatching and handling of "messages." My requirements are usually:
I should be able to add new types of messages AND/OR new types of handlers without affecting the existing messages or handlers (i.e., loose coupling).
Every handler can choose which subset of messages to "handle" ... |
I'm writing a math library and I've encountered trouble with floating point imprecision. I want to know if there are any standard workarounds that are used often. I have doubts about my current method and my lack of knowledge and terminology when it comes to these floating point errors emphasizes the doubt.
Specificall... |
Suppose, I have a tensor tfDataSet as follows:
data3d = [
[[7.042 9.118 0. 1. 1. 1. 1. 1. 0. 0. 1. ]
[5.781 5.488 7.47 0. 0. 0. 0. 1. 1. 0. 0. ]
[5.399 5.166 6.452 0. 0. 0. 0. 0. 1. 0. 0. ]
[5.373 4.852 6.069 0. 0. 0. ... |
According to Why is Clean Code suggesting avoiding protected variables?, I should avoid protected variables because of the reason : "closely related concepts should not be separated into different files", that means, for example, if all Animal must have an _id field:
public class Animal{
protected String _id;
p... |
I have two different options in mind:
def foo():
try:
# do something interesting
except:
# report error here
return bar
bar = foo()
or
def foo():
# do something
return bar
try:
bar = foo()
except:
# report error here
Is there a preferred way to do this? If so, is th... |
I have a Spring service that acts as an adapter for another service in my company. The service receives a request to generate push notifications for a given user and needs to call the other service for each device token associated with the user. The request payload to my service and the payload required by the other se... |
I found this Python code implementing Double Metaphone, and it basically has a bunch of if statements handling each letter, though I'm not exactly sure the decisions that went into each branch yet. But the output are two hashes of consonants it seems.
result = doublemetaphone('Jose')
self.assertEquals(result, ('HS', ''... |
Folks,
I am wondering if there is any dis/advantage to using json objects as message keys.
Assume I have 2 event streams coupled with 2 tables in a source system. Each of those tables have its own business keys;
Product table has product_number and base_product_id as business key in the source system (key: product_num... |
In a Java open source project built with Maven, is there a standard way to declare code style settings (such as indentation settings and import order)? I would like that people who import the project in major IDEs (such as Eclipse and IntelliJ IDEA) are able to get their editor configured to follow those settings with ... |
Our coding standards for C include various prefixes for data types, constants, static/global variables, and pointers. These prefixes were originally introduced for code review purposes, but with the convenience of modern IDEs, which provide type information through highlighting, we are questioning whether it is still a... |
I've recently created a library that needs a non-text (but platform agnostic) resource to be used. I basically tell CMake, if this is an install interface, it's in the "${CMAKE_INSTALL_INCLUDEDIR}/resources" directory, otherwise it's in the "${CMAKE_CURRENT_SOURCE_DIR}/../resources" directory. Then I generate a heade... |
I have an event class that holds details of a volunteering "Event" class. There is an "EXCO" Class that can create and edit details of said Events. There is also a "Volunteer user" class is allowed to register for such events.
My initial approach to this was to have a "Event DataBase" Class that holds an array of Event... |
Let's say I have a table for storing users. In this table, I have data like id, name, address, bank account and birthdate. Also, I have two domains in my codebase; in one of them, I need a user entity with id, bank account and address; in the other domain, I need a user entity but only with name and birthdate. The firs... |
Over and over I am faced with a similar problem: I have to perform two actions that are mostly unrelated, except that they need to share a mutex lock, at least for a moment. For example:
void action() {
doStuff();
cleanup();
}
//Somewhere far away:
std::mutex p;
void doStuff() {
std::unique_lock lock(p);
... |
In legacy code bases, some APIs might be encapsulated by different developers with separate classes many times. Example:
public void calculate(int baseIncome) {
revenueCalculator.calculate(baseIncome,company);
}
and the RevenueCalculator looks like this:
public class RevenueCalculator {
public void calcualte(int b... |
A recurring pattern which I see in my code is chaining together a lot of functions. This is the result of a large number of processing steps needed for a given task. This could be e.g. a data processing and visualization or my most recent example:
For some financial analysis I want to read in a couple of pdfs which are... |
Suppose we are building a REST API with ASP.NET Core. Suppose there are 3 projects in our solution:
The ASP.NET Core Web API project.
A class library project for the businnes layer.
A class library project for the data persistence, using EF Core.
The first one contains all the controllers and actions, dtos, etc. It w... |
I've started working on a C# codebase. There are three services which run the same set of steps of three kinds of objects, each returning IResult:
public IResult FooService(Foo foo) { ... }
public IResult BarService(Bar bar) { ... }
public IResult BazService(Baz baz) { ... }
Foo, Bar, and Baz share common properties,... |
I am writing an application that receives different kinds of messages from an external device. The messages are of different types and they are received from the device in the form of a string.
For each message type, there exists a DTO object representing the parsed message, and a parser class which parses the string m... |
These days, I see people always extolling the benefits of using Static Site Generators (SSG) for building static sites. Why would I not just write the HTML/CSS myself? What's the advantage of using an SSG, such as Gatsby?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.