instruction
stringlengths
34
36.1k
I am looking into Event Sourcing. One of the key points is about saving the differences to the event store rather than objects themselves. This is fine in simple examples. However, I am struggling with the correct way to do this in the, more complex, real world (i.e. you could have an object with 20 properties on being...
I'm receiving a JSON object which has many properties and the properties change (properties are added/removed) according to the type of the data in the JSON object. I'm expecting to receive many different types of data. Each property in the JSON needs a type of formatting. Example: // objectA { property1: 10 type: ...
In a document editing web application such as Google Docs or Evernote, sync/save has to happen almost instantaneously to make sure data loss is minimal in case of a connection failure or a client crash. A straight forward solution seems like to have the update end point called at short time duration or each time user p...
I am trying to understand the difference between Reactive Extensions and Message Queue? Are they competing frameworks? Can they be used in conjuction? Started programming, and trying to understand this. Reactive Extensions: " The Reactive Extensions (Rx) is a library for composing asynchronous and event-based programs ...
In Microsoft Azure one can store secret values like passwords in Azure Key Vault, but also as encrypted variables in Azure Automation (these ones are stored in an Azure-managed Key Vault behind the scenes). From a solution design perspective, if Azure Automation is used to trigger all the solution code executions, is t...
I have a microservice, lets call it microservice A. It talks to another microservice's REST endpoint, lets call that one microservice B. I'm monitoring the health of microservice A using the Springboot actuator health endpoint. I've had a code review comment that says that microservice A 'should' also be checking the h...
As a practice I'm working on a CPU simulator (runs at about 1.78MHz) and I'm using a switch statement to execute correct opcodes based on the value in the IR (instruction register) variable. This switch statement needs 256 cases. While it may not be that big, the switch statement needs to be executed many times in a sh...
I am new to DDD approach and need some advice. I am going to use event site as an example. Say user can create event with start/end date. Event status can be running, expired, closed. Closed status can only be assigned by user manually after creating event. The other two status are calculated on the fly by checking the...
In an Event Driven Architecture when there are more than one microservices say A, B that publish same Event say Order_Created and a service C listening to it, performs some actions and publishes an event say Credit_Reserved for each new event on this type. My question is, while I can keep a CorrelationId to track a ch...
Basically, the idea is to have a new thread pool with a few worker threads in it every time a user log onto the application (a new user session is created). Pretty much all the web applications I've worked with in the past had fixed amount of thread pools based on functionalities, but almost always performance issues w...
I have global message queue with multiple different producers, and a cluster with N nodes of consumers. Each consumer receives a message and may decide to process it or to put it back to the queue if not interested. Each message has a relation to the project. The amount of projects is greater than amount of nodes (proj...
I'm conflicted as to what is the best way to approach this problem. I am writing a simulation in Python, which is parametrized by ~ 50 parameters. I have a JSON file where these parameters are set, so that it is simple to modify them and perform different simulations iteratively. Snippet of settings.json (not actual pa...
New to Apache Airflow and curious about how code and data are expected to be used across worker nodes in a multinode airflow setup. When considering if ETL logic should be in the dags or in separate files called by operators in the dag, from here (https://www.astronomer.io/guides/dag-best-practices/) I see: Try to tre...
I am using HATEOAS architecture in my rest application and want to send internationalized success message that will be directly consumed by the client. I know we can just add a key in the response but want to know what is the ideal way architecturally. For example, lets say i want to send a message Department created s...
I'm designing a enterprise infrastructure monitoring application which has customized needs of access control, beyond roles and authorities. The architecture include multiple nodes of REST API being load balanced, an angular client and an authorization server based on OAuth 2.0 using JWT. These Rest API nodes are gener...
Recently I was going through some of the source-codes of the best competitive programmers in the world. I found out that those people use a template while writing programs, preferably in C++. I have some difficulty understanding those programs because of the fact that they first create their own macros/types using #def...
I need to have compiled in a single file all the interfaces that extends a particular interface for doing some refactoring work (long story). I'm using Visual Studio 2019, but I didn't find any extension that would it for me. I can create a parser to parse all ts files, but I don't want to reinvent the wheel if someon...
Technologies : NodeJs, Kafka, Mocha The issue : I have a nodeJS service which given a String returns events with a many data. How can I test this using Mocha ? In a simple scenario the service returns one event with some data attached. In a more complex scenario the service publishes multiple events. Is there a way ...
I am writing a C# client SDK to a REST Api. This SDK sends JSON-serialized models to the API, and implements a first level of verification of the parameters. If the verification fails, it throws an exception. An example would be: if (requiredParameter == null) { throw new ApiException(400, "Missing required paramet...
So, somebody at work who is twice as experienced than I am, told us that we must not create ViewModel classes within Web API. (We are using Angular for UI) In his opinion ViewModel is ASP.NET MVC approach. And we must come out of it when using Web API. Here is my argument for using ViewModel in WebAPIs: Database Tables...
I am working with a custom, fairly simple DSL for specifying how various scripts will be run. The DSL takes the form of config files that are very simple and easy for humans to read. They define what scripts must be executed in what order and how. I have a program that parses such a config file, and executes the steps....
I would like to write something like <byte> ::= <bit>*8 to mean that a <byte> is a sequence of exactly 8 <bit>'s. Is there a way to do this in BNF[1][2] or a widely used extension of BNF? How?
I have the following StudentGroup class: public class StudentGroup { [Key] public int Id { get; set; } //the set of peers who will review the work of the StudentGroup [ForeignKey("PeerReviewGroupId")] public PeerReviewGroup PeerReviewGroup { get; set; } public int? PeerReviewGroupId { get; set;...
I have a code at my local machine, with which I want to call an AWS Lambda function. I have configured AWS API Gateway as doorway to Lambda function, but I am concerned about security when sending credentials as query string parameters. So could anyone suggest nest approach to pass credentials to Lambda function even i...
I have a hardware device connected to the computer and on the hardware device there is 512 bytes of memory for storing parameters. I want to read this data and decode the parameters stored in the memory. I will explain how I currently do this, and then ask if there is a better way. I read the data using this function c...
We have an issue with how the implementation of the Data Access layer (EF6 Includes more specifically), influences the behavior of our Domain layer. A theoretical example to illustrate: Application in 3 layers, DDD: Domain layer: simplistic domain model An Order has Orderlines An Order has a public property "CanBeExt...
I am working on the development of an SDK in Android with Java, In general the user doesn't need to inherit any class of the SDK, so the question is if it is a good practice put by default all classes as final in the SDK's Classes?
Long story short - I would like to make a web application, solely for self-education purposes, that should allow user to add additional functionalities via plugins - just like Jenkins - https://jenkins.io/doc/book/managing/plugins/ - which does it via extension points. But beside that, at the same time I would like eac...
We are starting our new application in which we using MS SQL DB for all our insert/update/delete/select ie. both SELECT and DML operations. But, soon we will have two different sources. SQL Server DB and Elastic Search. The idea is to perform all the DML operations on MS Sql DB but will be using Elastic Search for ALL...
In C, global variables are stored with the program code. I.e. the space to hold them is part of the object file (either in the data or bss section), instead of being allocated during execution (to either the stack or heap). What other ways are used by languages to store global variables? For example, consider a dynamic...
We have a text file with extended ascii (words like 'Systèmes' and 'Café'). It is in Google Cloud Storage. Its Content-Type is text/csv. If I download it via the browser UI (https://console.cloud.google.com/storage/browser/...) all of the characters are correct. However, If I download it from java, using the code be...
For libraries like NGRX - Actions or NGXS - Actions when creating an action you create an interface or class like so: bar-action.ts export class Foo { static type: string = 'bar-foo'; } // etc classes They are simply imported in angular: import { Foo } from './bar-actions'; All great until you want to do something ...
I'm writing logic for a patchable game, and patching involves modifying multiple files. type UpdateInfo { file string data []byte at int64 } func AtomicUpdate(ui <-chan UpdateInfo) error { for _, v := range ui { file, err := os.OpenFile(v.file, os.O_RDWR|os.O_CREATE, 0) if err != nil ...
A potential client is very interested by a VSTO product we developed. However, their IT department is concerned wether they should trust this sofware. Mainly, they are worried it could expose a security breach into their system. We are a small company, with very little reputation. Our apps are signed via en EV Code cer...
We have a Java Play Framework Application which we want to scale out into a cluster. The only issue is that there are services ran by the Akka Scheduler once per day, and we don't want these services triggered by all the instances. Here are some of the options we have thought of: Extracting the scheduler operations as...
As far as I know, the DBContext or underlying persistance technology should be only contained inside the Data layer. Also, it feels very wrong to me to have identity package inside the user interface layer. The identity should be the responsibility of a centralized business layer, which in case should be usable by oth...
Every day, there will be a set of new data that I will need to write and update to the database. This set of data can contain 8-10million records. This new set of data comes from Service A and it writes directly into a database which is used by Service B. I don’t maintain Service A but I do maintain Service B. The pro...
We are a fairly new team of 5 devs working on an existing code base to make MVP somewhere in Q2 2020. We do not deliver to production yet but we do demo to stakeholders on our progress. We try to work as agile as possible but because we are new (1 dev 8 months, 1 dev 4 months (myself), 2 devs 3 months and one dev 1 mon...
I have a library that provides access to our content management. It consist of a public ContentService and an internal ContentRepository. The ContentService is public and Dependency injected through out our solution. The ContentRepository is only used by the ContentService. My issue is that I am passing 3-4 arguments ...
From my understanding, parser generators accept as input some form of context-free grammar description. The context-sensitive features are handled during semantic rather than syntactic analysis (please correct me if this is wrong). Since shell languages inherently have a lot of context-sensitive features, is it worthwh...
More specifically, how to study competitive programming, but starting with the notes. Some background information: So I am new to programming. I noticed that competitive programming is a lot like math competitions. These are real world problems and just remembering a few for an exam is not like the industry. For exampl...
I have just started learning about model-driven engineering. But I have a hard time to grasp the different model levels, given software example. Would not the model always be represented in a UML diagram or a class? Which then makes the above level to be the same in all cases?
We are now in a process of migrating our server-per-client architecture to a multi-tenancy architecture. Everything is in place except for one design issue we are having. We are using a subdomain in order to determine what tenant it is and route it to the proper DB (it is DB-per-tenant). Let's say we have a tenant clas...
Redux uses a state reducer pattern where essentially you create a pure function that looks like: function reducer (previousState, action) { //... return newState; } This looks similar to JavaScript's Array.reduce function, so I don't think the concept of a 'reducer' is something original to Redux. However, ...
I have to call a critical API over a network (which makes it unreliable) many number of times in a go, many times a day. If the API fails to respond (timeout) or returns an error (because that server is in turn calling other unreliable third parties) i have to notify them about the error and then call the original API ...
I'm building an Electron app using React. I'm coming from the C# and WPF world and I'm wondering, where should my domain classes go? I understand the concept of components, but what about a class with no UI, just a lot of methods in it? For example, an application for managing software teams in the company. There is an...
I am building a Data Collection Web Application with Flask and MySQL Database. It is basically a creating a Bill Of Materials for the organization for a new product. Bill of Material in a form looks like this This application is giving three interfaces to three different groups ie: a) Engineers - They will be adding Pa...
I am working on a project to use fingerprint to authenticate the user. I don't want the authentication to be device specific. Hence want to upload the user fingerprint to cloud. I do understand that fingerprint can be considered to authenticate the user on device using :https://www.npmjs.com/package/react-native-biomet...
We are building a backend RESTful service for a workflow builder. The service's responsibilities will be to accept workflow definitions from a frontend and store them in a database. We are trying to decide between the following two choices for the structure of the API. Choice 1: Single API, saveWorkflowDefinition, wh...
When writing tests, I often struggle with a conceptual issue, and maybe I am missing something major here. For many classes, the test writing is straight forward and simple, often tests (and their verification) are even possible to be repeated with any amount of random input data. However, for a certain type of classes...
Currently I'm building GUI applications for Linux and they have many dependencies( We ship Raspberry Pi devices with the executable installed on each device). My idea is to create a docker image for the executable and copy the image across all the devices instead of installing all the dependencies on each device and th...
I have several jobs that run nightly. Generally they work but from time to time they fail. What's the best way for them to report failure? The way that seems obvious to me is to send email. I have several google accounts and would like to use one for this purpose. However, I cannot after several attempts, get my head a...
So I have some naive implementation for the following problem: We have a list of objects with action methods that have to be trigger at some value of interest. This value is polled (or is streamed) from a remote server and is constantly changing. Let's say we have tens of thousands of such objects in the list, and t...
What's the relationship between the two? Both are for atomic operations. Both results need to be either success, or failure with rollback to original state.
Say I have two Map instances in JavaScript (or HashMap in Java, or Dictionary in C#), A and B. I want to synchronize B to A, so that B is a copy of A. I can't copy the reference and I don't want to delete all keys and re-add; I want to keep B available and mostly accurate during processing. What's the most efficient al...
I'm using a public git repository and adjusting it to my specific needs, meaning that the changes are not worthy of being merged upstream. Repo is in github (upstream), and we maintain our own git server (origin), where the fork will be store. The original repo is quite active and has 10+ release branches plus as man...
I want to implement "FaaS least cost routing". It does not make sense to calculate the costs before every request, but calculating the cheapest provider on a daily or hourly basis would make sense. My question is specific to FaaS. No storage is involved. As far as I know up to now the FaaS providers (Google, AWS, Azure...
Maybe I'm being dense, but is it common practice to create an API which requires users to submit GET params as an object? I've encountered one which has me submitting GET requests like... http://www.example.com/?ip={keyOne: "ValueOne", keyTwo: "ValueTwo"} I find this makes using Postman with the endpoint pretty difficu...
I know that associations in class diagram can be bi-directional or directional. We refer to this as navigability. I am not sure to fully understand what it means. Please consider the following example : Does the navigability in the example meant that we read this association as "one order detail is related to one it...
I'm starting a pet project and would like some advice. I need to perform the following: Scrape JSON Data from a REST API Save the Data into my Postgresql table Paginate through the rest API and continusously bulk insert rows into my Postgresql table. I have some specific questions regarding 2 and 3. Question regardin...
Where would I begin if I wanted to develop an algorithm that maps consecutive whole numbers to a long list of unique sets of whole numbers. For example: 0 = {0, 0, 0} 1 = {0, 0, 1} 2 = {0, 0, 2} 3 = {0, 0, 3} 4 = {0, 0, 4} 5 = {0, 0, 5} 6 = {0, 0, 6} 7 = {0, 0, 7} 8 = {0, 0, 8} 9 = {0, 0, 9} ... 29436 = {19...
This question has been asked first on Stack Overflow, I've been told that this forum would be more appropriate I am wondering what's the recommended way to solve the following situation : I have items, Cars which have a color and a car model property When a customer choses a car on the carmaker website (the one I am...
I'm working on a video streaming project for drones with opencv where I want to apply multiple stacked image manipulations on a 2D input matrix. I was advised to make all manipulations calls non-blocking. In designing this I had the idea to give each of the manipulations a thread and 2 matrixes, the last completed matr...
I have a question about how can manage multiple repositories with unit of work. I thought for two solutions but I'm not sure. The first is a classic solution where the IUnitOfWork interface looks like this: public interface IUnitOfWork { IUserRepository UserRepository { get; set; } IUserSecurity UserSecurityRep...
First post here on Software Engineering, so I hope I don't goof up too much. I am writing software that integrates with an application written by a company that has a small development team. I have suggested that they add webhooks to their application so that it can be event driven. They have said that they like the id...
I am in the process of designing a simple portfolio management system for financial advisors. The central table here is an 'tb_account' table that holds the various accounts an advisor manages. I create a random unique account number and store it in the 'accountno' field in the table tb_account. The field is also the p...
I have been doing some research on the Hexagonal/Ports & Adapters architecture. For the most part, it makes a lot of sense. My initial understanding was that "Driver Ports" were to be implemented by the adapters in the implementing application. The more work I do on my application, it's becoming clear that this is not...
I recently ran across some code in a public repo that I'd thought... just plain wrong. The first thing I noticed was /** * Sets a test mode status. * * @param boolean $mode Mode to set */ public function testMode(bool $mode = true) { $this->testMode = $mode; return $this; } Then another method used the te...
I have a spring boot application, that simply does, takes a set of characters and lists out possible english words. Now, as everyone knows , its fairly easy, build a trie data-structure to load up a dictionary. Now, the problem is let's say 170,000 words in english dictionary, need to be in-memory, how do I achieve tha...
I have created a machine learning software that detects objects(duh!), processes the objects based on some computer vision parameters and then triggers some hardware that puts the object in the respective bin. The objects are placed on a conveyer belt and a camera is mounted at a point to snap pictures of objects(one o...
We have a class in our company's main library as follows: public class User { private long id; private UserType type; // Getters, setters, constructors, etc. } and have several options to implement UserType. One of which is an enum: public enum UserType { DEFAULT (10), TYPE_A (20); private in...
In my UI application (WPF/C#, using MVVM design pattern), I have implemented a global exception handler which catches all unexpected (hence uncaught) exceptions and reports the application crash to the user via a dedicated "crash report" window. Instead of bombarding the user with the entire stack trace right away, I'd...
I've just started using clean architecture, It's clean and nice, but I've found a bit confusing use case. My application should be able to register to update a token after some time, so I handled that by calling a use case that starts a ScheduledExecutorService in a statically managed object, after the time is met, the...
The context I need to design a Client-Server(-Client) network in C++ that would allow an android application to communicate to a Raspberry Pi and back I am running everything on linux environment(s) and the project is time sensitive, but a latency of <80ms is manageable. The problem I am just starting to learn C++ and ...
The context: I created a PySide2 app to remote control a pyhsical product. The device is interfaced with a driver to get and set it's overall state (state machine with nested and parallel states) and configuration values. Dependend on the overall application state the model requests the product state periodically, mean...
In our company we recently had a discussion about which part of an application is responsible for the (re)arrangement of the items of a list. The list is a visual representation of steps to be done in production. Backend provides it in the "normal" order (1., 2., 3., 4.). In the frontend at the very top should be the 4...
I am writing a deep-learning program in Python. I'd like my program do the following steps (the exact steps are irrelevant, the pattern is important): Download the images and store them on disk. Train the neural net make predictions using the trained neural net. Downloading and training takes quite a while, and when ...
I work on a GIS-based Network Inventory software. There are two versions of it available: a desktop and a web application. Currently any feature must be implemented separately for desktop and web. The only common element of both systems is the database. E.g. if I want to add an entry in the context menu for some type o...
While recently creating a module for shared functionality between our projects I stumbled upon this question. Should the module be occupied with transpilation of code to older browsers that our projects, in general, should support or should it only contain the essential functionality, assuming compatibility to be an i...
I believe I understand what REST is and what Agile is. Our company has some APIs that we maintained, usually we only needed to tweak some requests or responses to fit new requirements. Recently, we had a need to create new set of API. The design of the new API was driven by how the client would interact with the server...
I have a class containing a list, for example: class User{ .... List<String> cards ... } What's the best way to provide access to this member? List<String> getCards() or String getCard(int index) I am tempted by the second option so that I can avoid a null pointer exception like this: getCards().get(0) //if...
I have come across mutable variables kind often, yet it seems to me it's always been use to solve a problem of design(typically coping with legacy code) rather than to answer a natural, intrinsic architect design necessity. Could some architect designer explain when is it really necessary, and why was it introduce in t...
Imagine you have a chain of functions calls, in which each function is taking the previous function's output as input for the next calculation in the chain. Make an assumption that you are leading the infra scope, which means you are defining the process chain and protocol, but you have a group of users that are respon...
I am storing my Ping records in a limited queue, and I also have a cumulative sum to get the average. I'm doing it like a window. My problem is this: Does it make sense that I have 5ms Ping with 98% packet loss? If I sent 100 packets but only two were answered and had a good response time, should Ping be the ones recei...
I am pretty new with go mod and vendor... I have a project A and a project B out of the GOPATH. I import project A in project B. I own both projects and I modify them. As I use externals packages from GitHub, I want to use go mod so I wont be impacted by any breaking changes. Problems come when I want to modify project...
I am to develop an inventory tracking system (e.g. keyboards, mice, phones, etc.) I am wondering if it is possible to use 1D barcodes UPC standard for this, will I be able to track each individual item or can I only categories the assets?
I am trying to understand DDD, but the scope to which we should seperate out domains seems a bit tricky to me. Consider a few cases: 1. Utility Consider I have a utility domain, with 2 helper function. GenerateUUID ValidateRegex Should I split these two into utility/uuid and utility/regex domain as well? 2. Versioni...
We have a REST API which calls a third-party REST API to Send Emails. The Third Party API is not super reliable and randomly fails every now and then with a 500. Our Clients do not want to retry at all and instead requested us to build a retry mechanism for failed emails. We are using Spring-Retry to implement Retry a...
I'm working on adding Approval workflows around our system which manages CRUD operations for our business item. Till now, I have been using an optimistic locking strategy to handle race conditions when two users try to edit the same item. The user whose request is saved first wins, and the other user has to try again w...
Currently have situation between having not much data (mid single-digit to low double-digit TBs (not per data set mind you, but the average total amount)), but desiring tools similar to those that come bundled with hadoop packages, specifically Sqoop, Atlas, and Ranger (which can be easily installed via Ambari with Hor...
Currently I have a large ontology like this: There are different categories of variants and each can be somatic or germline. There are more common behaviours between same variants, like somatic CNVs and germline CNVs have more common behaviours due to the fact that they are both CNVs. But there also are a few behavio...
I know that the general concept behind event sourcing is that the state of the application should be able to be replayed from the event stream. Sometimes, however, we need to get information for business rules from other parts of the system. i.e. An account has a user. A user has a blacklist status which is required to...
I am trying to implement some of the principles laid out in Clean Code by Robert C. Martin. I had a class that was heavily suffering from the ordering problem. I have solved most of this by extracting the code into separate classes. I am now left with my main class looking like this: public class Planner { public Es...
This is a matter of naming, structuring and conventions. I am developing a simple python package. in a directory "PKG" I have 3 files: __init__.py: # import the main module import PKG.main # in case for: from PKG import * __all__ = [ "main" ] main.py (simplified): import PKG.exceptions def f(x): return(x+1) e...
I have a workflow process housed in a Jupyter Notebook that uses spaCy to parse text documents. The workflow process essentially reads a text file and returns all sentences containing the keywords provided by user (similar to Google search which returns hyperlinks instead) To use that workflow, a potential user then ne...
I am working on a project where a user can input different criteria which will be used to fetch tweets, lets call this action as TweetAnalysis. These tweets will then be sent to another internal system (REST API) to do some calculation and get results. Each tweet will have a unique result from REST API. For each TweetA...
I have this idea of an app and I'm a little frustrated by how much I don't know how to proceed. My app is basically an art recommendation app. You start with 3 base images and for each images you click on you're presented similar images with slight variation etc... So my goal is to make this a mobile app and call it m...
Not sure if this question belongs here, but I've always wondered how exactly sites like Leetcode & HackerRank test your code. Say you code in Java for a question like, Find all the duplicates in an array After clicking submit, the code is sent as part of a POST request to the backend and then what is the most likely ...
I tried to build a database for Driver Booking system. Here's brief details: Drivers have several vehicles and they offers the driving service with them Drivers will charge different hourly rates on the different vehicles Drivers have base charge for each booking, this is independent of the vehicle types but depends o...
Often I need to transform a type to another, such as a networking model to a data model, or a data model to a binary representation. Should these transformation functions take an Optional/nullable value and immediately return nil if it's nil, or should the function only accept non-nil values and always return a non-nil...