instruction
stringlengths
34
36.1k
I have an index file that uses three main JS classes each defining one method. The JS application is about listing a folder datasets, deleting a dataset from that folder, or uploading a dataset from the same folder. As i defined a class containing one method for each of these functionalities that i use in the Index.js ...
Recently we have this client who asks for a API Gateway solution, in this case it’s Kong. Currently, they have 10 services (200 APIs) that are running on really legacy stuff (built with C++ and Fortran). It’s a pain for third party to integrate, hence they ask for API Gateway as a front to handle authentication, rate l...
Python is one of the few languages to support a string data type of code points (Unicode Scalar Values). I'm also wanting to creating a language that has this same characteristic, but I need to understand how Python optimizes such representation. There is a PEP about this: https://peps.python.org/pep-0393/ But I don't ...
I am new to Azure Function App. I am using a consumption plan. Does it make a difference how many functions are in a Function App? What about if there are functions, such as the service bus triggered function, which is no longer called? Should these be deleted? For example, I have MyFunctionApp It has an IoT Hub Trigge...
I'm sorry, no good title. I'm working on a C project right now and am writing tests. I usually do a 'struct method' style of programming. So I have opaque structs (no implementation revealed outside of the .c file) and methods that act on pointers to them. But this applies to OOP as well. Typically, when I am unit tes...
In a Microsoft Learn article on MVVM there is an, what I assume, UML diagram that didn't make sense to me. (https://learn.microsoft.com/en-us/archive/msdn-magazine/2009/february/patterns-wpf-apps-with-the-model-view-viewmodel-design-pattern) I do not understand what is meant with the double arrow means. I couldn't fin...
If streams in programming is about reading data in chunks, how then is it possible to process the data in the scenarios where the data cannot be processed bit by bit, but the processing logic needs the full data? I can imagine in some cases it might be possible to process data bit by bit, but it is not hard to imagine ...
Context: I am working on an application which loads a cache on startup - periodically refreshed. However it turns out that this cache is something which is very general and can be used by other applications as well. Currently as a work around other applications are using rest commands on this application to fetch data ...
I am trying to create a spell casting system for an auto chess game. I find myself not knowing which direction to go in my design. I started out with a Spell as a scriptable object that contains a list of spell effects (damage, heal, etc). Each effect can spawn a game object (usually some sort of particle effect) to in...
I wanted to know the best practice(s) for ensuring scalability while passing arguments. Say, in version 1.0 of an application, the foo function looks like this void foo(int i) Now, in version 1.1, the function has to be changed to void foo(int i, bool enablethis=true) Version 1.2 forces me to change the function to v...
I'm working on a project that requires the use of verifiable credentials, and I'm looking to build a wallet that can store and manage these credentials according to the W3C standard. However, I'm trying to avoid using a blockchain for this purpose. Are there any alternative technologies or approaches that I could use t...
What are the most efficient and low-latency approaches for sharing data between threads in a C++ system, and why? My primary concern is minimizing latency and maximizing performance, as I have two threads that are each pinned to their own core: a thread that builds an orderbook snapshot and a thread that reads the snap...
I was developing a new API, and some doubts appears about context of payload data. Example: { "transaction_id": 123, "transaction_date": "2022-12-25", "user_id": 999, "user_some_data: ... } VS { "transaction": { "id": 123, "date": "2022-12-25" }, "user": { "id": 999, "some_data: ... } ...
I'm making a class diagram for my school project, an Inventory Management System. So far, I've made the use-case and activity diagrams, however, I'm struggling with the class diagram and mostly because of this one thing (stated in the title). Here's my diagram so far: See how I use the same string "products" in Manufa...
I'm working on an npm package, and I'm kind of new to this. I published version 0.1.0, but when I did, I saw that there was a bug that broke the entire package. I do not think that it is right to make a patch (v0.1.1) because that will leave v0.1.0 useless. (Or maybe I'm wrong?) My question is: What's the best professi...
I've got a file in my includes folder, which is the folder I expose, that isn't used externally and isn't supposed to be used too. When I noticed that and tried to remove it - I noticed that it's included in another file in the includes folder - the interface. So, removing this file won't solve anything because it'll b...
I have a task that is to convert cable schedules into an Excel spreadsheet. I have tried a few different OCR (Optical Character Recognition) things such as websites, code in R (tesseract), javascript, data from picture in excel and looked into C. So far none of these have worked. I believe the main 3 errors are that I ...
I am working on a mobile application, and I want to plan a separation between the model layer that represents a user (that comes from the server) and the "applicative" user that has the same fields but additional parameters. The goal is to make sure that a change in the model layer will not harm the applicative user. O...
I have seen Martin Fowler using the term "collaborators" as some sort of synonym of "dependencies". Unfortunately, Martin Fowler does not seem to define the term anywhere, so it is unclear whether he means this term to have a slightly different meaning from "dependencies". Others use the term too, for example someone h...
Arrays are stored in a linear fashion, with memory cells of fixed size for each element. To have fixed sized memory cells Arrays should be homogenious. So in Arrays we get an Nth element by skipping certain amount of bits (defined by element type) N times. But what about lists? Or heterogenious arrays like we have in J...
Note: This question is not about this particular instance of this grid with these exact words, but about any combination of words. I am programming a puzzle game where you have to arrange a grid of words correctly. The image below shows a final grid. The grid is represented by a two-dimensional string array and could l...
I am looking to create a multi-page web app. I had begun the construction of this web app in angularJS when I realized this was no longer being supported. I am early enough in development that it isn't catastrophically bad to change my implementation language from angularJS (.js) to angular (.ts). Given the lack of sup...
Having been trying to improve my unit tests, I'm trying to adhere to the principle of avoiding call verification. This is because it aligns with other principles I believe to be true: We Should test the behaviour, not the implementation details of code (i.e. don't try to prove the code is written like the code is writ...
Background I have been attempting to create a line editor in C, eventually becoming a visual editor, and as a means of both allowing the editor to be useful but also learn more about C development, I would like to implement regex in the project, however, using a library I know (like C's regex library) would not satisfy...
I like typescript, and I want to add it to some projects in the company. Thing is, it is rather powerful, probably too powerful for it's own good at times. From experience, it doesn't take long until someone who knows the type system just enough to be dangerous to define types and interfaces that are as complicated as ...
I had a discussion with a colleague and we don't seem to be able to agree. Can someone help me understand his arguments? Initial situation: We have an adapter in our application which queries other internal services and constructs out of those request an object for our service. Currently every time we want to use this ...
I am interested in robotics programming. HW control often involves calculating the derivative or integration of the signal. It seems quite inevitable to avoid local states for such calculation. (Since it must store past n signals). The advantage of referential transparency seems attractive for the safe and reliable ope...
I'm trying to develop a CRUD feature for an ASP.NET app that lets me manage customer information. Each customer can be subscribed to one or more services, and each service can have one or more terms. I'm struggling with the same types of questions for both the frontend and the backend. I'm trying to decide whether to m...
I'm learning cqrs right now. Problem My concern is event ordering. Assumption 1: user service is creating user and three events in order. Each event was sent after each step was finished in write model. Event A: user ABC created Event B: changed email for user ABC to abc@mail Event C: change email for user ABC to abc2...
I have an distributed application that sends P2P messages parallel (for fault tolerance) across different channels. This mandates an filter to avoid multiple receivement of the same message. Therfor I added an GUID as an unique ID on each message, before sending it across those channels. While it works fine, I have som...
So I'm building a client for a third API and I want to be able to Get() and GetMany() for each type this controller can provide. So I've built this adapter, that provides generically typed methods for these. public interface IClientAdapter<T> { public Task<T?> Get(string predicates = ""); public Task<List<T>?> ...
I'm not sure if this is the correct area to ask this question, quite honestly, I'm not sure how to phrase the question because I don't know if what I'm thinking is possible. I'm trying to figure out a better way to trigger third party API calls from an on Premise SQL Server database. Currently, there is a Python scrip...
I am working on a compiler in TypeScript, and currently am focused on how to pass around the "lexical scope" to the relevant objects. Essentially every time there is a conceptual major branch in the code, there is a new lexical scope created and assigned to that AST node, pointing to its parent for parent variables. mo...
We've recently taken up DDD approach to design. Some of our developers are using the Aggregate pattern (https://martinfowler.com/bliki/DDD_Aggregate.html) but to me this sounds very similar to the well-known Model approach (from MVC). Aggregate is a pattern in Domain-Driven Design. A DDD aggregate is a cluster of doma...
I'm using a REST API to retrieve data from my back end at my front end. I'd like to figure out which way of receiving data from the back end is the better one (= clean, robust, and best practiced). There are the following two ways of retrieving data from the back end (the example code assumes the retrieval of some rese...
Recently I had many problems opening old projects, which had all dependencies in package.json defined with ^ x.y.z. When I pull the code and run npm install the dependencies are installed but I will for sure have some problem with some package that is related to versions. My question is if having a package.json like th...
I'm experimenting with some projects at the moment and I am stuck trying to decide on the correct approach to this question. Given a simple architecture like this consisting of Domain - (Person and IPersonService) public class Person { public string Name { get; set; } public string PhoneNumber { get; set; } pu...
This problem is quite "a classic", but I can't find a good solution to it. I am using CreateFile to open a file. Sometimes I would want it to be read-only, sometimes write-only and sometimes I would want the same file to support both read and write. Of course I would like to follow RAII principles. I am trying to accom...
In one of the project I am working on, I am facing a problem in terms of creating an object with a dependency that sits at a deeper level in the class composition. Following diagram shows the class composition. The problem I am facing is as follows: The IFrameGrid object contains 'IBracings' object at a deeper level ...
Multi threading could cause a racing condition if two threads are accessing the same memory slot, but why is that? From a HW point of view, if the two cores are designed the same, internal pipelines are the same, the logic gates/transistors pass electrons the same way and the speed of those electrons is a constant valu...
Im not dealing with a x minute task that can use an message queue and some workers to be done. Lets say that i have an cctv camera that capture 24/7, but can be stopped or started again via Web API for example. In this example i can't just use normal task queue (like Bull in js or Celery in python) as each worker will ...
I'm working on a microservices application that is implemented from the ground up with MediatR em CQRS. We have a list of domain events that will be published via MediatR [simple pub-sub library that implements a mediator to commands and events] as soon as a Command (CQRS) commits the database. Let's imagine a new user...
My question is regarding how would the developer know when you add interfaces/protocols to their code and inject them as dependency. Consider an example of BudgetService. protocol BudgetServiceProtocol { func save(name: String, amount: Double) throws } class BudgetService: BudgetServiceProtocol { private ...
I am working on a program to automatically design heater units based on varying client specifications. The process for creating each heater is quite involved and requires multiple optional steps depending on the type of the heater and it's options. I am trying to figure out what the best way of creating heater objects ...
We have an ongoing argument in our team. Please help. Here is the problem: In our SPA web app, let's say we have a resource which can be edited by only those users who belong to the team of the user who created that resource. Now, we are sending this resource to the multiple places in the frontend. At some of those pla...
I was asked to write a use case diagram based on a description/scenario and I got a little confused when designing this use case because I doubted a little whether it's a functional or non-functional requirement (because I'm specifying how, not what) In my case, the user shall be able to add transactions manually or a...
I've got this class: [UsedImplicitly] public class ClassicalKeplerian { public ClassicalKeplerian(Angle argumentOfPeriapsis, Angle inclination, UnitFraction eccentricity, Angle rightAscensionAscendingNode, Length semiMajorAxis, ReferenceFrame referenceFrame, Angle? trueAnomaly = null, DateTime? epoch = null) { ...
In a project I am doing, I have to perform a lot of repetitive checks at the beginning of each API end point. As the amount of duplicate code started to grow, I thought of using a decorator to wrap all of my api endpoint view functions, and to perform the checks there. This approach actually turned out to be useful for...
Problem statement: The information system of a university must manage information relating to its employees, departments, institutes, courses provided, and research projects. Information relating to employees includes the normal personal data (name, surname, date of birth, ...). Employees are divided into researchers, ...
Let's say I need a queue for my project and the language I use does not have a built-in queue structure. So I decided to implement one myself. So I create an object with elements positions as the object's keys. I also keep track of where the head and the tail of my queue are. I increment and decriment those values when...
I am new to Kafka, trying to do a project. Wanted to do it as it would be in real life example, but I am kinda confused. While searching thru the internet I found that if I want to have 3 brokers and 3 zookeepers, to provide replication factor = 2 and quorum, I need 6 EC2 instances. I am looking thru youtube to find so...
Assuming I wanted to implement the Database per Service pattern or one of its related patterns like Private-Tables-, Schema- or Database-server-per-service (https://microservices.io/patterns/data/database-per-service.html) for microservices: How do I go about this if I want to run the databases in Kubernetes and not wi...
We would like to differentiate (by HTTP status codes) between correct request but the requested resource is missing or deleted and resource not found because of invalid request (URI). For example: /api/non-existent-api-because-mispelled-path which returns 404 because the URI doesn't exist. And /api/my-awesome-api/{id} ...
I have a service which is used to register tasks. These tasks are asynchronous and executed in background using a state management engine. The state management engine is running inside the service and it is executing 4 concurrent tasks at a time. I have an algorithm to auto-scale the service based on the number of task...
Goal: I am learning about SOLID principles and trying to refactor Gilded Rose code, in order to make it fresh and clean. What I have done: I have created an AbstractItem class as follows, which "wraps" Item class: public abstract class AbstractItem { protected static final int MIN_QUALITY = 0; protected static ...
The article "Products over Projects" by Sriram Narayan makes the case for treating projects as products. I can see many benefits to this and would be my preferable methodology, but the examples of 'projects' referenced in this article seem to be 'almost' products already in that they are delivering shared components th...
I'm working on a HR application that has employee management and access control. We decided to go with these bounded contexts: Employee management: manage employees information, like name, contract, birthdate etc Access control: manage whether an employee can get into the facility, in which case we upload his or her f...
There are few reliable absolutes in this world. One I have relied on is the idea that checking if a file exists before doing something with it just creates an unwanted race condition. Meaning between the check and the attempt at usage, the OS was free to do whatever it liked with the file. So I had no right to expect a...
So I've been going over some design patterns and I came across this discussion https://stackoverflow.com/questions/43565475/using-lists-instead-of-decorator-pattern I've been thinking that in all honesty I can always replace a decorator design pattern with an ArrayList of methods that I can activate in the order of ins...
Suppose I write a function with the following declaration: void sumAllBytes(const ByteArray& bytes); I will use Qt as an example because that's what I'm familiar with; but I am asking about the general concept. For those familiar with the Qt framework, it provides a QByteArray class. I want my code to be able to work...
What is the best practice, for creating a template repository, and then creating n projects based on that template? With "template" I mean: Let's say the template site is x. So x is a site with features that many new sites will have in common, and would want to utilise. For example, features like login, authentication ...
I am working on a form building feature that will be used across different applications within our organization. Since each app has a slightly different stack we are planning to implement this feature as its own service. It will be hosted separately from our other applications with its own isolated database. I am prett...
When writing tests for my FastAPI endpoints I am not sure which is the best way to setup the test (store data in the DB, prepare data for the body of a POST call, etc.). I can either use: direct calls to the DB to set it up (SQL) methods from my Repositories (Repository Pattern) other endpoints to get tokens, prepare ...
I'm attending a software engineering class at my university, and my final consists of a fully-documented desktop application to be built in a four people team. While designing and coding this software, there's a question that always pops in my head, since my professor keeps repeating that everything that happens in cod...
I am designing a new process to request service accounts. I am in charge of both, the process design and the technical implementation of the request & creation flows. I am new to BPMN and currently learning as I go. The process starts when an employee requires a service account. The next step is that the employee fills...
I have this object RelativeFoo{int relativeCode, Origin relativeTo} And I want to map it to this other object AbsoluteFoo{int absoluteCode} In order to do this, I need to use a service whose implementation calls an external API AbsoluteFoo absFoo = fooProvider.obtainAbsoluteVersionOf(new RelativeFoo(1, Origin.BAR)) ...
Should I use separate actors for "Video Watcher" and "Channel Creator," or a single actor called "User" that represents all users of the system? i have a webapp where user can participate in an event and user can also create their events and manage them i cant find an answer should i use separate actors organizer and p...
I'm looking for some guidance around REST design for user account endpoints. I generally understand REST and some of the principles involved, with paths being used to fetch items from a resource: /user/{id} This is generally fine, but I've run across a design problem that could have two options. In many API's I've se...
Similarly to a sports team chemistry or even a better example would be fifa ultimate team chemistry where putting certain players in the team would improve the team's overall chemistry Say there are around 20/30 possible players How would i go about doing this with examples like this: player A, player B add to the team...
(FYI: I asked this question on stack overflow and was directed here) My problem is as follows: I have a dashboard running on a server at customer premises which updates every 15 minutes The dashboard has multiple views The dashboard has hundreds of KPIs (key performance indicators) I want to replicate the dashboard at...
I have a Product entity: public class Product { public int Id { get; set; } public string? Name { get; set; } public string? Description { get; set; } [ForeignKey("Brand")] public int BrandId { get; set; } public Brand? Brand { get; set; } public List<ProductVariation>? ProductVariation...
Overview I am tasked with designing a system that serves as an Interface between a User and one or more microcontrollers in different Variants. As an example, our Microcontrollers Type 1 are milk frothers. They heat milk to a preset temperature, also they spin a little circular spring to make the milk foamy with varyi...
I have the following dilemma with designing a piece of software. How can I design a relation between the follwing entities so that a configuration rule can be global or apply to a building / room or a combination of buildings / rooms? How should the result data I think I should use the following entities: Configurati...
The Microservice arcitecture is still a new thing for me to work with, so it gives me some unanswered questions. In my case each MicroService has its own database. I need a UserService to handle CRUD operation for users. Lets say we have a User table with the columns Id, Name, UserTypeId and a UserType table with the c...
I have recently developed a small module that performs queries against a database. At the end of each test that contains code performing modifying queries against the database, I added an assert that checks that a record irrelevant to the query did not get affected. My reasoning is that I want to prevent a future deve...
I have read many blogs and stack exchange posts about global state (usually) being bad practice. I'm now trying to avoid this where possible in my code, but I'm running into a case where I don't know how to avoid global state: Suppose I have a task which handles events. If I want to count the number of events it proces...
Suppose I have a std::span-like type, that represents a matrix or an image, or a class modelling a 3d mesh. I would like to say template<class T> class 2d_span; class 3d_mesh; But that would obviously not compile. What to do instead: Use exotic unicode symbols. They are sometimes hard to read (depending on font), an...
I'm developing a web game that currently all runs on one server. It uses SignalR to maintain connections between the server and clients, and the server also sends all the web stuff to clients (HTML/CSS/JS/etc.) I've been thinking about how this would scale up if many more clients were to start using the site. Reading...
I know that a lot of interpreted higher level languages like to abstract a lot of things and therefore cannot directly be compared with lower level constructs. For example in some languages primitive values are implemented as references to value-objects. Most famously in Python. When I learned programming, I was taught...
I am currently working on my own iOS application and am going to be using a locally developed API for fetching data. I wanted to outline my current account sign-in architecture and verify this is correct and can prevent as many security holes as possible. I will be using Patreon OAuth to verify the person logging in is...
I was working on a small CLI tool to convert between time units and seconds. Someone filed an issue about how the code was treating a year as 365.25 days while the Gregorian year is supposed to be 365.2425 days, where 'day' is defined as 86,400 SI seconds. Upon further research, I stumbled onto the concept of mean trop...
I have a gRPC service and I was thikning about the security aspects in the client side. I have only one certificate (public and private certificates) for the client, that it is uses for all my clients, WPF clients, Android clients... etc. By the moment, in my WPF client application, I copy the certificates (certificate...
This has erupted from quite a turbulent meeting between two senior developers, a lead developer and an engineering lead, and after 90mins reached no resolution. We create Spring Boot Java services which are then dockerised before being deployed to an environment. As part of our automated build our services are compiled...
I have been going over our app web api and making sure all async work is async all the way - and no artificial asynchronicity is enforced. Say I have the following web api controller: [HttpGet] public async Task<IActionResult> Foo() { //no async work return OK(...); } I planned to remov...
The company I work for is maintaining and developing a web application that uses many Node.js packages. A lot of these packages are really outdated. I can intuitively understand that it is good to keep packages updated but I was looking for concrete reasons as to the benefits of updating such packages. What are the var...
I'm trying to know if we can freely raise new exceptions when maintaining methods of a versioned library. Here is a minimal example of what the change could be: import logging def check_id_old(identifier): """ :param str identifier: An identifier that's less than 10 characters long :return: a verified ide...
I'm trying to find the best solution to abstract the return type of the service layer. I have a controller that calls a service to create a user. The service calls a REST API and receives an HTTP status code (201, 400, 409 ...). I don't want to return the HTTP code to the controller to keep the application loosely coup...
I've been tasked with refactoring/simplifying the architecture of a (relatively) large node.js codebase and it makes ample use of global variables. I don't have much experience with javascript so just wanted to get a general sense of whether this is indeed super confusing and bad practise or if I'm in the wrong. Here's...
We store data – some kind of metadata like car manufacturers or types of computer parts – in one of our applications. This data changes rarely. Let's say it changes once every two weeks. This data is also relevant for other applications in other domains. We now want to make this data available to these other applicati...
My task is, I think, pretty interesting, if a bit unusual. Any number of threads can call function f(). They add some data to a buffer and begin waiting (the function is blocking). Eventually some extra processing has to be done on the whole buffer, and all the previous calls to f() wait for this processing. Either the...
I have a Azure Web App that generate different types of notifications. At the moment, every notification is written in a queue. A queue function I call scheduler read the notification and redirect it toward other functions. Each one of those functions generate a type of notification: email, push, sms. I have different...
Given: Let's say I have 3 objects A, B, C that form a cluster. Each unit (A,B,C) is independently tested with mocked collaborators. The "integration" is the call to A that calls out to B and C based on some conditions (e.g. either both are called or only B is called, say). Testing Approach: Unit test for A relies on m...
I work on a survey that has a lot of questions. This means we have a lot of columns/variables to work with. This translates to a lot of conditionals that have to be done a certain way according to a specification. The implementation in the code can be different, but it has to map to the spec. We are moving toward Pytho...
We're all too familiar with waiting for compilation, especially on large projects. Why isn't a thing to interpret a codebase for quick iterative development instead of generating code for a binary each time? Is that because if we are compiling at -O0, most of the compilation time comes from parsing, so it won't matter ...
We have 2 vehicle types in our system Car and Bike. Both can be associated with a Report. There are components in our system which operate on Report but when dealing with the report they need to check if the report is for a Bike or for a Car. I'm trying to decide between these 2 options Create a report type for each i...
Really dumb question. I really like the new feature called "optional chaining" in JavaScript, and it's used in quite a few places in my front end code. However, I am concerned that whoever maintains JavaScript, maybe Mozilla Foundation, will remove this feature in the future, and my code will be broken. Is that likely?...
Let's say that there are two products, product A and product B. Product A is a desktop product that customers download and install locally on their machine. This product follows a typical versioning process where quarterly releases are sent out to customers to install at their own discretion. For example, 2023.05 woul...
I created a simple parser in Rust and defined the AST like this: enum Expression { Number(i32), BinaryOperator(Box<Expression>, Operator, Box<Expression>), Identifier(String), } enum ProgramLine { SetIdentifier(String, Expression), Print(Expression), } struct Program { lines: Vec<ProgramLine>,...
In a Flutter app I'm developing, I have a class hierarchy of model objects of a certain base class. To take a typical example, the abstract base class could be Vehicle. Then I have a (pretty much) parallel hierarchy of widget classes that show info about a particular subclass of Vehicle: Car objects are shown with CarW...
Web browsers are imperfect machines. So let's say you came across an error. You might search your code to find the problem, and then failing that, you turn to online research that indicates the error isn't because of an error in your code but some error or other unexpected quirk in a correctly-configured browser. Your ...