instruction stringlengths 34 36.1k |
|---|
I'm looking for a way to avoid centralized management of authorization rules. I'd like every microservice to be responsible for the authorization logic of its actions, but I'm having some trouble implementing that.
Let's use an online marketplace application as an example (like eBay). A user in this application can man... |
We want to build a new frontend for our existing app with elements shown or hidden based on a users role.
Are there any common patterns for this? I see two ways of doing this.
The backend sends the user role to the fronted, the frontend knows
about what roles can see what elements.
Or the backend knows about the eleme... |
let's say I would like to create a service like eToro that allows people to trade stocks but with their own brokers.
If I do it just for me, it's pretty straightforward:
create logic that replicates someone's trades (or from my own instructions)
use my API keys to get the best price with my brokers and trade
Now if I... |
I am developing an engineering application (WPF, C#) that consists of a collection of other programs that perform specific engineering tasks. I guess you can think of it like Microsoft Office, however unlike MS Office, the programs within the application all share the same context in that the tasks that they perform al... |
I have the following problem. I have a method which takes two other custom objects to work. This objects are required by the method because they have the information that the method requires to perform its operations. Normally, you could mock the objects and just hardcode the API of this objects.
The problem here is th... |
I'm asking myself above question since I implemented an API that accesses a third-party API and currently write tests to increase my code coverage in the class that communicates with the third-party API. Currently I'm sitting at 76.6%. I covered possible third-party API-responses and JSON parsing errors.
What's left ar... |
We have an embedded device collecting data from various sensors attached to it. The data is then passed to the application. What is the best way to design the data packets? The data needs to be hardware agnostic. There's only one hardware device and one main sensor on that device that is collecting the data of interest... |
I've read Allow users upload CSV files, and embed the data for a simple API , Importing large data sets into a database over the web the closest concept is
Is there a way to efficiently allow a user to upload multiple content at once for e-commerce type sites? and the most thorough
A manual and automated CSV file upl... |
Most of applications, when you sign up, you must agree with some terms and conditions.
Should the information that the user agreed to those terms be saved in the database?
I asking this because I'm thinking, If the user breaks one of those terms, I will need some prove that the user agreed to it? Like have a flag on th... |
I'm currently working on an program that solves a graph optimization problem.
I know the "standard" software-design principles like information hiding, modularization, etc. What I'm struggling with here is that I feel like this use case rules out most of them as not applicable.
For example, I constantly have to use the... |
I'm trying to aggregate logs from multiple embedded devices in centralized place to be able to analyze them.
This is how system looks like:
I have number of embedded devices.
Some deployments are on-site and system might not have access to the internet. So I need to request customer to dump the logs and send them to u... |
For building a simplistic live search system, I trying to decide whether to use Websockets or Ajax. Implementation wise, for every letter the user types (or maybe every 0.5 seconds), a database query will be run against the input/typed text and some comparisons will be made on the query output to return the top 5-10 re... |
I am building an application for employee management. To start discussion, I have 3 roles: admin, manager and employee
admin does everything
manager owns a company and manages its employees.
employees only record their point and nothing more.
My tables are:
users (store authentication and permission information)
com... |
In the C++20 codebase that I work there are a couple of functions which have helper functions defined as lambdas. I can see the idea of locality for these helpers. By having them there in the function, one doesn't have to care about them in other parts of the code.
As the code is proprietary, I cannot show the original... |
I'm creating a mobile app that will have a verification process of the phone number like most of apps do when they use your phone.
I'm also developing the back-end but I don't know exactly what is the safer way to generate a 4-6 digits code and send by SMS to verify that account.
How should I implement the generation o... |
I have a question about gRPC communication.
I know gRPC has 4 models communication: unay, server-streaming, client-streaming and bi-direction. And the terms "client" and "server" very flexible, because it really is peer-to-peer communication.
I wonder "Can gRPC supports client-to-client communcation in case two or many... |
I do have n nodes managed by Kubernetes, all of them running several containers. A container may contain a database alongside with an application. As containers should be stateless, all data within the container's database would be lost (uppon restart or redeployment via Kubernetes). Hence, I thought of a central datab... |
Can I get some thoughts on the entity design?
Let's say I have an entity called Book. Let's say I create a specific instance of that book. It has a title A and an author B. Since there can be multiple books, should the amount be included in the entity OR should I instead create a separate entry for each of the same boo... |
I have created an application in which users and tasks can be entered.
A task should be be assigned to one or more users. If more users can do a task, the task should be assigned in such a way that it can be done by person A OR person B, or that person A AND person B have to do the task together.
In addition, more comp... |
I am interested in implementing the following requirements for my e-signature web application.
A user can create a new signing contract. That contract can include multiple users to sign. The contract creator needs to provide emails of the recipients. Every recipient will have additional data assigned, like signing det... |
I am writing a payment Processor class, then will take different payment objects in input and talks to external services to process payment.My class is designed using polymorphism as follow:
public class PaymentProcessor
{
DebitCardTransactionDetails processPayment(DebitCard);
CreditCardTransactionDetails processPayme... |
Recently In an interview I was asked this question -
Question- If are storing passwords in encrypted format in DB and in future when user login into our website how will we perform authentication?
Me:-we will first first encrypt the password using same hash function then compare it with already stored password.
Interv... |
The divide and conquer strategy for closest point problem sorts the points according to x coordinates so that the median could be found. But what does sorting the strip (strip array contains all the points which are at most d perpendicular distance apart from the median line where d is the minimum distance till now) ac... |
Let's consider such an example:
I'm an author of application like Google Chrome. I would like to my application sends anonymous telemetry logs to my server. How do I prevent somebody to use my server API to pretend he is my application to insert some malicious / spammy logs?
User of that application might be anonymous.... |
I've recently been working on a customerproject that makes extensive use of a signals/slots like mechanism. Their approach is to directly connect signals from a larger framework to private methods of their businessobjects. Now, my role has mostly to do with unittesting, and their approach makes testing fantastically ha... |
I'm kinda new in versioning.
In my scenario, for example, our main project is currently developing in 2.1.0 (develop branch), while the library version remain same as 1.5.0 since nothing change (for both 2.1.0 and 2.0.0 release).
So, few questions
If later on, we introduce some backward compatible fix in the library i... |
I'm reading about software architectures like Hexagonal architecture, Onion architecture etc.
They put a big emphasis on decoupling. The business logic sits at the centre and the UI sits on the outside. The idea is that the UI should not touch the business rules at all. It should be totally dumb and should just relay c... |
Git flow recommends to have separate branches .i.e.
main/master --> production deployable code
Development branch gets created from main/master --> active development branch (integration branch)
feature branch ---> Multiple Feature branch gets created from development branch
My question is basically, why I need to keep... |
I have a disagreement with one of my colleagues on whether or not functions should have inverse functions available.
I would like to know when/if inverse functions should be used.
For example, say we have a function isTrue(boolean condition){return condition == true;} then what I would do is also include a isFalse(bool... |
I'm dealing with a system where:
A number of around 50 microservices are available
Depending on their needs, clients design their deployment choosing which of those microservices they need
Most of them are not usable in isolation, but require others to be available, which is perfectly understandable.
Now the situatio... |
Alright so here's the situation...
All of my coworkers are used to RDP'ing into a Windows server and doing all of their work there. Whether it be coding, SQL work, etc. Multiple developers connecting to the same Windows Server (either 2012 or 2016 currently) and running all the same applications. Their workstations alm... |
I've recently come across CRC cards and sequence diagrams at my university.
Martin fowler has said that sequence diagrams are interchangeable with CRC cards when you're in the design phase of your development.
I had a university project which was rather small where we just went from use case descriptions to sequence di... |
Given a collection of objects and an action id (there is a corresponding "action controller" class, which can be found with the id), what is the best way to organize mass action on the objects?
There are some twists though:
an action is already implemented for a single object,
action may need pre-checks. Those then wa... |
Context
Hi, in my job we are trying to modify an API endpoint (/resources) to make special queries to it. A resource has a location (long/lat) and we want to make queries based on that location. We want to support mainly two different filters:
Filter by lat/long (already done): GET /resources?lat=0&long=0 returns a li... |
I'm doing some work with my team to refactor/rearchitect some parts of our existing codebase which consists of two separate Django apps hosted in one common project repository. We're starting work on a new app and at this point want to break down the project into more useful components.
Currently, our presentation laye... |
I’m trying to think what’s the best approach when I need data present in different services in a microservices-based architecture. In an e-commerce context, when a user creates an order the OrderService needs to confirm if the sent list of products actually exists and infer if the total price is indeed correct (data va... |
We have jobs running on-premises, many of which directly query our (on-prem) database. At the start of these jobs a new record is created in the database, and the record id is returned so that it may be referenced in future queries. We’ve recently started running other jobs in the cloud, but we have yet to run jobs t... |
For the sake of discussion, you can assume I'm using Entity Framework and a mediator pattern implementation in .NET.
I'm going back and forth trying to decide how to structure some of my data access in .NET. This confusion stems from the fact that I'm trying to follow the general advice of keeping my domain models and... |
I'm working on a c++ data analysis project. My workflow goes like this
Analyze the data and build models
Optimize the code for latency, to deploy for production
goto 1
Step 1 has lots of machine learning parameters, using which I test very minor variations of algorithms. In step 2, I clean up the unused parts of the ... |
I am trying to understand how branch prediction works, specifically with regards to correlative branch prediction. I understand that in an (m, n) branch predictor, there are m branch predictors, with each branch predictor being an n-bit predictor. My question is, given a set of 4 3-bit branch predictors, each outputtin... |
I have thousands of .csv files with the same structure and, in most of the cases, some column values are the same ones recurring. Each file represents a report on some structures, with numeric attributes and a date.
I want those to be structured and suitable for cleaning missing values, visualizations, predictions, etc... |
I know an empty method without any good reason is a code smell, but it can be required for constructors.
What would be a good way to write an empty constructor among the following?
class A
{
private int a;
public A(int v)
{
a = v;
}
}
class B : A
{
// 1
public B(int v) : base(v) { }
... |
I have a very simple standalone java application that allows users to tick which messages they want to transfer and then click go, essentially.
We now need to provide different users with a different set of messages on the UI.
e.g:
company 1 can only tick messages A,B,C and the rest aren't visible to them
company 2 can... |
I'm wondering what are the nowadays risks of storing a JWT that does not expire in an HttpOnly, SameSite=Strict, and Secure cookie.
I understand localStorage is vulnerable to XSS, and that normal cookies are vulnerable to CSRF, so that's why it's recommended to use temporary JWTs with refresh tokens.
My idea is that th... |
In a case where having microservices deployed as containers without any orchestration tool, they need to define some HTTP response headers.
A way to achieve it is by having each microservice define their own headers. Another way is by creating an API gateway that attaches them to each microservice response.
For one sid... |
I currently stumbled over the the concept of "ports" in UML component diagrams and I'm not entirely sure how they are supposed to be used. Sometimes, ports seem to be used generally as start of connectors. Sometimes, ports are only used as soon as a connector leaves/enters a bigger component. I've even seen examples wh... |
Say I want to test the behavior of the GUI while I follow a PassiveView approach. I also use the command pattern to handle the actions of the user. So given a PersonView and a PersonService with a savePerson(firstName,lastName) method, my command looks like:
class SavePersonCommand{
public SavePersonCommand(... |
We are using Jira to track all our tickets and confluence for documentation. We intend to document the test cases covered on Confluence.
Here are a couple requirements:
Consider a development ticket done and ready for release only when all of the relevant test cases have been written and approved
It is usually the cas... |
I have been reading about the concept but still it doesn't make sense to me. I want to clarify my question by giving an example.
First of all, if we have task1 and task2 which have to run in sequence, they call it synchronous. Whereas, if task2 runs before task1 finishes, it is called asynchronous. I came across such d... |
I'm having a huge doubt on how to connect the front-end of my application to its back-end.
So my application has a single entry point where all requests go.
The request is dispatched to a controller, which, in turn, needs to call the logic (the model), which elaborates the data, communicates with the database and retur... |
I am building a mobile client app that gathers info about movies/TV shows from a website and displays it in a pretty format. When the user clicks on a show, they are taken to a page with the thumbnail for that show used as the background. This works well for most shows because they have dark thumbnails that contrast we... |
Our drawing tool is draw.io. Occassionally I've got to draw flow charts with it. In those flow charts I've got to express parallel processes (very similar to this UML example).
Wikipedia says about flow charts:
Parallel Mode is represented by two horizontal lines at the beginning
or ending of simultaneous operations
... |
Context
I'm currently developing a notification system with DDD which needs to be able to send the same notification to multiple users. For example, a group of party goers might all be notified about the lineup of a certain festival.
To accommodate this I've created two domain classes (which are on their own seperate a... |
We have a bunch of microservices written in different programming languages. These all communicate with each other over RabbitMQ(AMQP) middleware. There are consumers and publishers in each microservice which listen to incomming messages and publish on a RabbitMQ exchange respectively. The current architecture is shown... |
There are times when I have to fix/update records on a Production and/or Staging environment for a Web App. These are remote DBs.
Rather than push application code to fix the data, I've been "interfacing" my localhost's version of the running app with the remote DBs. I can do this by simply changing an ENV var for the ... |
I have an event driven architecutre, with many microserver that publish a lot of message in my event bus.
In some case i can't track why some process is blocked, maybe because my Service-A haven't publish the message in the bus after the transaction saved or maybe the other Servics-B is crash immediately after have tak... |
I've question about the philosophy of createMemento() in Originator class in Memento Pattern.
My teacher said:
now that Originator class no longer stores Memento objects internally, we should give it two new methods; createMemento() and setMemento().
The createMemento() method stores the current state of the Originato... |
I have been designing a C++ class that maps an integer to an integer using a vector. Because there is a lot of repetitive data (for example 11115555666222), I am using a compression scheme where I am keeping the struct in a vector that holds the value along with a number indicating where the next value in the sequence ... |
First-time poster so please be gentle :)
I have a rather large table in my database (MySQL in case it matters) that holds lat/lng values of certain points of interest around the world (table name: Maps). The table is very large (millions of rows) and could grow significantly larger since users can add rows to it.
I hav... |
I got the following interview question:
Say the company has this event, where we will create a button on a website and only the first ten clicks will be accepted and win a prize. Assume that there a millions of people around the world participating in this event. How would you implement it?
My answer:
Just save ever... |
I want to design a domain model for the following system:
a customer asks a hotel for rooms availability and prices on a date
the hotel send several offers: room type x, price Y, etc
the customer accepts an offer and makes a reservation.
One way of looking at it is that a reservation it's just an offer "flagged" as a... |
I have a shop system that is based on a MySQL database and over which I have full control. On this system runs my synchronization plugin.
And then there is an external CRM system with a fixed API. This API allows reading and writing of customers. When reading, I can specify a UTC timestamp and it will provide me with a... |
Let's say we are building a threaded program in C, for example a message queue system where a thread is spawned to manage one end of the queue, and (re)connect sockets.
This can roughly be set up in two ways (excuse the pseudocode):
void spawn_thrd(){
struct S* = **allocate new structures for thread creature**
... |
I am just getting into DDD, and I am trying to model a very basic exercise schedule. I have a Schedule and I have a Slot the slot takes 0 - many Exercise entities. The schedule is composed of Slots which must be a minimum of 7 to match up to a week but I don't want to prevent users from having a schedule that exceeds a... |
I'm reading SICP, and I don't understand how Lamé's Theorem gives us an estimate for the order-of-growth of Euclid's algorithm (the relevant passage is below). It would make sense to me if the assertion was that the smaller of the two inputs grows as the logarithm (to the base phi) of k. Intuitively, it makes sense to ... |
I am looking out for a general design strategy or pattern designing various components in my client application. Here are high level details:
The data is accessed my making a RestAPI call. The data returned by making a single RestAPI call is called a entity. This entity is de-normalized data meaning, if there is a Use... |
I'm designing the architecture of my application and I'm running into an issue. For the webshop every Order entity has a relationship with a Store and many StoreItem's. This allows for quick fetching of information when a user wants to view the Order.
However, when a StoreItem is altered, or even worse, deleted, this i... |
My project is about an automatic HTML documentation generator. The final product can't be in C# because of some organizational and legal constraints.
To my experience, Python is harder to debug than C#, primarily because it is only weakly typed. Hence I thought I could implement my project in C# and then convert it to ... |
I am teaching a beginners course on JavaScript programming and web development. Passing a function as a value into another function is a very common thing in JS from the very beginning.
As the students are total beginners untouched by programming concepts, I need to be very careful and thorough when explaining abstract... |
We are working on a multi-tenant SaaS product that has a ledger of all tenant customer transactions, which we use to track invoice states on a line-item level. This particular application will result in a lot of upstream interactions with service providers which results in a lot of line-item debits and credits. The poi... |
I own a library that reads a file (large or small) and converts it to a special format that one of our vendor's application needs. This conversion can take anywhere between 5 seconds to 10 minutes depending on the file size.
Until now, when my users wanted to use this capability, they needed to integrate my library int... |
To clarify, I'm having to develop a GUI application that stores information about clients (for a course) where one of the fields is the logo of the client. I'm currently using serialization to persist the information, but in Java BufferedImage cannot be Serialized.
I also cannot merely save the path since this could ch... |
We recently integrated a monitoring solution (Data Dog) for our REST-APIs based microservices. The monitoring solution gives us many useful metrics. For example, we can see the average response time for each API. It also alerts us if the average response time increases for a specified period etc. However, we recently s... |
In a project I am working on we load various entities from the database, do some work then attempt to save the resulting entities.
If saving the result is not successful, we return a Result object containing any errors. If it is successful, we return Success = true & Messages = new string[0] and don't use it ever again... |
According to documentation from PM: https://pm2.io/docs/runtime/guide/load-balancing/
To make use of its load balancing feature which uses node's clustering to spawn multiple node processes, I need a stateless nodejs application.
In the context of clustering, you first need to be sure that your application has no inte... |
I'm currently working on a game in which a maths module is being used, here is one of the classes called Vertex.
I'm getting confused with the relationship between HAS-A and objects representation.
I know that HAS-A is the composition of the object, but what has the composition got to do with the objects representation... |
I have a project that relies on getting data from IoT devices.
then I display the data analytics using a graph (in real-time) and also the state of the machines (are they working or not and the reason for stopping ... etc).
something like https://evocon.com/
The important thing is that I decided to use Apache Kafka bec... |
I came across this question and super confused about rethrowing concept in the following example:
try
{
// code that may throw exceptions
}
catch(Exception ex)
{
// add error logging here
throw;
}
Above after error logging, the same exception is thrown again. I don't understand this. I summarized my ... |
I recently ran an Event Storming session and a scenario came up where we needed to represent a loop within the process. The events and commands needed to happen iteratively until a condition is meant in order for the process to continue to the next event.
Representing the command and event only once in a linear line al... |
How domain model capture business logic / domain logic since i cannot access repository?
I see many posts saying that domain model = business objects
But Business objects live in application layer (service layer "not domain services") where they constructed after a repository call and returned to the view
if that is tr... |
I'm currently trying to implement an event-system following a broadcast/observer scheme. I have events/notifications that contain information about what is happening:
class Event
{
public:
Event(const std::string& _name="event");
~Event() = default;
protected:
std::string name;
};
/* I want to flexibly ex... |
Say we have to create a model for a company, where employees can be part of many different teams.
A team can have member members.
Members can be part of many teams.
How to design database tables for this is well known, but what would be a good model for this in the world of classes?
Both Team and Member have their own ... |
I am at my company for half a year now and think that I have gotten a fair idea of their codebase. Initially I didn't dare to form strong opinions, but now I start to feel that the code could benefit from a more structure and more software engineering.
My coworkers do a great job of adding new features, creating a cool... |
Assume a device using Raspberry Pi to control some hardware. This diagram tries to clarify the components:
SOA concept feasibility is being explored right now. The motivations are:
Components in different programming languages
Need for maintainable components
Need to support desktop, phone, etc.
...
Would the SOA co... |
Context:
I am talking about a new program from Microsoft for Microsoft Teams based app development called "SLATE". This program requires 6 weeks fixed timeline for the "Build" phase and 2 weeks fixed timeline for "Envision" phase. Microsoft development partners who are involved in these phases, need to provide detailed... |
I've been using different ad-hoc variations on this, especially in numpy / pandas / data science-y applications. For example let's say I've done some intensive processing that outputs a numpy array and there's probably no need to redo that part of the code. While debugging I want to rerun the script but avoid that pro... |
I have an Unity project with countless of C# script files and I'm working on it solely.
Although nobody else is working on it, I'm aware that some form of code documentation is crucial for my future self.
What I thought about is putting comment files like these into each file / class at the top for a better overview:
/... |
There are many secured applications developed in node.js. However, I could not find any framework (like Spring-security in Java) that can be used to save the trouble of managing the authentication (login/logout).
Going further, there are many flows like create-account, forgot-password, change password etc. that each ap... |
I am in the process of implementing a visual programming language similar to Blender's node editor or Unreal Engine Blueprints. It will be implemented as a SPA that will communicate with a JSON based REST API.
I am trying to represent a graph similar to this in JSON:
+------+
|Number|
| Value|-----+ +----------+
+----... |
I'm using C# with NUnit.
Let's say you have a class
public class MyClass {
private int classMember;
[Test]
public void Test1() {
classMember = 1;
Assert.That(classMember == 1);
}
[Test]
public void Test2() {
classMember = 2;
Assert.That(classMember == 2);
... |
Consider we have something like this:
A person, which has a physical body with arms, each arm has a hand, each hand fingers, and each finger a fingernail.
Another example: we have a car and a car-wheel in it.
So now I want to tune the fingernail a little bit, or the car-wheel, in both cases I want to change the color.
... |
I will have to create a second app based on the first app. The second app shares 98% of the code (Some of the UI is different). I am wondering how to set up the second app without creating a merging hell. The files which are different are not in one place throughout the code tree. (The app is a flutter app - I don't th... |
Given a Set of messages sent to a Queue, what are good ways to determine all of the messages have been processed?
Constraints:
Large number of messages
Other messages besides those in the Set will be in the queue (queue size may never be 0)
Queue does not guarantee ordering of messages
The best solution I have though... |
We are currently making the codebase for our company.
In this project we upload user data like users ID card, drive license, bills for identity confirmation and a lot of other sensitive data.
My question is why we should use a server that only helps with authentication when we already have to deal with the user data?
F... |
I have a task of designing login system with the requirement below:
If the user login over three times, lock account for the first 5 minutes. The next failed 3 times login-in will lock the user account for good. Only the admin can unlock the account
The way i am design the system is that I create 3 more columns in the ... |
My application deals with multiple entities (Articles, Files, Images, Documents, ...) and multiple Users (another entity). Every entity must have one or more "Author" User(s) associated to it.
First design
Build a many-to-many relation between each entity table and the User table.
Articles <--> Articles_Users <--> User... |
I was reading about it and was thinking surely the queue first in first out system would make more sense than using a stack because the last instruction will become the first right because it's lifo?
|
I am looking into Eric Lippert's answer to this Stack Overflow question.
In his answer, he uses the phrase "lock ordering inversions" in regard to deadlocks. I've searched the web and have come across priority inversion. Is this the same concept? If not, what exactly is lock ordering inversion?
|
"Transactional outbox" is a pattern for distributed systems which makes use of a single db transaction to do both, persist changes to the domain model and send a domain event message to the outbox.
In my understanding, being responsible for updating the domain model and sending out domain events are two quite separate ... |
I have a function in python that calls itself recursively, and has some internal variables
passed down the recursion using keyword arguments (that are not listed in the docstring)
Is it a problem to have this exposed to an user instead of defining another private recursive function that is called by a public function. ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.