instruction
stringlengths
34
36.1k
Cross-posted from stats stackexchange Say I have a logging utility in my application that I use for recording timestamped diagnostic log messages. I want to add tracking of some performance metrics to this log. Moreover, I want to do this intelligently, so as not to explode the size of the log files. A convenient way t...
I have a monolith implementing what is basically an ETL process, receive data from external system, orchestrate the processing of it, and then pass the results back to an external system. (The monolith does not perform the actual processing, that is handled by external services This monolith is deployed on-premise to o...
I am creating a unique "key" object type for a tree, we will call this object type a TreeCoordinate. A tree in this case is a fairly standard mapping of nodes from parent to children where each child holds a reference to the parent. The parent holds a list of children based on their index. A node can have zero to N num...
I am the newest programmer on a very small team of 6 developers, 3 of which are offsite. By "newest" I mean both in years of experience (drastically) and familiarity with the code. I've been with the company for a couple years, though only recently shifted towards programming. I have no formal education on programming ...
Background We have a number of backend api's that do work; some connect to equipment, some store data, etc. The original setup was each service was a native c# asp.net 6 minimal api running on a windows server 2022. I was able to convince the right people we should be using docker, but as a compromise, I had to write a...
Assume we have a single large JVM project (the example is in Kotlin), containing code. As part of a refactoring effort, we are decoupling pieces of the code by splitting the code into multiple modules, and using a build tool such as Gradle/Maven to build deploy applications with only a small set of the modules. Some mo...
I’m starting at numerical methods and I am introducing to the machine epsilon and succesor. I have this question, which is the succesor of .13579x10^2 at a floating point system of (10,5,-2,6). My intuiton is that it must be $.1358x10^2$,but then, I know that $.13579x10^2 + \epsilon$, where $\epsilon$ is the roundoff u...
Background: I'm a scientist working with a small team on data analytics. No one on our team has any experience with software engineering, though I'm trying to change that. Suppose I have an array A that constitutes some measurements. I have a script that transforms A-->B. I also have 3 separate scripts that transform a...
I'm playing around with DDD, and in particular in cases that involve remote service calls. I'm building a system where the user records are actually backed by Cognito, so I've got to work with the Cognito IdentityProvider SDK instead of a local database. In terms of just loading and saving data, that's pretty easy. I'v...
Currently, I'm designing the Project based on Clean Architecture composing with 4 layers: Domain Application Infrastructure Presentation Since the project is pretty huge, I'm now considering to separate the Application Layer into Multiple Module Layers. For e.g. Application.BackOffice, Application.FrontOffice, Applic...
I've seen such a convention. Whenever a public method is declared, two classes are also defined that enclose its return value and parameters like this: public MethodNameReturnDTO MethodName(MethodNameParametersDTO parameters) { // method body } public class MethodNameParametersDTO { // blah } public class Met...
In my company's codebase, we hardcode sql queries without using an ORM. Here's an example of a query we would run: UPDATE client SET status="active" WHERE client_id=123 Since the query is hardcoded and the parameters are passed in, the code would look like this (Python): 'UPDATE client SET status="{}" WHERE client_id=...
We have a requirement to store key value pairs (KVP) in Kubernetes and looking for possible options here. The requirements are as below: KVP are small sized - 200 characters together. KVP are short lived - 5 mins max, we don't need it beyond and thus clean it up. KVP written from one node, retrieved on a different one...
I'm sure this has been touched upon by a number of questions, but I'm struggling on drawing the boundaries between code, data and configuration versions when working with a large DAG (think airflow or Dagster). There are a few things that change over time: The source data (data always changes over time) The code (code...
I'm relatively new to OOP. Let's say I have three different objects/classes defined, like: Public Class Part Private m_Name As String = "" Public Property Name() As String Get Return m_Name End Get End Property something... End Class Public Class Assembly Private m_Nam...
My scenario is fairly typical, but I can't figure out a good solution. I have a DB table (in reality several unrelated tables, but let's focus on one) where there is a fair deal of activity going on. In the table: Records are rarely inserted Records are often updated (I expect multiple records to be updated every minu...
Suppose that I have a class named CharStream Additionally, there are a large number of functions which convert their function input into a CharStream def funky_the_function(_input): input = CharStream(_input) # do some processing return output There is no need to convert a CharStream into a CharStream if...
This question is about how to be a good citizen in an open source community, and do my part to effectively participate, to advance the project/not harass people. I am building a medium-sized C++ project at work. My toolchain is the Clang with LLVM 15.0.7 on 64-bit Windows (the most recent LLVM release for Windows on th...
We are working on a suite of Python 'services' each of which is basically an application that does some calculations based on a domain (data) model and returns the results. These services are designed to be called individually by only providing a domain model. We also have one large "main" service, MainService, that or...
Im currently working on a college project on the simulation of magnetic interactions of particles, see physical simulation: design thoughts. Right now im starting to code my system according to this design: However, I'm realizing that I haven't thought the communication between my PhysicsWorld and my PhysicsSystems th...
I have a C# application that needs to connect to either an Oracle database or a SQLite database. The databases can be considered "identical" - same schema - but users have the ability to "load" their own SQLite file for faster local access. I'm trying to design a data access layer for this need. My problem is that the ...
To best explain my context, imagine that I’m creating an alternative piece of software to google analytics (since my personal project’s principle is similar). Each unique user creates an account and needs to place a tracking script on their website so that their website visitor actions can be tracked. Something like th...
Dilemma: I am working in microservices (MS) architecture for a product with shared (PostgreSQL) DB between MSes and DB Views exposed as Data Access API between SW Components, written and maintained by different teams in different languages (Java+Hibernate, C#, Python). I have tables/views like root with columns id, nam...
Using Typescript, if we imagine an entity like this: interface Order { id: string; address: string; } Now I would like to design a system where we can process entities feeling confident that the address field won't leak by accident, e.g. if I were to log that entity. For example I can imagine a logger that runs al...
I'm a Java developer and I'm try to separate my code to packages (modules, services, whatever the chosen unit of functionality is). Let's say I'm creating a system that tracks employees and the company laptops they are using (this is not a real example, I'm working in a bank). I have an entity in my model called Employ...
What exactly does Hosted-Application, Cloud-Enabled, Cloud-Native and Cloud-Agnostic mean? Pros, Cons, and when to use? Unable to find a similar question on Stack Exchange.
I'm trying to use Kafka for my event handling, but I'm struggling a bit to understand what pattern I should use. My use case is this: One consumer waits for one type of event. When that event is processed, the same consumer need to produce several different types of events to different topics using a subset of that in...
In a library, there could exist three types of functions. The first are those which are visible to the user i.e. their declarations are installed in the library's include directory. The third are those which do the core work of the function by e.g. getting into the numerics in a highly detailed fashion. The second are ...
Assume that an external library or framework not under our control exposes a Controller API: abstract class Controller { abstract fun call(): Result } Assume that we want to handle exceptions from all of our Controller implementations using the same exception handling logic: abstract class ExceptionHandlingControl...
I have an application with dependency injection that consumes a REST API. The API calls are abstracted into entity-specific repositories. Some of the repositories are: HttpNotebookRepository, HttpPageRepository, HttpBookmarkRepository, HttpUserRepository and their corresponding interfaces. I have a NotebookHierarchyCon...
We have research code that consists of Jupyter notebooks and large data files. At the same time, we also have production code that consists of Python source and CloudFormation templates. There is currently no overlap between the two - the directory structure is different and research code is rewritten into production c...
I'm looking for the most proper way to design a modular application with ServiceLoader. --MAIN IDEA-- module app.view | exports app.view.View interface that defines UI api module app.engine | exports app.engine.Engine interface that defines Engine (core functionality) api module app | (entry point) requires and uses a...
Virtually all (imperative) languages offer the operators < <= >= > for lower, lower or equal, greater or equal and greater. But why no ternary range operator like (10 < x < 100) to test if x is between 10 and 100 or an inclusive one 10 <= x <= 100. Would this make parsing prohibitively complicated? Or is there even a l...
I was taking the PluralSight course with the title “azure-devops-continuous-delivery-release-pipelines” and it makes a big deal out of (ie spends a lot of time talking about) separating the release and deployment concepts, and adding features behind feature flags. Where Deployment = binaries in production; Released = ...
I'm maintaining a library written in C++, which offers modern-C++ bindings for another API that's C-ish (it's this one, although I'm trying to make this question somewhat more general). Now, when I started working on this library, it was 2017. The newest published standard version was 2014, and 2011 was already popular...
I am refactoring an old application which has about 200 user permissions. Based on access permissions for the user, menu items for webpages will be Enabled or not. Permissions are also checked on the Load of a webpage to see if the particular user should have access or not. At the moment there are a few "category" perm...
This might be an opinionated question but I'm eager to hear your anecdotes as I'm at the beginning of designing a new API. Now I'm questioning whether I want this API to be a sink API or non-sink API. I call it that for the lack of better words (and I heard that somewhere so it might even be the right wording). A sink...
Scenario: Given a class with some internal state and methods to manipulate this state, I want to limit the exposed methods that are available to potential clients/users of my API. TLDR: In the following, I present a simple example describing the problem and four alternatives I have considered. Answers should either poi...
Do software developers actually use UML diagrams, and more specifically object models, domain models, system sequence diagrams and operation contracts? I am taking a computer science degrees, and we're spending a lot of time (significantly more than programming) learning about UML and different types of diagrams. But c...
I'm currently using Azure AD as my identity provider and Keycloak as my intermediary/broker for my client applications. However, I need some user attributes (such as phone, email, picture, and officeLocation) that aren't provisioned from Azure to Keycloak by default. I'm considering two options: fetching the additional...
It seems that the RFC8259 and ECMA-404 definitions of JSON are unclear on the escaping of solidus, aka forward slash. RFC8259 states: Any character may be escaped. All Unicode characters may be placed within the quotation marks, except for the characters that MUST be escaped: quotation mark, reverse solidus, a...
When writing a tokenizer, what is the standard practice for handling aliased language keywords? For example, notethat signed short int is a language keyword in C++ and several aliases might be allowed. signed int short int signed short int Do we map several different misspellings of a single language keyword to som...
I am trying to come up with a branching strategy. We have two teams working on the same product which is kept in one repository. Both teams have different release plans and if both teams merge on develop then it will be create or problems for another team to release as release branch created from develop will contain c...
I have a repository with various tools/scripts written with ts-node and used in many projects. Initially, it contained several automation/analytics scripts, one package.json file at the root, and one index.ts file as an entry point. I just uncomment the one call to the function I need and type npm start. Debugging in V...
We are working on a big feature, because we don't know how to make it any smaller. I got to a point, when I need to merge my changes from our feature branch into develop branch (we're using Git Flow), but there are many conflicts, some of them are in the GUI which I have no idea what is doing, some of them are in code ...
We have 2 systems Legacy & New and I have to migrate the data from the legacy system to the new system. The legacy system exports the data in .csv format while the new system accepts the data in XML format. I've built a converter to read the data from the CSV files and consolidate them into XML. Some of the CSV files ...
I am trying to build an IVR system that requires some form of username & password/pin entry to access sensitive data. My naïve solution seemed obvious enough, until I realized that username/pass over a keypad essentially reduces to a long string of digits (0-9) -> easy to attack. The application is designed to be a sor...
It's obvious why you should track ongoing bugs. It's not at all obvious to me why you should track solved bugs. If a bug is solved, then just email the person who submitted it, delete the bug once they're happy, and maybe give your boss a thumbs up. Despite this, every bug-tracking guide I've seen suggests to track whe...
We are trying to implement an authorization and authentication service for our product. Now, we would have to cater to different kinds of IAM systems like SSO, LDAP and Basic Username+Password in Database for accessing our product since we have different kinds of client applications that use either one of these securit...
I have done thru where do bug fixes go in git flow and the git flow and github flow pages. There are scenarios many times when we need to show demo of new functionality and on same day fix issues of prod. So for a few hours have one branch in QA and for a few hours another. Or pushing to beta/ UAT we want to test in st...
I am developing a .NET Windows application and I need to make requests to a SQL Server instance. How do I secure the authentication data in my code in case someone decompiles my application? I know there are ways to encrypt the connection string, but if someone decompiles the application, they gain access to the encryp...
Looking for ideas in how to go about providing an estimate for project completion, when a fairly large percentage of backlog is not defined enough to confidently assign story points. This is a management request and we have to provide something. For the portion of the backlog that is defined enough to assign story poi...
For example, let's say that I have an endpoint to get a list of buildings, that can be either apartment or house. The client can filter by apartment or house. Apartment has a property floor that house doesn't have, so floor will be null for all houses. For a response with a list of houses we would have { [ { ...
I am developing a micro service that saves votes to a relational database. I have a use case with an entity that represents an aggregation of votes. I receive events from voters saying that they vote in favour of, or against X. This will increase values on the given entity, and these changes need to be persisted to DB ...
I have an application in which a client interacts with a backend, which interacts with blockchain. Since blockchain executions can be time-consuming, they are executed asynchronously within different services. I have one shared database. There are total of 3 services. Rest API service: this layer serves all the reques...
I'm trying to design and develop a software (part of a bigger application) that should compute and render a spectrogram. The spectrogram can be rendered either from live microphone or a file (assuming its content has been turned into a float array) and using two different algorithms, i.e. FFT or DCT. In case the spectr...
I am working on a class design question - design a simple grocery store with a self-checkout system I am a beginner After briefly jotting down requirements, I started with the Product class as follows - class Product{ String barcode; int price; String description; ... } However, some products like vege...
Something that's bugged me for years now about ASP.NET (Core) is that it's standard practice to set up dependency injection in the Web project, whether through the Startup class's ConfigureServices method or through the newer WebApplication.CreateBuilder's .Services.Add... style. I recently experimented with adding the...
I have realized that PHP can treat string variables as numbers (as long as int or float values are stored in the string variables), for example: <?php // Declaring two int numbers and one float number as string variables $i = "10"; $j = "3"; $f = "5.2"; // Adding an int number and a float numbe...
I have the following requirements : A player in an FPS Shooter game has health points, where he can take damage and regain health. One of the ways to regain health is by using a Health Booster that has been purchased from the store. One of the packages is a SmallHealthBooster that increase the health by 10 (or to ma...
I have recently started working with a new large company, which has lots of different teams, working on different products, which are largely self-managed and are run quite differently. My team is apparently "not using estimates", which, as initially explained to me meant that we have a "rough project delivery date" an...
In MVC, I often seen all models in a models.py module, all views in a views.py module, and the controller - you guessed it - in a controller.py module. In other projects, I sometimes see all exception types grouped in an errors.py module. In a recent project, I saw all SQL query strings for all tables in a queries.py m...
When writing code in a programming language that has the option of creating standalone functions vs. methods of a class or struct, what is the most relevant objectively-quantifiable reason to choose to implement any specific functionality as a method of the class or type instead of using an independent function that ju...
I'm reviewing changes to a widely used library, which are supposed to be refactorings, and so we want to minimize the risk of introducing any accidental regression. Of course, there are changes from this: if (!BlobExists()) to this: if (!await BlobExists(cancellationToken)) This looks like an impure refactor...
It is possible to nest many decorators. @decorator_one @decorator_two @decorator_three @decorator_four def some_silly_function(): pass How do we write a decorator class so that the order in which the decorators is applied is inconsequential? Ideally, for this application, we could permute the order in which the de...
Background I'm currently working on a project using domain-driven design and Dapper as my ORM. The entities are naturally slightly different than the tables in which they are stored (e.g. _id is protected rather than public, collections are read-only, etc.), and I'm struggling to find a good approach for restoring the ...
I am currently working on a C# Azure Function that is triggered by an HTTP request. The function's purpose is to extract raw data from Azure Table Storage and output it to the user in the form of a large JSON object. However, I have observed that as the amount of data I am processing grows, it takes an increasingly lon...
I am trying to build a file editor, and I wanted to build the UI using Flutter. However I wanted to implement IO operations (reading a file, applying changes, etc) in Rust. The reason I would like to use Rust is that it would be faster for expensive operations and also seems to have a better serialization framework (th...
I have recently stumbled upon a use case of extension methods and wanted to gather some design thoughts. The problem: A IEnumerable of a POCO and within that list there should exist a POCO that satisfies a condition say POCO.IsTheRightOne == true. You could write and extension class for this query public static class P...
Couple of years ago, I designed an API service which has a limit on the number of requests per month per user. To track the monthly usage of each user, I used a table called monthly_usage. The table structure is as follows: Column name Type Description id integer A unique identifier for the user current_perio...
There is a coding anti-pattern I've noticed (while using .Net). You declare a data class, which is supposed to have a dictionary field (or get/set Property), and lets call it 'Properties', for the sake of example. It has a string key type. public System.Collections.Generic.Dictionary<string, object> Properties { ge...
We are a team of around 60 software engineers divided into almost 6 teams. We are working on an ecommerce project and following microservice architecture. Each team is responsible for their own service. As team size is growing and we are moving towards bigger and complex features, inter team dependencies and communicat...
Background: We're providing an API that provides information about all users within a given group. Our API is a high level facade over another low-level REST API. To gather those information we first have to get a list of all users in the group via REST call to the low-level API and then for each user do two additional...
I am creating a platform which allows multiple users to edit a file simultaneously and I was wondering if using a web server with routes could be the correct architecture for this goal. I am trying to achieve something similar to Figma or Google Docs, where they allow multiple users to edit a single file concurrently. ...
Let's assume we need to send a message, and to do so we would like our client to be concerned only with constructing the message (DTO) and using a facade service to send it. We already know that we could have various services capable of sending messages of different types and we want to avoid going to change our struct...
Imagine there is an Order entity that has a lot of states and conditional transitions between them. At the moment it is stored in a relational DB. There are multiple consumers of Orders that perform a select for update within a transactional method and then run a huge spaghetti of code to handle all the possible transi...
Many languages such as C or even C++ or C# or Java have no natively supported vector (SIMD) types or functionality. In such languages, one would have to either use non-standard extensions or third-party libraries to access vector types/instructions, or make due without them and just hope that their compiler is smart en...
Overall cost and simplicity are the primary strengths of the layered architecture style. Being monolithic in nature, layered architectures don’t have the complexities associated with distributed architecture styles, are simple and easy to understand, and are relatively low cost to build and maintain. However, as a cau...
I'm trying to make this function called walk in C. The idea is that the function takes as parameters a point in space (represented by an array), a function (pointer), and a step size / learning rate and moves from the provided point in a direction that minimizes the provided function. The problem that I faced is regar...
When I read about DDD, it is always said that it is about behaviors, said in another way, actions than can be performed. My doubt is that who should start the actions. Suppose I have a bounded context (BC) about orders. For the example I will tell just a very few rules. An employee receives an order. The employee crea...
When does it make sense to put data in elastic search vs creating secondary indexing on Primary datastore? Elastic search with another primary store Pros: Primary datastore can be optimised for read write usecases. Elastic search suports more than just key value matching like fuzzy match, etc. Cons: Out of sync with...
I'm using a MacBook at work. Per company policy, no other devices are allowed. I am developing a Go application, the production environment is Linux and will be Linux only. But I run tests locally to determine whether my work is ready to be reviewed because the app, as far as I know, is not using OS-dependent features,...
In this scenario, my renderer process' goal would be to make an HTTP request to an external web server and receive responses. My question is: which options below would be more secure, give a future developer less headache in terms of the development process, and also be better as a general design approach (whether in c...
Here is the design step by step: User opens a webpage Inputs few details in the form Click submit Request goes to API server API server creates a pod in Kubernetes Pod executes a script and stores the output in shared storage Another pod keeps running and attached to the shared storage API server waits for pod executi...
I am trying to figure out how to design SaaS system that offers subdomain per customer (e.g. <customer>.example.com), where each customer is on specific region. Due to compliance and regulation, some customers must have all data in specific regions. There are two deployments of existing system (US and EU) with differen...
I am wondering about some architectonical decisions in our system. There are situations where we are sending import business events through kafka which should be performed in every case. All the cases are working just fine except one - deserialization issues. We want to be informed when particular event has not been pr...
Will anything that's written in c/c++ be rerwritten in rust? for maintainance, even for performance?
Reading about DDD, i have read that it is needed to have a repository per each aggregate entity. For example, in an ordering system, I should have a repository for the order and another repository for the buyer. If i am not wrong, a unit of work it is to ensure that all the actions are processed as a unit, so if i do ...
What is a good pattern to refactor a chunk of code where you can identify smaller chunks, but the results of these smaller chunks are used in other chunks? An example should make things more clear. Let's say you have something like this (reduced in size to make things easier): public Response CreateCustomer(CreateCusto...
Background I've been working with a team of 6 for the last couple of months doing enterprise software development. About half the team is very new (2-6 months). We loosely follow Kanban and manage/track work through Azure DevOps, with code reviews using pull requests. Challenge I'd like to get early feedback on my code...
I would love an opinion on system design in a distributed system that operates under the same domain. I have a bunch of microservices following the Database per Microservice pattern, and updated via events where each database stores a partial representation of an object, based on what information they need. Due to chan...
Let me first describe the situation I have a component that uses dependency injection through a service locator. In the first scenario (image 1) the component needs a class that implements Interface0, so it just asks for it at the service locator, something like this (in pseudocode): Inferface0 i0 = serviceLocator.get(...
I have a question related to the best approach when resources are limited, such as on the Azure Function consumption plan. I have an IoT device, and the number of IoT devices is likely to increase to several hundreds, then progressing to a few thousand. These IoT devices need to be instructed to switch on and off exter...
Basically I have this class file which was getting quite large with functions and type definitions. Is it best practice to keep all the code that works on the same aspect in the same file for "Single Responsibility Principle" or should you move parts out to different files, perhaps in a folder with the name of that old...
Because I have multiple entities with unique fields, I need multiple repositories for each one even though each Entity will be handled exactly the same. What is the best way to handle these separate repos without repeating code, minimizing if statements, and avoiding code smells? Originally I chose for the Service to h...
I'm looking for some advice/recomendations on structuring an application which involved multiple classes that need access to each other for the sole purpose of tasking (i.e. class A needs to pass something to class B for processing, but class A doesn't care about the result. Class B may later produce a result which nee...
(I am facing this issue with code written in Swift, but would appreciate any high-level pseudocode solution, just so that I may wrap my head around the architecture) I need to find an architecture that would allow me to store generic data into instances of a specific type. Consider the following example: struct Project...
As part of an migration from .NET Framework to .NET Core we're looking to decouple elements of our monolith into more manageable modules. Ideally following a clean architecture/DDD/microservice approach dependant on each module. Two major elements of our system include a CMS and an Ecommerce Product Catalogue. Currentl...
I have recently read about the so-called "distributed enum anti-pattern." In particular, as it relates to using enums in conditional statements. (The idea is apparently that if you were to add a new enum value to the enum, you might forget to update all your code that consumes the enum, leading to bugs. Violates the "s...
Imagine the following: Persons table: (Id, FirstName, LastName) PersonEmails table: (Id, PersonId, Address) (to allow a person to have multiple emails) Contacts table: (Id, PersonId, UnsubscribeAll) (special table, because only some people are in the role which allows them to subscribe) Subscribers table: (Id, Contact...