instruction stringlengths 34 36.1k |
|---|
Let's say I have 2 variables dir_name = mydir and file_name = file1, each to be used in formatted strings. There're a few ways to insert a / in a string with those 2 variables.
dir_name = mydir/; file_name = file1
dir_name = /mydir; file_name = /file1
dir_name = mydir; file_name = file1
With Python, there are 3 commo... |
I'm working on loading PNG files. I know there are existing libraries, but I'm doing this for learning purposes. Previously, I was using LodePNG, which is a great library that performs really well.
I have a large PNG, 2048x2048 pixels with 8 bits of depth. I load it ten times with my code, and average out the time it t... |
In the online book "Introduction to Modern CMake", I found the following recommendation:
Do not use global functions: This includes link_directories, include_libraries, and similar.
Yet the only 2 use cases I've seen of CMake in are:
make a couple of libraries and a binary using them OR
compile a simple binary
(fetch... |
How are physical memory addresses actually determined or 'created'. What is the process where the byte blocks have a memory address assigned to it?
I understand that this is determined during boot up, before the BIOS is executed. But not exactly sure how or what the process is.
|
I found previous SE questions like this.
I'm familiar with the typical RDBMS backed MVC web app framework. To illustrate what I am thinking of, let's use the examples of Bunny and Carrot from this [article].
In a typical MVC
For a typical MVC RDBMS, you would have two tables. A carrots table and a bunnies table. Whic... |
I am working on a grade management system web app for a university and I came up with this database schema
How the app work:
In the user table I am going to keep all the users data and the id_user_data will tell what kind of user is(student, teacher or administrator)
The administrator can add new users, new specializ... |
In our codebase, having precise management of memory, data was being passed around like so:
typedef struct {
size_t const sz_size;
size_t sz_len;
int32_t * const restrict pData;
} S_ARR_T;
int32_t highLevelAlloc[DATA_SIZE];
S_ARR_T sArr = {
.sz_size = DATA_SIZE,
.sz_len = 0U,
.pData = &highLevelAlloc[0]
};... |
Our main (C#) application:
takes in parameters and starts working (batch processing, takes anywhere from minutes to hours)
up to x instances of said application per server
instances are started by users from our front end by making a request to a "master" on a server (really bad load balancing is just one of the probl... |
I'm working with a client who currently uses a database system that they've outgrown, so we're re-building it using a different platform that can handle their growth. One feature of their current system, built into the platform, is that updates to data are automatically propagated to others viewing the data in real tim... |
I have a collection of documents, which hold a subject id, a timestamp and a value. For example:
{ sid: 1, t: 3, v: "A" }
{ sid: 1, t: 5, v: "B" }
Which means subject#1 is measured to have value A at t=3. Later, at t=5, value changed to "B". Only when a value is changed, a new document is inserted.
My goal is to k... |
I've got the following:
Clientside C# application. Contains forms for CRUD operations. It uses an API for all data operations.
Input is validated on the client, and obviously also on the server (API).
I use the repository pattern for calling my API. That's because I want to communicate with data layers via interfaces, ... |
I'm looking for a clean solution to share types, endpoints and response format between a backend and frontend. The backend will be in Python & the frontend in Typescript. The backend is a REST API.
Ideally, we will have a code & architecture as follow :
- backend/
- ...
- frontend/
- ...
- config/
- types/
... |
I'm working on a project in which I have a clear separation between domain logic and the logic that exposes these features using an API (or whatever). For this I'm using the Onion Architecture.
Now I want to implement authorization. E.g.: If the user is the manager of an employee, he can update their salary. But not fo... |
I have Orders which are raised against Contracts, which can be set up as either a fixed price contract or as per price per contracts.
During Contract setup, allowed Products are assinged as ContractProducts. For fixed price contracts, ContractProduct is set at the Contract level, while for price per product Contracts, ... |
I have a class whose instance variables should be initialized from a file ('settings.json'). That file does not always exist or is sometimes not filled with useful values, so I have to check for that first.
I am now wondering what the best practice would be, I currently see two options but I am open to better ones.
Ch... |
I have an idea to use gRPC for all microservices communication for the sake of simplicity.
Now there is a service that needs high availability, So the idea is to use RabitMQ as a message receiver from the outside.
Question: Do we still or possibly still preserve high availability by using gRPC as a transport layer for ... |
I am asking a question about the overall architecture between different projects.
Let's say I want to centralize all icons / images between different projects in a single repository. This means that all projects need to checkout / synchronize with this repository.
I am going to use SVG graphics to make sure that I can ... |
My apologies in advance for a question that might seem trivial - I am a mostly solo dev in academic environment and a lot of industry best practices don't necessarily make it here.
Several of my projects run high-performance numerical computation loops. Per se, a single iteration of the loop is rather fast (~1 sec), bu... |
Let's say that in a project we have a function (in PHP for example) that checks whether a particular user is eligible for a discount.
Also, we have a report (written in SQL) that pulls all users that are eligible for discount.
At the beginning of the project, the logic in the function and the SQL is identical, no issue... |
I saw an answer on SO which said that just having a class with methods doesn't make it OOP and that it represents Class Oriented Design.
I'd like to hear the differences between Class Oriented Design and Object-Oriented Design also want to know how can I sense Class Oriented Design in a codebase?
|
I'm creating an inventory management system, in which the program needs to handle a lot of different equipment, with the possibility for the product owner to increase the selection, without having to change the code.
Some of the products that might need to be included in the application is:
Transistors
Wires
Drones
Ra... |
I'm currently working on a web app using ASP.NET Core (C#) on the backend and Next.js (TypeScript) on the frontend. I have a lot of forms that need to be validated and I don't want to write validation rules for them twice because it will be a hell to maintain and keep them synchronized. So I want to kill two birds with... |
I'm studying asynchronous IO, concurrent models for IO and how things works on windows, linux and most used web frameworks.
I'm struggling on understanding why single-threaded event loops like the one used by node.js or ngnix, in case of handling requests that wants to make an IO operation (let's say an HTTP request to... |
I'm currently trying to solve a problem with some legacy code that makes some calculations in order to find out the final value of a monetary benefit. The legacy code uses an imperative approach with lots of if and elses to handle calculation rules for each kind of benefit, which I believe will be hard to mantain and r... |
Little History, I used to work directly for this company a few years back. Due to budget reasons I decided I needed to move on. however I maintained as a part time contractor to keep the lights on. Within the last 6 months they asked me to contract full time complete a pilot program for a new product.
I know the hi... |
I would like to create an application that will interacts with an online database and i want to host my own online database on an old computer, but i think that in this case i should handle the security and other thing by myself. The problem is that i don't know if this i'm able to handle this stuff. So it's something ... |
I have read DDD Vaughn Vernon book. There is a info about CQRS architecture. He mention that Handler can only do one Handler task, which I understand his and he cannot invoke other Handler. And even If i skip that and I invoke other handler I can't return value to connect them like with keys.
So I have this kind of pro... |
I have two separate, isolated Domain-Driven Design contexts, and have a feature that needs to be implemented to integrate them together in some way.
Both of these are broken down in a Hexagonal/Ports and Adapters style. The feature is implemented using an Event Subscriber, with an event messaging mechanism for communic... |
Lets say we have a microservice architecture consisting of:
multiple frontend clients, e.g. an Android App, an iOS App, and a Javascript Web Frontend
a Java Spring (HTTP Rest) microservice to access user data
a Java Spring (HTTP Rest) microservice to access application data
a keycloak authentication microservice
Lets... |
I saw a code example online that uses adapter pattern as:
if you look at the HR system, the employee information in the form of string array and the ProcessSalary method of the Third Party Billing System wants to data in List. So, the HR System cannot call directly to the Third Party Billing System because List and ... |
I'm defining some binary formats to encode some information and dump it to a file.
I want to place a MagicNumber/Signature at the beginning of files encoded in my format to be able to tell them apart from other types of files. My question is:
How do I choose a good signature?
I've been thinking about picking 4 bytes th... |
I'm trying to code Star Trek The Dice Game. The basic concept is you roll dice, which become different types of crew (Science, Medical, Command, Engineer, etc...) and you can "spend" crew to take actions (heal people, transport people, raise/lower shields, cause the ship to travel, repair the hull, etc...).
The game ha... |
As per the "Accelerate State of DevOps 2019" (you can download it here) they define lead time for changes as:
how long does it take to go from code
committed to code successfully running in production?
I wonder how should you calculate this when you have multiple commits because I see at two potential interpretations... |
I recently started researching about coding, but there are a few things that made me confused. I chose Visual Studio Code to start coding in C and Python (I was using IDLE for Python before), but afterwards I learned that Visual Studio Code does not contain compiler or other components that I don't know what they do, s... |
I'm a developer on a website which has a server which serves HTML and another server which handles API requests. I use a CDN to cache both the HTML and API responses. I feel that it gives me all the control I need while keeping the cache settings in one place. If I make a deployment of new website version I just invali... |
In my organization there is a release cadence to deploy any piece of code to Production environment.
We have three environments, Dev, Test and Prod and we have deployment in every 15days and the dates are pre-defined for an year.
For Eg: For 2021 we have Prod Releases on 2021.06.15, 2021.06.29, 2021.07.13 ... so on.
Me... |
The usual approach is to do what libraries do: group your (single file) classes by component where folder = namespace, right? That makes sense for code that is mostly meant to be used by other projects.
But wouldn't it be better to structure your actual application by inheritance? The major benefit would be that just b... |
I have a fun problem ahead of me.
So, I have built a solution for my company that basically handles unstructured information. It works like this:
A user creates a Task, the Task is in reality just a collection of Tags. These Tags can hold any type of value.
So, for example, if a user wants to create a Task that holds a... |
In my app I have items which are dynamically created based on an UI editor. The item details is a JSON.
The domain does not interact with the JSON details. The UI is responsable to create and render the details.
public class ItemDto {
public JObject Details{ get; set; } // JObject is Newtonsonft.JObject
}
public... |
I need to put data from MongoDB together with tracking data from a quiz app (stuff like which users clicked what button etc). Then I’ll use this in machine learning.
I looked at all the DW options such as BigQuery, and I’m asking myself if a SQL database wouldn’t be enough. Is there a general strategy to evaluate when ... |
I've got a race condition problem I need to solve with a distributed API/service and would appreciate vetting my plan and any fresh ideas I have missed.
Problem:
I have a finite amount of many (hundreds) different resource and need to know when each has been used up. The resources are consumed via API calls to a distri... |
I'm building a backend following the CQRS pattern and I don't know how to manage properly the primary keys (surrogate keys) between the command and query databases.
For example: I have a model with two different tables in each database. When I want to update the model in his different tables, each one doesn't have the ... |
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.