instruction stringlengths 34 36.1k |
|---|
Suppose we have 2 microservices - service A and B. These two services are independent for most parts and API client talks to them directly. However, their functionality overlaps or intersects in some areas where we need some info from service A first, then provide those info to service B to get some other info. To save... |
I know this is a theorical question since i don't have code to or any logs to show, but i hope that someone can give me some idea on this question.
The problem in question was the following:
On my work, on a deploy to a production system a migration took so much time running that it failed due to a timeout and this hap... |
I'm a beginner in C++, and I was wondering if it is best practice to define a member function directly in a class, such as:
// something.hpp
class C {
inline int func() { return ... ; }
}
rather than the usual:
// something.hpp
class C {
int func();
}
// something.cpp
int C::func() { return ... ; }
In my read... |
While writing python code (I write python-selenium for GUI automation), I am facing situations wheer I have to deal with 5 widgets that do the same thing, just there xpath is differs by one term.
# set value of a type of web element to x
try:
if not some_web_element.checkExists():
report('X does not exist')
so... |
I'm building a lot web applications for internal use, my setup is basically ASP.NET Core, React/Angular and Typescript.
I started to find my self duplicating a lot of code from C# into TypeScript types and found this nice little utility https://github.com/pankleks/TypeScriptBuilder that will create TypeScript-models fr... |
Consider the following scenario:
If the user isn't registered in the database, register them. Return their ID.
If the user is in the database, return their ID.
The API endpoint for this may look something like POST mysite.com/api/users?LastName=Stack&RegisterId=1111
The consumer of the API does not want to first GET ... |
UDP is an example of an unreliable protocol. Is there a single word that means "okay to send via an unreliable protocol?" Sort of like "unimportant", but that's too strong a word.
The context would be the name of a message property where the application cares that certain messages are delivered reliably, but is otherwi... |
I am modeling a ship that has contracts. Each contract can either be a fixed rate contract which pays a set fixed amount every day or a market index contract which pays an amount that varies based on a market index.
I hope to run simulations on each ship where I would provide required information on what the market ind... |
If reading uninitialized memory is undefined behavior anyway, why has the C++ standard not been changed so that objects of primitive type (int, unsigned, float, double, bool, char) get default-initialized to 0? Wouldn't this prevent an entire class of typical beginner mistakes? From my understanding, it should be possi... |
I'm reading about BroadcastChannel API https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel . It seems that it is already on market for a long time, and quite cool as well. However, what still bugging me is any practical use case that we really need this BroadcastChannel. Appreciate if there is any real li... |
First of all, I found it a bit strange because technically, iterative means something that is done as a recurring series of steps - so how can one be purely incremental, when each increment will be implemented through the same series of steps?
Anyway, my main confusion stems from the word "iterative" - if the meaning i... |
I wanted to create a background job in which I want to use the retry mechanism for that I want to use the Polly. My requirement is like this:
the First retry should be done after 2 hours
the Second retry should be done after 4 (2^2) hours
the Third retry should be done after 8 (2^3) hours.
In short, I want to retry a... |
Charts are a pretty common thing on the Internet. So that made me wonder why there are still not some web standards for the charts?
I thought that it would be cool if we had some sort of built-in library that would create charts in your browser that would be the same all over the internet, just like <input type="text">... |
In a project, I need to come up with a way to virtualize a third-party DLL with a known exported function prototype. I need to create something like this:
My app <---> wrapper DLL <---> third-party DLL in a virtualized environment
The wrapper DLL just calls the exported functions in the third-party DLL.
By virtualizati... |
I've had a quick search and probably explaining the situation is why I can't find anythign useful to help me. It's best to describe the sitation with an example!
Take a form where a user must input a positive integer. If they don't put in a correct value, say -1, the form will fail validation. Naturally you want some f... |
I have a program which downloads web pages and then scrapes html to create domain specific collection objects e.g. ProductCollection, CatalogCollection, NewsCollection and more. The idea is to create first class collection objects, so these collection classes are encapsulating a list of respective objects. Also, the co... |
I made this design for a university assignment, but I am genuinely interested of this design's good and bad aspects.
The design was supposed to be an OOP design.
The system is meant to be an online store. Users can browse a catalogue of products and add them to their cart. Within the cart they can proceed to checkout a... |
What is the appropriate REST API pattern for a "pure function" that takes an input and returns an output, without side effects?
A trivial case might be a REST API that returns the sum of a list of numbers.
One way of approaching this is, you could think of the function itself as the resource, and use a GET operation to... |
I am using a publish-subscribe event broker, and am constructing libraries to help people interact with this broker consistently.
One of the things I would like to design is some kind of IEventSource interface that each potential publisher could implement. The broker libraries would then natively understand the IEventS... |
My application syncs data between 2 different services. Data flow looks something like this:
Target <-- My Service <-- Source
I have a method that starts this batch operation:
// we have multiple organisations for which we do this
for each organisation:
void process() {
1. fetch data from source
2. fetch data f... |
Suppose I have the following class structure:
A forest can have any number of trees, but each tree can belong to only one forest. If the forest is deleted, the tree is deleted.
A tree must have at least one branch, but can have many more, however each branch can belong to only one tree. If the tree is deleted, the b... |
I'm working a project where I found another developer wrote a method as you see it below.
How would I clean those IF statements and refactor this method.
Also is it ok ti set a variable to nil ?
def set_tenant
if current_user
if current_user.tenant_id.present?
if current_user.tenants.include?(curren... |
I'm trying to calculate a trajectory in the presence of time travel.
In the following picture, there is a character traveling toward the right in a straight line (like a billiard ball). If the character encounters another character, he will always turn right (as a rule). There is also a time portal at the bottom, that ... |
According to the Java API documentation, the Collection<E> has:
boolean add(E e)
Similarly Map<K,V> has:
V put(K key, V value)
Among these methods, generic types like K, V, E are used as the argument type
Whereas the following methods in Collection<E>
boolean contains(Object o)
boolean remove(Object o)
and simila... |
My scenario involves the following classes:
I have three types of Peer that creates a RegistryType instance because its methods are needed. Same for Identity class. Each PeerType need 0 or all the RegistryType methods in order to accomplish their work. Every Peer is then run by creating a Server instance that makes us... |
I have 2 different implementations of the same interface, but each one of those objects have different implementations, however they have the same methods, should I create one interface for each type of object and extend the main interface ?
|
Disclaimer: This question may be related to the framework I'm using to support CQRS/ES rather than the concepts themselves but many of these frameworks implement the same strategies, making me think the two are tightly coupled regardless.
CQRS tells us to...
use a different model to update information than the model y... |
I download the atmospheric noise data from random.org in form:
10111011 01101111 01100001 00001001 00100110 10111011 01110110 11010110
00000111 01111110 10001110 01101010 11100000 11110111 10101011 01001011
11010111 00100110 01001011 11101111 01100111 01011000 11000000 00011010
00111101 10000100 11011111 10001100 11100... |
I am building a chess - related application, and I want to use a pre-compiled program called Stockfish as my chess engine. I am wondering what is the best practice to encapsulate the usage of the program. There are many design patterns to match - Strategy, as the program is, after all, an algorithm that operate on som... |
I have a list of Registration's, on which I need to apply a set of rules to each individually.
Rules can be a single Rule, or a sequence of rules, representable by a tree. One rule is a ConditionalRule, where the condition itself can be a tree (e.g. and,or,not, isOwnedByAdmin), which checks if a specific condition appl... |
This is more of a high-level architecture question. If there is a better site to post these at please let me know.
To greatly simplify - think of Uber Eats, but for services. You could order services of a local plumber, local roofer, but also nationwide service like Comcast internet, or some statewide service. "How to ... |
I'm struggling with the design of a method CallSystemX() that needs to accept a parameter of multiple Types. To get around it I created an interface called IRequest to be able to pass different types of objects into my method, but that introduced new problems since I have a builder that needs to know the 'real' underl... |
Let's say I have a class with some suitable instance variables which are then used for some computation (via a method of the class). As the computation will generate lots of data which needs to be accessed by other classes, it needs to be stored somewhere.
What is the best way in this scenario?
Obviously you can store ... |
I am trying to understand one thing of using semver in rest apis. Semver says that
Major version X (X.y.z | X > 0) MUST be incremented if any backwards
incompatible changes are introduced to the public API. It MAY also
include minor and patch level changes. Patch and minor version MUST be
reset to 0 when major version... |
Context: I initially asked this question. I lacked some understanding and phrasing to ask the actual question I wanted to ask. The answer though helped me understand the friction points a bit better to ask this question.
I have three separate Bounded Contexts, and have a new feature requirement that states that, based... |
My goal is to define a Service class which process method accepts a RequestType argument that is defined by the contained ServiceType and returns an object of a type defined by ServiceType. By doing this I'm able to derive Services that can process a given Request that is compatible with the type of the Service , same ... |
I am currently working on an application that models a complex business process that consists of many steps, each having a 1:n relationship with subsequent steps. The software is written Java using Hibernate and PostgreSQL.
Users request quotes (each containing multiple items). Requests are then matched with suppliers.... |
I currently have this Bot Viewer application
Which consist of the application itself - the Bot overviewer, which depends on a library
Bot.Core.
Within Bot.core we have defined the core interface for each bot, and within this libary also implemented them as Bot x, Bot Z, Bot y.
Since Bot.Overviewer depends on the Bot.... |
I have a .Net 5 Web API project and use MediatR to encapsulate my business logic into commands and queries since I don't like to have a single CRUD service handling everything related to a specific resource because my usecases are too complex.
For the data access part I'm using EF Core.
Given the example query to retri... |
I am looking for advice on how to manage shared code between several projects more effectively.
Currently, we have several applications that use the same common backbone of infrastructure code, from simple utilities to wrappers around larger libraries, offering our preferred ideal interfaces internally.
Currently, we h... |
An edge case is usually defined as what Wikipedia would say,
An edge case is a problem or situation that occurs only at an extreme (maximum or minimum) operating parameter. For example, a stereo speaker might noticeably distort audio when played at maximum volume, even in the absence of any other extreme setting or co... |
I'm extracting an image [jpg/png etc] server project from a larger solution.
Images are uploaded via an API by authenticated users. The same application also serves the images.
The file is validated: It is inspected to make sure it is the type of file it claims to be.
The file is processed: If it is too big in spatial... |
I am building the test process for my development team.
Currently, we have multiple ping-pong scenarios between Dev and Test teams.
to send the product to QA then QA find issues and return them to developers then fix them to QA and so on.
I asked the Test team to share the Test Cases they have with the developers and t... |
I'm creating a NodeJS application that receives a ton of incoming financial data (prices) through Websockets, like anywhere from 1 to 5 data points per second which I would then like to send to the front end (which is built with React) as the data comes/changes. I will also have functions internally that simulate buy/s... |
I am learning the MVVM paradigm and I have seen a few different implementations surrounding the Model and how it is updated which I want to understand.
My understanding of the View and ViewModel interaction is clear (I think) and is as follows:
Properties in a View are bound to properties in a ViewModel
ViewModels do ... |
I was looking at Rust's Allocator trait. From my understanding, you give an allocator a length of memory and a word size to align to, and the allocator either gives you a pointer to the memory or an error. So clearly the custom Allocator is finding valid addresses in the memory somehow. How does the allocator know wher... |
I am struggling to find a good solution for authorization of users after they were properly authenticated through an oidc flow. Let's assume the following setup:
An angular SPA is interacting with several microservices.
It's important to note that those microservices support multi tenancy, depending on the url being c... |
I was stuck on a relation description and unable to model it in the Crow's Foot Notation:
Each individual vehicle is a particular model of a particular brand offered by the company (e.g., the XF is a model of the car brand Jaguar of Tata Motors). Each model can be offered with a variety of options, but an individual c... |
I'm thinking of creating a custom fork of a program to customize and fit my day-to-day uses a bit more, and was wondering how I would manage the fork to keep up to date with bug fixes and stuff in the original repository.
To keep things simple let's use a fictional piece of software, let's call it "Fruit Organizer," an... |
I'm wanting to store lots of data in cloud storage - like S3.
I want some data to only be accessed by authorised users, one way I could do this is to authenticate the user on my service, download the data from the cloud to my server, and serve the data to the user. This seems innefficient - as my server has to both upl... |
I'm approaching the DDD way and I was posing myself some questions. Assume that I'm writing an application that lets you define a nutritional week, where you can
Define a nutritional week as a resource having a list of aliment to eat for each of the 7 days
Activate/deactivate the created weeks in a sort of calendar
M... |
I understand that preparing test cases and scenarios that goes through the whole system stack should be written by a QA person. But my question is with automating these tests, and I mean specifically e2e tests. Who should be responsible for the implementation of e2e tests, is it developers? or qa engineers? and why?
|
I have the following (hypothetical) setup and am wondering if anyone has design suggestions, keywords, or nudges.
I have a class Walk that implements a method doActivity. This method keeps track of state from a limited set, e.g. "LOST", "HOME", "ON_TRAIL". Any time my state is updated, I would like to perform some (asy... |
What are some pros and cons of representing routes as legs or as stops?
A leg is a departure and arrival location, a departure time and a duration (or an arrival time and a duration).
A stop is an arrival time, a location, and a departure time.
The domain I'm modelling is a marketplace where people describe the route t... |
Apologies if this isn't the correct place to ask the question.
But, I'm stumped. Can multiple memory addresses be read/written at one time, or must one address be read then another, is it possible for this to happen simultaneously?
I.e. If the CPU requires 4 bytes of data from RAM, then can those 4 memory address be re... |
Is there a solution for the following problem?
We have a function f(x,y) where the inputs are secret an cannot be
known by anyone besides the party that submitted them.
The output of f is public and can be known by anyone.
An adversary has access to any machine in the middle (not the devices of the two submitting par... |
Companies like Google and Microsoft use identifier-first screens: where you provide your identifier (like an email) before providing the password.
Why is this done, is this somehow more secure?
I'm setting up a login with Auth0 and identifier-first is one of the options; should I use it?
|
Authors such as Dave Farley advise us to "only build packages once", so that we can "be sure the thing we’re deploying is the same thing we’ve tested throughout the deployment pipeline".
On the other hand the Composer manual suggests that we should list dependencies required only "for developing this package, or runnin... |
I'm creating a class representation of a mathematical tuple (or simply, an ordered set of numbers). Being a list-like object that could benefit from an iterator representation, I have decided to give it one. By following this tutorial, I have found little difficulty in creating the iterator class.
What I do not underst... |
I have a situation where let's say I have a folder called logs which has N folders.
Each folder contains events for a specific event type and each folder has N .log files where each file has multiple lines of JSON.
Example:
event1.1.log
{"id":1, "name": "ABCD"}
{"id":2, "name": "EFGH"}
{"id":5, "name": "IJKL"}
{"id":7,... |
I'm trying to create a REST API that allows the user to:
create a resource if it doesn't exist.
update a resource if it exists.
with the same request.
Given an example: I have a company that has many employees. I know that the way that usually an employee is inserted is using something like do a post request to /empl... |
DataModel contains a Proof that contains all the information of its integrity along with the method with which the Proof should be verified.
In this case I designed a JWS type of proof that can be generated by using a ProofGenerator object that contains the private key to calculate the Proof. However each time a DataMo... |
We are creating a SPA, and thus the frontend is more than just a view for backend generated pages.
Now to create an "entry" you normally press create, and then fill in the data for that entry in the resulting page. (as admin you can view and edit in the same page that others can view).
to help generation we created a "... |
Let me try to clarify my question with an example. Assume a library of some sort which has a built in logging system and it is published as Library.Core. As the maintainer you want to add a wrapper around your logging system to add support for Microsoft.Extensions.Logging. You create a working implementation and publis... |
Is a "wrong" to return anything else besides this in a constructor?
Take this TypeScript Queue sample:
class Queue {
private buffer: string;
constructor(buffer: string = "") {
this.buffer = buffer;
}
push(n: string): Queue {
return new Queue(this.get() + n);
}
get(): string {... |
I am reading up on system design concepts, specifically DataBase replication and partitioning. I understand that partitioning is used to improve throughput, and/or when the amount of data is high i.e. basically to improve scalability. But at what point do I need partitioning?
Eg. If I have a single table in my OLTP DB ... |
We have to make a bunch of HTTP calls from Java/Spring-Boot application which will be mix of in-sequence and parallel.
Level 1 : We make 3 parallel calls to Services 1 , 2 and 3
Level 2: After service 1 response is received (which is a list), we make parallel calls to service 4 and 5 for each item in list
Level 3 : Aft... |
I know the lifetime of the controller class is transient by default, but I think it's better to be singleton. should explain to me why creators choose transient instead of singleton or scope lifetime?
Thanks a lot
|
I'm in a dilema where I'm translation a full mobile app where the translations are going to be a key value pair but I'm not sure how to name the key.
Should I name the keys describing what the text is, like (key: ok, text: Ok), or should I name the key from where it is on the screen/context, like (key: screenXButton, t... |
I need a good approach to declare a lot of variables over a context. For exmaple in kubeflow, I need declare a pipeline with a lot components in order to do that, I use the following code:
component_1_op = comp.load_component(
'path/to/component/1')
...
component_n_op = comp.load_component(
'path/to/component/n... |
I have method with the following prototype :
R[] = method(k,n)
which :
n = ordinal value 0 <n <10^9
k = math function depend on n value : i.e n^6
R = array of computed values
For example :
n = 10^8
k = n ^2
so then :
n [index]= 1,2,3,...,10^8
R [index]= 1,4,9,..,..
I dont want to do the common solution : iterate an... |
I am trying to implement a basic bytecode VM, which I plan to target with a compiler. How can I implement the ability to call external C functions using the bytecode, i.e., call arbitrary functions in runtime. For example, my future compiler should be able to produce programs that call printf(), malloc(), etc. My guess... |
So the current setup is a typical event sourced system built on AWS: Lambdas exposed with API Gateway to get the orders (commands), the domain (aggregates) apply some validations after loading the aggregate, publish all events in the event store (DynamoDB).
Where things get interesting! How to react to these events! So... |
I'm currently brushing up and learning about a bunch of techniques to hopefully begin implementing in my own workflow; one of which is IoC (and DI in particular).
I'm hoping someone could clear up my confusion I have reading two articles about the subject:
In this post, the author seems to demonstrate that you can use ... |
So, I have an entity called Consultation that is being used as a member variable of the class VideoCallViewModel that goes like this:
struct Consultation: Equatable {
enum Status: Int, CaseIterable {
case pending = 100
case dropped = 150
case ready = 200
case created = 300
ca... |
I have to manage multilingual information in JSON documents in a MongoDB/Mongoose context. But I'm in a dilemma regarding best the format to use with a view to performance metrics:
I'm currently considering two formats (data is left empty):
// English translation in top level, and all of the others language are
// kept... |
When using collaborative applications like issue trackers, planning tools, etc. it can be very frustrating to have to keep hitting refresh to make sure you're viewing the same state as your colleagues. Therefore I want to build my applications so that when one user changes something, it shows up on everyone's screens. ... |
When an entity is changed, I want to raise an event to notify potential consumers about the state changes. My question is, should I have
an xxxChanged event for each attribute, or
a single EntityChanged event that identifies which attributes changed?
Having more specific events seems better to me, as consumers can s... |
I'm creating an application using the jigsaw modules system. The app will just perform some tasks in multithreaded environment. In my mind the app architecture (modules) looks like that:
Work (the task implementations and management plus some related
stuff)
UI (graphical/text based representation of data present in Wo... |
DevOps of our customer require that our application creates database objects and Kafka topics automatically on application start, if they are missing. Moreover, they want the application to automatically upgrade the database model, if it has changed (e.g. by using Liquibase).
My response is: Do not want us to do that i... |
I am developing a simulator of a bank software system, where each operation (deposit, withdraw, transfer, ...) is just a string.
I have 5 main classes :
Bank where bank accounts are stored.
CommandValidator that takes a command (string) then decides whether it is valid or not (through its validate(string) method) accor... |
How does changing the video quality works behind the scene? Suppose I am watching a video on youtube (I will use YT as an example in this question) and suddenly my internet speed becomes slow, in that case YT automatically (or sometimes I as a user) change the quality to some lower resolution. But the video does not st... |
I have an UI module that will expose only one class - UserInterface. The class will be responsible for collecting user input and providing output (command line UI style). From logical way of thinking, I'd never need more than one instance of the UserInterface class.
Should I enforce only one instance using design like ... |
The average utility class: A stateless class that provides some functionality by exposing static methods. Its default constructor is private to avoid instantiation. When ever the average utility class is used, a hard dependency is created.
So, referencing the utility class is the way to invoke a desired method. But cou... |
I have a Python application using SQLAlchemy. It uses around 15 database tables.
For example, I have an image table that lists image files manipulated by the application. Most operations involving that image have side-effects both on the filesystem and on the database.
To keep this easy to test and de-couple the logic ... |
For the last several years, I've been checking all dependencies of my team's nodejs project into source control. At first, we stored the archives of all dependencies using yarn v1's offline mirror, now we store zips using yarn v2's cache feature.
The reason I felt like it was a good idea to do this is package security... |
There are 2 independently functioning web applications. Web-app1: (Flutter+Django+Postgres). Web-app2: (Angular+Spring+Postgres). Each of the web-apps has its own user database and are functioning independently. It is now decided to integrate the 2 apps such that Web-app2(Spring) will no more have it's regular users in... |
I am trying to model APIs for
Create shipments
Fetch Available shipments (based on region preferences)
Accept shipments (allows logged in user to accept multiple shipments on first come first serve basis )
Allocate shipments (allows logged in user to allocate multiple shipments to driver, shipments must be accepted fi... |
This question is vaguely Internet of Things (IoT) related - but it's about the intra-net (no external internet connection in this scenario - we are air-gapped). Let's say I have a new smart household appliance. This smart appliance can connect to my wi-fi and has a built-in HTTP server that you can contact with your ... |
I am a junior developer and my typical senior developer just got fired and while they try to replace him I shall ask you.
I have an API that returns some internal data of ours in increments of 200 per call. There are about 40,000 pieces of data that I need to grab each week or 200 calls that need to be made to this API... |
In particular I am wondering if it is acceptable to have an instance variable that can be calculated by other instance variables (i.e. during the creation of the object)?
On one hand I see the data dependency and information redundancy as a possible issue. However on the other hand performance will suffer if the value ... |
For fun, I'm developing a multi-player card game. I plan to run it on a single cheap VPS, so deployment would have to kill the process and re-start it with the new code. There is no Load Balancer. I'm okay with deployment causing a few minute outage, but not losing game state. I want to use websockets or real sockets, ... |
I am working on a small project and I tried to represent the following two requirements in my diagram:
An album may be performed by either a singer or a band (not both).
My plan to implement this requirement is to create a producer class that combine both singers and bands to guarantee that only one of them has perfor... |
I have read that objects contain the actions it can perform as functions and its attributes as variables. But i am getting confused with objects that don't seem to perform any actions such as an integer, quadtree and set.
I know that we can represent these "non-real objects" as abstract data types. But this is differen... |
I'm going through a beginner programming learning guides and the teacher brings up the try catch block paradigm.
The code you put in the try block is run and if an error happens the code in the catch block is run. Your application should recover from it.
try {
// do something that might throw an error
}
catch (exce... |
I want to learn firestore and to this end I created small project which replicates instagram. Not all functionalities of course, just the very basics - photo sharing, comments and the possibility to report a comment or a photo.
This is how my current collections look like:
users -> user_id -> [username, email]
followin... |
i want to set up basic login page in xamarin.forms. There is no username/password, just a simple pin
so far i have 3 pages to do this
Sign-up Pin page
Sign-up Confirm Pin Page (re-enter pin to confirm)
Sign-in Pin Page
Main app page
my project flow as follows:
1st time user, will be prompt to "Sign-up Pin Page", tha... |
I have a background as a full stack web developer, but didn't code professionally speaking for about 8 years, now focusing on technical and/or functional analysis. In the meanwhile, many things changed of course, and I'm now trying to "refresh" my understanding of how modern web can be rendered, so that I can still at ... |
I'm aware that it's generally considered bad style to write tests that have to run in a particular order. Let's say I'm testing an account-management API, and have the following two integration tests: test_create_account, and test_log_in. What I understand to be the correct style for this would be something to the effe... |
I understand their own characteristics but a lot of articles focus on comparing the two methods but never talked about they serve different purposes within SOA.
Eg. Example of ticket system and identity management.
When creating a ticket I can assign to a person from a list, which the list gets from identity managemen... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.