instruction stringlengths 34 36.1k |
|---|
I have a Node.js micro-service architecture-based back-end. Services communicate with each other via PubSub. E.g. upon a request to service A, service A messages either service B or service C via PubSub. B and C can message other services and so on.
What exactly is to happen is for the user to decide. The problem is: I... |
I have a question about where should I get the info required for making an api call.
Let's say I have this :
Presenter --> Use Case --> DataSource --> Api
Ok now to do my api call, I need a userId, languagueCode, etc.. for instance, and I have use-case to get that info, also a datasource . My question is, where should ... |
I need to consume several APIs concurrently. In order to do that I decided to containerize each API client code and manage them using Kubernetes. Some of those APIs need to be "walked". They basically have this one endpoint from which you get more endpoints and so on. These "trees" are not that deep, but are constantly... |
We are using microservices(read a lot of GIT repositories) and our department has 90+ java developers. All of them write code which mean there are a lot of PR`s every day. We are using BitBucket and Also we have a self written bot that listen BB events and can sends a PR review notification to slack.
Notify every devel... |
Our team has started to use AWS and one of our projects will require storing approval statuses of various recommendations in a table.
There are various things that identify a single recommendation, let's say they're : State, ApplicationDate, LocationID, and Phase. And then a bunch of attributes corresponding to the rec... |
I'm having trouble with modeling the association between movies and DVD disks - it's my homework for university.
So I have a "Film" class and a "Disk" class.
One film can be on multiple disks (at least one)
Each disk can have only one film
Is my diagram correct?
Perhaps the second option is beeter?
|
I have an app with many individualistic features which behavior is controlled by settings.
Let's say these are a few utility services with the following settings that are historically stored in separate JSON files.
Property values can be bools, integers, doubles, and also some complex types such as lists of JSON object... |
I want to know is if we should perform authentication at the API gateway, at the individual service, or both.
Let's frame this question and descussion in the context of new development. Specifically, in my current scenario we're rewriting our software to be a SaaS offering in the cloud using current technologies.
I don... |
I have a database full of ModelNumbers that I want a user to be able to search for. The tricky part is that some of the model numbers have lots of funny characters including:
* - Alphanumeric wildcard
# - Numeric wildcard
(AB,CD) - List of options
So for example model number 1234#*(AB,CD)
The following searches shoul... |
Considering this question and the most upvoted answer, and his specific example of
public static final int THREE = 3;
might it make sense to allow this sort of usage if we added units to the declaration? I mean like this:
public static final int THREE_MINUTES = 3;
or maybe this:
public static final int THREE_GALLONS... |
I am developing a REST API and I would like to allow the users to remove a field of the object through PATCH.
My idea was to use a null field on the PATCH body as a signal to remove this field of the object. Is that a good approach? Is there a better way to allow a user to remove a field from an object using a REST API... |
One of the alternatives for managing common data between microservices is replicating the data needed by multiple services in their own databases but there are large data sets that we do not want to replicate.
I'm using as an example the Food Ordering Application used in the book Microservices Patterns by Chris Richard... |
My question is about DDD, the Infrastructure layer, it's relation to the Domain, and specifically how we can take advantage of the ability to "swap out" one persistence implementation for another.
I have a .NET5 solution designed using Onion Architecture, that follows all of your basic guidelines:
A Domain layer with ... |
Suppose user A creates a private resource at, for example, /books/somebooktitle
If user B attempts to access the resource at /books/somebooktitle what code should be returned?
HTTP403: Permission denied seems obvious BUT, does this not leak information to user B that someone has created a book and named that book with ... |
Where do you like to draw the line for modeling a single value as a Value Object v.s. a primitive? For example if I have an internal order number and a customer order number, would you model them both as Value Objects even if they only contain a single string attribute and no special validation? I see the benefit it ad... |
I'm looking at Segment's documentation right now and they have something called a "write key" that you include in your client-side JavaScript in order to send analytics data to the backend. If I include Segment in my website, what stops one of my customers from copying my write key and sending spoofed "analytics" data ... |
I am learning about various causes that lead to software failures. So far, two prominent causes of failures seem to be managerial and technical. An example of the resources I have looked at is this file. But I am looking for a more specific explanation.
Could you please give me a short, comprehensive explanation about ... |
You have the backend for a web application. I'd like to keep this is as disconnected from specific programming lanuages as possible, but if necessary, assume we're talking about PHP.
You need to write code that generates or fills documents with data from a database, so that these documents can be stored as files. These... |
Not sure if this is the correct forum for this question - but I could really use some advice.
I need to design a system (within certain constraints).
The system must implement the following logic:
A producer will drop JSON messages on a Kafka topic for me to consume. Each message will contain an image (something like ... |
G´Day,
So I am making this website out of basic HTML. I wanted to add a Moderator/Administrator script for it and was wondering if there was any way I could Create a script myself easily. (Keep in mind that I only took one Web Design class and im still in High School.)
I did have a look at How can I design an efficient... |
I'm struggling to understand how, for example, the IETF is a "standards organization" but the standards are "voluntary" meaning there is no civil or criminal penalties for not following the standards.
I don't understand how those are standards. Why would anyone follow them?
|
I have been searching about this topic for a few days and have not yet found anything on books, courses or tutorials.
What is a way to make data pipelines more scalable, that doesn't involve NoSql or major investments like hadoop clusters?
Most of our pipelines are currently made with Python. They're pretty simple in n... |
I have a checkout process that 1) creates a user account in Stripe and my database, 2) creates a paymentMethod in Stripe and logs the last4 in the database, 3) creates the subscription in Stripe and logs the subscription to database, 4) sends welcome email and creates a job record in the database to build the service f... |
In a design book I was reading they describe a method to determine a database sharding scheme by taking the hash (MD5, SHA1, whatever) of a userid (integers or uuids) and then (whether encoded or not) doing mod shard number.
So it looks like this: Hash(userid) % number_of_shards.
The output of the hash function includ... |
My bot currently listens to new messages coming in, and if a message contains a keyword (different from a command) it will automatically log information about who posted that unique key into a database. If another person in that same server posted the same YT video, the bot would flag it as a repost (and reference the ... |
Note: Controller here refers to one from MVCs
Bear with me, I know these are seemingly unrelated. However, I'm inclined to think both are analogous to each other being that they're means to the same end (i.e. safe product release).
Background: you want to safely push new updates without breaking existing product. Assum... |
I have a $c variable that is calculated at the beginning of the request. After calculating this several nested methods use it as a part of their job. Is it better that I pass down the $c variable to every method or store it based on the request (cache it maybe?) and use the stored value in each method to get the value ... |
At my current workplace there are some projects that when preparing a release will
backup the current RELEASE branch by making a branch from it with the current date (this isnt technically required, so this is optional. It does happen more often but its not 100% of the time)
delete the current RELEASE branch
take the ... |
I'm trying to design a system that inject configuration of each component into each class.
project structure:
|features
--|component-a
component-a.service.js
component-a.config.json
--|component-b
component-b.service.js
component-b.config.json
--|component-c
component-... |
I want to know how variables are stored in JavaScript (what I mean is, how JavaScript stores the type and the value of the variable and stuff like that).
But I was only able to find a tutorial about how the first version of JavaScript stores variables. Do newer versions of JavaScript stores variables in the same way as... |
I am working on a course design and I'm preparing the project that the students will have to work on all along the course.
Each student will create a GIT repository a the beginning of the course and they will add files and modify them to add features as they learn new things. It has various milestones that will happen ... |
If you wish to perform the same action using different parameters, you can either make differently named functions:
public Apple findAppleById(long id){
return repo.findById(id);
}
public Apple findAppleByCultivar(String cultivar){
return repo.findByCultivar(cultivar);
}
Or you can overload a function and make... |
I want a configuration file for a .NET program.
This file is to configure pairs of regular expressions.
The regular expressions belong within a hierarchy of sections.
Section1
SubsectionA
regular expression
regular expression
SubsectionB
regular expression
regular expression
Sect... |
Well in a page in our spa application we need to request some dynamic data from the server. Besides this data for display purposes we also need to request explanations of the columns from the data (each set of data might have different columns which are not static).
Normally in any application those are two distinct th... |
I have a Java library which is deployed automatically to Maven central. Right now this library has Java-1.8 target SDK, I want to continue releasing source code with this target and add new target Java-17 with Java module support. Source code will be compatible with Java-1.8 versions, so both releases will be built fro... |
I'm writing an application in C#. I'm facing an InvalidConstraintException, but from that Exception, I seem not to be able to access the Constraint, causing the Exception. That specific question is currently being handled on StackOverflow.
Just out of curiosity, I've written this piece of code (don't laugh):
int a = 2;... |
C#'s primary error handling mechanism are exceptions and try pattern.
We don't have access to discriminated unions yet like in case of F# and Rust Option<T> and Result<T, E> types.
The official Microsoft guidelines mention that exceptions should be avoided for errors that can happen often.
The try pattern works only fo... |
Let's say that I have a service like that takes in some text, classifies it, and then outputs the classification. The critical path between entry and classifier is as follows:
Query -> QueryPreprocessor -> ML Model
Now, I've obtained some ground truth on a random set of queries, and I want to retune the classifier base... |
I'm working in a microservice application which has some level of coupling between the microservices (some of them talk with each other via rest api - I know it is bad, but it is what it is; also I think this question would still be the same if we changed this microservice intercommunication problem with the normal fro... |
Is it under the rules of REST to return a different model of 'order' if someone call:
/me/orders/222
Return values:
- OrderId
- Price
or
/customers/111/orders/222
Return values:
- OrderId
- Price
- Tags
- Risk
- Comment
Maybe the model of 'order' should always be the same instead of different endpoints? Or it can d... |
I recently joined a new company. After working on some projects I noticed a pattern. Every project contains a lot of static classes. A lot of static Helper classes. ApiHelper JsonHelper UmbracoHelper ContextHelper DbContextHelper. Etcetera.
Now I know that this is not a good sign, and I tried to explain. They really wa... |
Hello im about to create dasbord for my website..
Dashboard will have multiple subpages like users, posts, roles etc..
I was thinking i would use only one rest api endpoint for those resources like
/admin/{users}
/admin/{projects}
/admin/{roles}
and create enum for each of those which will be used later on to query dat... |
I’m currently writing a software for my company (3rd world country), and I wanted it as simple as possible to install and maintain, so I started with Qt and no server app beside the database, (MariaDB or MySQL). The app is made to be used by different users on the same machine.
The app the communicating directly with t... |
I have worked with Git workflows where we release from dedicated branch specifically used for release (e.g. Gitflow's master/main branch). In such workflows, there will be multiple (at least 2) long living git branches. One for development (called develop), and one for releases (called master/main/release/production).... |
I've got a class which stores two data series like so. I need to do some complicated processing on each of these arrays, but for now we'll just get the average of each data series. I could either do this:
class DataMangler
{
private array $dataArrayA = [];
private array $dataArrayB = [];
// stand in for co... |
I know this question has to have been answered in countless ways before, but I would appreciate some help pointing me in the correct direction.
I am developing an embedded system that receives "commands" over a communication line. Obviously, in the OOP world, a specific type of "command" could be represented as a spec... |
For a paper I am writing, I need to find the origin of the following two phrases:
Code against the interface, not the implementation
and
Test the interface, not the implementation
(Note: the second is more important to me than the first.)
I googled around, but was unable to find anything. Apparently, everyone knows... |
I have experienc with designing relational dbs but first time attempting to store JSON in a mysql table. I am using mysql 5.7.8 which has the ability to store json data type as a column.
When I create the schema for the table should I have two columns where one column is a key and the second is to store the JSON docume... |
I have read that the null data type in JavaScript is a primitive data type, however due to a bug or something in the first version JavaScript, null is considered to be an object.
However, let's assume that null is a real object (and not a primitive data type like it really is), what does that mean exactly, i.e. what do... |
I need to write continuously into a JSON file in C++. The format and structure are defined as requirement. The data is produced in the process itself and needs to be stored multiple times per second. It's actually a protocol of realtime data.
Structure is basically:
[{Object01}, {Object02}, ...]
With every tenth of a s... |
The context
I have an IoT project where the sensors are sending data to my Postgres database. The sensors are manages by a stand-alone service which provides a REST API to query various information about the sensors (e.g. are they online).
I would like to have a unified interface for querying all the related data regar... |
I'm working in a large company and am doing my first Java project here. We have certain code style guidelines. In the Java guideline, it is said that "assertions are only intended for debugging and bug hunting, but should be removed in production code".
I personally like to write assertions to get notified of invalid p... |
How should I go about using TDD and writing tests in this scenario?
Suppose we have request handler classes. In short, a handler applies a "request" (e.g. Update details) to an entity then saves the result to the repo.
However, the existing handlers follow this sort of implementation pattern (simplified):
// You can sa... |
A particularly nasty bug just happened to our software. (JS/react something was preventing onclick from firing about half the time - turned out a constant rerender was happening). This wasn't really easily to solve and the culprit wasn't found easily. So the way the bug was found was by going back in history till the c... |
I have an app where certain data is stored in the database. Multiple users access the same set of data (similar of a collaboration tool). However, they can non deterministically work on stale data. For example, if there are three work tabs and someone is working on tab 1, it may not matter to him if tab 2 is modified. ... |
I want to execute everything in a user context. Meaning that if the request comes from one user then the service has a token of only this user and can't execute anything for another user.
Now the problem:
Service A publishes a message to MQ which is consumed by Service B.
Service B then makes a REST call to Service C t... |
If my service is inserting into a varchar column with a certain max length, I can either
validate its length prior to inserting to avoid getting an error from the database if the string is too long
try inserting it as is and then handle the error if the database say it's too long, and giving the consumer a validation ... |
Based on this explanation of multi-tenant architectures here:
A multi-tenant architecture is one where a single software instance
and database serves multiple customers
I cannot fathom how it is preferable to have a single database instead of spawning a single/multiple databases per tenant?
I would think that it shou... |
I am building an app (.NET, but whatever) which is supposed to be able to send notifications to users.
Each Notification can either be a Reminder or a Newsletter, and I'll possibly add more types in the future. Each type is handled differently. Reminders are periodical, so I need to keep track of who is reminded of wha... |
Many programming languages have an implementation language (mostly a system language like C) which is used to implement important parts of the core of the language. Besides the libraries are written in the language itself (like Ruby or Python). My question is for an interpreted language like Ruby or Python, this means ... |
Lets say we have a table 'A' with 4 referenced tables : Table B,C,D,E
In our Data Acces Layer we could write a method that returns Table A containg every entity of B,C,D,E by joining in order to reuse that method in bussnies layer.
Is the better aproach just creating a new method for every query you need? For example i... |
Sometimes the UML component diagram contains a database component. Does this database component represent a class that programmers create (which includes host, username, password, port... DB connection with PDO, SQLI... etc.) or does it represent the real, entire database?
|
I am looking for a way of dealing with the following situation:
1- Have an items collection in MongoDB
2- Have a users collection in DynamoDB
3- Each document in the items collection has a "reference" to a user or multiple users via an id attribute of the DynamoDB.
4- I need to query the items collection and populate e... |
I have a project written in python that I would like to create unit tests on.
This project has a dependency on a database project which is a sort of abstraction layer to data connections.
The issue with this db project is that it's huge! So when I want to run the unit tests as part of a continuous integration pipeline ... |
I'm trying to implement a project using the Onion Architecture (aka Hexagonal, aka Ports and Adapters, aka Clean Architecture).
I understand that the user interface uses Service interfaces instead of the actual implementations.
I also understand that if a Service needs something from an external source (e.g. a database... |
I have been trying to come up with a method to "serialize" various objects into various different formats. For example:
class Shape {
public:
virtual std::string_view name() const = 0;
virtual double area() const = 0;
};
class Square : public Shape {
...
};
class Triangle: public Shape {
...
};
Suppose I ha... |
I have javascript script that creates the same div everytime the user clicks enter and then set the event listener to the new input in the new div.
example:
//creates the container, text and input for the new line
function createNewUserInputLine() {
var body = document.body;
var inputLine = document.createEleme... |
How can I tell if my C function is a computable function in computer science?
I am trying to write C code that would be acceptable to computer scientists in the field of the theory of computation.
It looks like anything that can be construed as a mapping from a tuple of natural numbers to a natural number is a computab... |
Background
In the scenario GraphQL Federation was designed for, you have numerous GraphQL microservices in the backend, each with their own Schema Definition Language (SDL).
Theoretically, these services are able to start and run independently and can begin serving GraphQL requests right away. In order to tie these ser... |
I have the following interface:
class IHittable
{
virtual Intersections intersects(const Ray & ray) = 0
}
which will be implemented by various geometric objects(Spheres, Triangles etc).
Now the class World will look like this:
class World
{
public:
Intersection intesects(const Ray & ray)
{
auto int... |
Is it a sign that something is wrong with the code design if you end up with a layer of functions that just forward request to a component? Exposing the component would avoid this but hurts encapsulation.
An example in a C++ like language.
class AnimalManager
{
public:
int GetNumAnimalsOfType(EAnimalType Animal... |
I have a simple app for storing the movies, that exposes REST API. I am using spring-boot. I am using this simple app as an example, however, the question is more about general good practice.
I am using spring-jpa, so i have entity that represents the movie:
@Entity
@Table(name="movie")
public class MovieEntity{...}
I... |
first of all i will explain you what i want to do.
I have a Web application where are multiple rooms like Room1, Room2, Room3…
Currently active users can join in one of these Rooms by clicking on it. I handle this with socket.io rooms. That means, if a user clicks Room1, he will join this room by socket.join(„room1“). ... |
I am working on social platform with a distributed architecture. The platform should offer a chat module, but since the most efficient way to implement a chat is using websockets. I am not sure what part of my architecture should have the websockets server.
Basically, I want my system to have an api gateway component ... |
A couple months ago, Microsoft updated their C# Naming Conventions (https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions). As the developers of C#, I consider Microsoft to be the standard for coding conventions.
They want private and internal fields to be named as _myField. So ... |
I have two micro services built using spring boot,
One micro service is: "payment" Which handles actions related to payments.
Like creating a payment link.
Getting the latest status of payment and storing that information in DB (via polling). There is an UI Screen to which user redirects once payment is done and from ... |
The distinction between a spike and implementation is that the spike is designed to find things out, while the implementation is designed to make something that works.
In a spike you don't necessarily care about completeness, maintainability, correctness or ease of reading. But I'm finding, for some tasks, there is a t... |
I have an API where every time is called there are multiple calls to multiple webservices in the background, sometimes it takes up to 20 seconds to process the request calling up to 10 different web services depending the specific use case.
The API is developed using .NET Core hosted in IIS behind a web balancer, the w... |
I am focusing on learning better design and wondered if this code is good or an anti-pattern? The function Validate() returns true if the data is correct, else it will throw an exception with a message to display in a popup.
Another way could have been to return a string and treat empty string as validated, but I don't... |
Hello we have an async event-driven system (kotlin, spring cloud stream, rabbitmq) where there might be an event FooPayloadArrived, published by an ingress rest-controller.
Processing this FooPayloadArrived and publishing the follow-up result in a subscribe may take some time, let's say 1h.
Being in AWS and using a man... |
I am designing a REST API that has to deal with users and two video uploads associated to each user. So far, I've come up with two different approaches of modeling this:
Video as part of a user resource.
Video as a subresource of a user resource.
Each approach has its (philosophical) advantages and problems: To expla... |
Say I have two object types of the same interface MyObj (I am using python in this project so I will use the same for the explanation)
class Foo(MyObj):
a = [5, 10]
class Bar(MyObj):
a = [[1, 2], [3, 4]]
Now I have this other class to do something with MyObj objects. Doing this is almost exactly the same for ... |
TLDR; I'm architecting an hybrid multi-tenant app that needs to handle customizations request from customers (tenants), I'm trying to decide between modular monolith and microservices pattern, Which is the best way to handle customization reducing development costs? How should we handle customizations, I mean, How can ... |
Challenge:
I am implementing a microservice/app/applet.
Several features will be delivered
As things develop later features rely/depend on earlier Pull-Requests (PR)
Developer resoruces are finite, so a PR is not necessarily merged with main in a time-frame that permits me to commence work on the feature/next.
For in... |
I've always been taught that fatal exceptions (indicating problems that cannot be solved programmaticaly) and boneheaded exceptions (resulting from bugs in my code) should not be caught, should not be handled, should not be ignored, instead they should be allowed to crash the app. The reasoning is that once such an exc... |
I am working on a C++ desktop application using the MVC design-pattern. In a nutshell, it allows to monitor the position of a real robot in a 3D environment and create tasks for it by modifying the virtual 3D environment.
Everything in the 3D scene is a "DataObject" with properties and signals when a property change (a... |
If I have a discriminated union and want to write a function piecewise, the following code works just fine, but is taking advantage of some fairly tricky (at least to me) stuff involving overload groups:
struct A { };
struct B { };
typedef std::variant<A, B> C;
void f(const A & a) { std::cout << "a" << std::endl; }
... |
I am trying to implement a Binary Search Tree in C as a learning exercise. I have the following struct that represents a node.
typedef struct BSTNode {
int data;
struct BSTNode *parent;
struct BSTNode *left;
struct BSTNode *right;
} BSTNode;
BSTNode* create_BinarySearchTree() {
BSTNode *p = malloc(... |
I am looking for a suitable design which uses composition to allow three classes to share some logic.
The problem I am solving is that I have to read 3 different json configuration files from my application, and each file needs to have a different class that allows to filter specific data accordingly, however I need to... |
I'm writing an express/socket.io-powered game server for a web game. I have a central map of game state objects, each representing an ongoing match, like so:
// map of gameId -> game (primary holding place of games)
const activeGames = new Map<string, ActiveGame>();
Each game is an object like so:
{
players: {
... |
I read Bertrand Meyer's paper on design by contract yesterday and it is not very clear for me what is the relationship between DbC and testing, since it appears that without testing I cannot be certain all the assertions were hit at some point.
Consider a square root function that has preconditions defined that verify ... |
Is there a name related to the pattern shown in the code that follows? Or is there writing/thinking on the [design of] code shown that suggests it is an anti-pattern? In general, I'm curious if this is somehow a well known design strategy for non object oriented applications (and, more importantly, why or why not).
I s... |
I work for a consulting company and we're doing a software contract for a big company. Part of what we are doing for them is helping them figure out what they want, which means the requirements are pretty much in continuous update mode. We're busy speccing out version 3 while working on version 2 while fixing bugs in... |
I currently design an API using spring boot. In my service layer, I use Entity Manager for accessing the database. I have provided a method in my service layer below as an example.
public Object getFirstReturnDate(Long vehicle_id, LocalDateTime reservation_date){
String string = "SELECT r.reservation_time from Rese... |
Let's assume I have this API on /api/v2/persons that enables me to create new entries by POSTing this JSON:
{
"name": "me"
}
The API is implemented using Spring Boot and if someone sends this JSON ...
{
"name": "me",
"age": 47
}
... Spring refuses to handle it because it can't map the additional value of age to... |
I have a class (as a protobuf) OrderChange, that represents when an order (imagine Amazon.com) changes:
message OrderChange {
Order old_order = 1;
Order new_order = 2;
}
message Order {
OrderType order_type = 1;
OrderCategory order_category = 2;
OrderStatus order_status = 3;
// many more fields
}
enum Ord... |
Given the often wide variety of layout managers available on any particular UI platform, I was wondering if there is something akin to a "theory of layout completeness" that can be used to describe them. Can we reason about all the possible layouts that can be made using, say, flexbox?
An example where such information... |
i'm trying to learn about requirements in software engineering. At the moment i have a example problem i'm running through, where i'm trying to develop a system that allows calculations. The goal of the excersise is to understand the basic general process of requirements and design.
The system has requirements and a de... |
I've seen many SO questions around auto-generating unit tests, or documenting unit tests, but I'd like to go the reverse direction. What I'd REALLY like is to have folks (devs, tech writers, etc) write documentation with embedded code, then, as part of CI, automatically convert that documentation to runnable code, and ... |
Let's say I have a system that parses network traffic, and generates event of things that happened.
example:
ip1 was talking to ip2
ip2 was talking to ip3
etc
Now let's say that these events are published into event sourcing thing (like kafka for example).
I have another service (service B) that listens to these even... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.