instruction
stringlengths
34
36.1k
We have a few tables with a large amount of data and with indexes on those tables to help in faster retrieval. We are also using Spring Data JPA JpaRepository for adding data to those tables using the .save(Iterable entities) method. Now, I know that the index is going to slow down the inserts in the DB. But my questio...
Some background I am the newest member of a small team of 3 developers. For the past two years I have been working with them on an application the two of them made roughly 5-6 years ago. This application has no documentation and no design or analytical methodology has ever been applied to the development process. The l...
I am part of a new dev team that is assigned to work on a legacy app. The app currently has no regression or automated unit, integration and system tests. Due to technical debt and convoluted architecture, automated unit tests would be difficult without refactoring the code. However refactoring code is not a something ...
At my work we have a typical microservice architecture, but one of the issues we are running into is sharing data across multiple services. We have certain data that is used by multiple services and so we have to share the data across services. Our databases are separated out by service, for reference. To give an examp...
So, I've fallen into the fad trap, and started replacing a large amount of linq queries with extension methods. For example: orders.Where(o => o.Status == ShippedStatus.Shipped).Select(o => o.ID) has become : orders.ShippedOrderIds Extension methods are static with all the cons implied, and I believe the 'most-correct...
I recently started working at a place with some much older developers (around 50+ years old). They have worked on critical applications dealing with aviation where the system could not go down. As a result the older programmer tends to code this way. He tends to put a boolean in the objects to indicate if an exception ...
I'm a little confused about commands role in event sourcing distinction between domain and external events If my understanding is right a command represents an action initiated by an actor in terms of the domain a domain event is an event can be consumed and produced by aggregate roots an external event is just like...
I'm building a mobile application using Expo & React Native. As the user interacts with the mobile app I need to store their interactions in Google BigQuery, so they can later be used to train machine learning models. Think 'user swiped left', 'user clicked image' etc. I have a few options in mind: Host the app on Goo...
Say I have a database with 100 tables. Scattered throughout the tables are some string columns for short things that could be considered usernames/tags/categories/hashtags/addresses/placenames/other short names. Also scattered throughout are integer columns ranging from super tiny numbers like 10-50 to super BigInts li...
I am new to object oriented design and learning about interfaces and design patterns. In this example, I am trying to create class for cars. My question: Is it good practice to use base class and then inherit from it. And then use interfaces for implementing different functions? If not, then what would be the best way ...
It seems pretty common knowledge that code is read far more than it is written. Does this mean that if a tool produces code that's checked in, then it's a net negative (saves the author some time in writing it, but more than makes up for it in time spent by everyone else reading it)? If not, why not? If yes, is there s...
I have came across a concept in recursion which says that when loops are compiled or interpreted then they get converted to recursive functions. If it is true how it takes place ?
Before I ask my question, I'm aware of Eric Lippert's Wizard and Warrior series. I'm trying to understand GRASP, but I'm having a hard time determining if this class violates GRASP. Suppose if I had the following Character class: class Character(ABC): def __init__(self, name, strength, attributes): ...
Our project is in its early stages and we are currently using Uncle Bob's Clean Architecture (also known as the Onion Architecture). An overview of our project is as follows: domain package Contains our business entities usecases package Contains operators that use our domain entities to perform use cases Contains ...
I'm working with firestore and have encountered several situations where a document will contain stale data which is a duplicate of the source of truth located elsewhere in the database. For instance I have a chats collection with documents that contain: users: [{ name: 'foo', companyName: 'bar' }] The source...
I've been working on a library at work which provides a simplified API for a few underlying libraries (face recognition, text to speech, etc.). My boss asked me the best way to describe this concept in English, and I couldn't find something that felt both succinct and adequately conveys what the library does. The best ...
I want to create an application that has some optional steps. But I could not decide how to do step plans. It looks like a workflow. I have a Work entity. This work includes specific business steps. Step-1 : Demand of work. ( DemanderName, DemandDate, DemandFiles ) Step-2 : ... Step-3 : ... Step-4 : Work investigatio...
I have gone through ken thompson's compiler hack paper, can't we just go through the complier's source code and check for any backdoor, what was the article's point? https://www.archive.ece.cmu.edu/~ganger/712.fall02/papers/p761-thompson.pdf Can we be sure that there are no backdoor's if we check the latest language's ...
I have situation where in the Repository class I have a dictionary: Dictionary<TableName, Dictionary<EntityColumnName, SourceColumnName> map1 = new Dictionary<TableName, Dictionary<EntityColumnName, SourceColumnName> () with methods for manipulating data (Get,Save,Add etc). Now there is a need to search by value from ...
Assuming we have different classes with methods that possess the exact same description, however execute code a bit differently for the same return type. class Foo: """This is the Foo class Docstring. It is a type of Bar source.""" def getBar(self,pos): """ This is the Bar method. It ca...
I know it is lot of code. But I am trying to understand the concept of Factory pattern with interfaces and base class. I have a base class of Car that implements an interface which will be implemented by every derived class. Then I have another interface that will be only implemented by few derived classes. OnlyImpleme...
Suppose I have a one C++ process, and I want this process to run eight threads in parallel. And suppose that: I have a computer with two (2) physical CPUs. Each CPU has four (4) cores, so that's 4x2 = (8) cores total. Each core only allows one (1) logical thread, so (8) logical threads total. I am using an x86-64-bit ...
I currently have a Web App using ASP.NET Core 2.2, Domain Driven Design, Clean Architecture, and CQRS. I'm using MongoDB as persistence. I have developed a Repository pattern to abstract the MongoDB implementation. But I've been doing some research on how to prepare the application against outages, timeouts, and discr...
At my company, we use a distributed pool of virtual machines to run our UI and API tests. These machines are all connected to an onsite server which the pool uses for publishing the test results and outputs. The problem is our storage on this server is limited, and each day we are producing 500MB - 5GB of reports (csv...
This is a basic question, but I don't have any sense of what other developers do in this scenario. The Situation I am creating an interface to allow end users to insert and update data in a table stored in an Oracle database. The interface will ask for an Excel worksheet and then generate a MERGE script with SQL to ins...
Apologies in advance if this is considered opinion based, but I wasn't sure where to ask it and was interested in learning if there were any definitive best practices. Say an application calls a service from one location, but a requirement is that a == 1. You would want to perform the a == 1 check in the service to be ...
To give a bit of context first, I have been tasked to mentor an internship on creating a UI for a certain business need: Already 4 months were spend on analyzing, creating the business use cases and some context diagrams, and BPMN diagrams, but the analysis is not complete yet. It was foreseen that the API would be...
I've seen this pattern pop up in a couple of different teams. They have a server with a REST API and a frontend web project. What commonly happens is the frontend developer finds their requests are being blocked by CORS, and they create a REST API for the frontend that just passes requests through to the main backend....
Although many people understand that even if we have the same setup for TEST and UAT environments as we have for PROD, there're still a lot of reasons why it makes sense to run smoke tests in production: Ensure stability of the core functionality Identify potential bugs and fix them right after deployment We'd like ...
I have an application which is currently used by clients. So based on the feedback from the client, normally we are fixing bugs in a live application.Parallel I am adding new modules to demo projects.My plan is to migrate the new modules into live after testing. But the issue is we have fixed many bugs in live version ...
In GitLab, an issue is usually closed once a Merge Request is approved and merged into master. However, what should happen with issues that are closed because of other reasons? There could be various reasons for this: It turns out the issue is not needed. The issue turns out to be not feasible, would break too much ...
The frames are sent in multiplexed fashion and have a stream id. The receiver re arranges frames with the same stream id but what happens if an older frame arrives first? Is there a concept of sequence number in http2.0 stream frames?
Our website needs to send transactional emails to customers each time an event happens on the site such as: User registration Email verification Password resets Order confirmations Despatch confirmations Comment notifications And so on. At the moment I am storing the email templates within an application page (e...
We have git installed on our webserver (via cpanel), but unfortunately no CI- / Deployment-Tools. Would it be good practice just initialise our repository in /public_html/ and push our local Dev-branches into the Master-Branch there instead of having an extra repository-directory on the server and 'deploy' the project...
I have the following "software reality in working code" (also no access to it): There is a class Class1 with different attributes AttributeA - sums up all "ordinary attributes" EnumType DataType AttributeValue It is realized that there are some objects John... of type Class1, so they all have these 4 attributes. T...
The cover of the book The Practice of Programming lists programming principles: Simplicity Clarity Generality Intuitively I understand generality as preferring to solve the general problem rather than the specific form in which the problem presents itself. For example a sort function should be able to sort anything t...
I know redis is a very robust caching solution and scales great, but when it comes to simpler non-enterprise websites I feel as if it's a bit too expensive (Azure Standard/C1: $100/m). I'm considering just creating a simple API that utilizes the Dotnet Core In-Memory Caching. One benefit of this would be cost, as I co...
I have a web application that has some specific differences between production and test environments. I.e. test email config, test payment config, the word Test written on the home page (useful to be sure you're in test!!) My previous developers taught me the basics of git and I can use github desktop pro to branch and...
I’ve got me a design and implementation problem extracting and formulating the results I need. What I’m trying to do is build some reporting on forecasted stock commitments in an inventory system to help drive JIT stock procurement and manufacturing. I’m really sorry, there is a fair bit to this so if you stick with m...
I have a list of functions which need to be tested against a list of inputs to measure their relative performance. I have already create a test function like below: public static String testFunction(Function<int[], int[]> function , int[] input) {} I have also generated a list of inputs to feed to each function. The c...
I'm reading the book "The Go Programming Language" and this sentence in the preface section "The Origins of Go" has me puzzled: One major stream of influence comes from languages by Niklaus Wirth, beginning with Pascal. Modula-2 inspired the package concept. Oberon eliminated the distinction between module interface f...
I believe the consensus on unit tests is that each individual test should interact with the smallest surface possible (?). I have a function I want to test, but it depends on some setup performed by other function. Should I call these other function in my test, or manually setup the state as the tested function expects...
I have a wcf service to create that will have to pilot a desktop process for the remote client. My limitations are : - the wcf service could not handle more 100 simultaneous desktop process concurrently. - the wcf service have to be protected so that a problem with one desktop process does not stop the server to ...
I am trying to make a user story for a basic Sudoku game, using the agile software development approach. I get the concept behind user stories, but I was just wondering if it was possible to get an example to further my understanding? Would saying As an avid Sudoku player, I want to have multiple levels at different ...
I'm trying to implement an Interface for a Message Queue. This interface should allow different implementations of queues to be implemented etc AWS SQS, Azure Queue Service. So lets say that I have an interface for the Message Queue: type Queue interface { AddMessageToQueue(msg QueueMessage) } I also have an interf...
I need help with a problem which I have been working for the last month. I have a group of documents, each document has a set of unique words (if the word appears more than once in the document, I count it only once). I want to find for a particular amount of documents the optimum group which contains the least amount ...
I'm designing an API, and I need to authenticate each request with a user. The simplest way to do that is to provide an API key to each user on their "My account" page, that they could regenerate at any time. Then, our users can either include it when they design their consumer apps, or the apps they use can ask the us...
Our team is starting to refine a set of stories that cover components and UI as part of an upgrade to a newer version of Angular. These components will then be used to recreate screens in an existing application. We are considering this work technical debt. Is there a recommended format for writing technical debt stori...
Imagine the following situation: I'm working on a python project, and I install the library antigravity with pip. I add the function fly() which uses the library, and I commit and push the changes. Some time after, my partner(s) run git pull. How do they know that they should install the new library? By failing to ru...
I'm always having the problem on how to properly design having static entity instances and it being attached to Entity Framework's Dbcontext. For example, we have the following: using Microsoft.EntityFrameworkCore; using System; using System.Linq; using Xunit; namespace ClassLibrary1 { public class PersonType ...
I currently have a small list (< 20) of constants that can be segmented into the following three parts: - main script (tokens, log file location) - database setup (username, passwords) - API (API key, various external IDs) I felt that it cluttered the top of the files during declaration, so I transferred them into a c...
First of all, I hope im in the right stack exchange. So I'm trying to build a facial recognition system, e.g. one that recognizes a face and compares it to a database of known faces. For the first part, there are a ton of resources available, thats not the problem. The problem I have is designing the database. How do y...
We are starting to have a few projects that have a design where a web server needs access to services/devices (think database connections and specialized hardware) that are on a local network. Instead of having users open up ports to the public internet, we are using a small program that establishes a connection from i...
I have just started a new job in which I will be overhauling and updating a web-application written in Django. I have a loose familiarity with Django (and have been reading up on the documentation for Django and external libraries like Django REST Framework). But I am hoping someone with lots of experience in quickly u...
A typical implementation of a DDD repository doesn't look very OO, for example a save() method: package com.example.domain; public class Product { /* public attributes for brevity */ public String name; public Double price; } public interface ProductRepo { void save(Product product); } Infrastructure p...
Whlist browsing on github I came across the following project: https://github.com/infection/infection and according to the project's website https://infection.github.io/guide/#What-is-Mutation-Testing . As far as I understood what a mutation testing mean is that automatically the code is slightly being changed and som...
So for DDD folks there, Aggregate Roots are supposed to contain business logics only and exposed what is needed only. In DDD Red Book by Vaugh Vernon, he used LevelDB and Hibernate as examples. LevelDB is key-value storage and Hibernate I think uses reflection. However, if I don't want to use any of those, how am I goi...
This may be a broad question but I have not been able to find an answer. In my program I am communicating to a device over serial communication. The data coming through is binary, and formatted with some header/length/checksum bytes. I can decode the data fine, the part I am stuck on is what is a good practice on distr...
I am trying to figure what could be the flow since I am using JMS for the first time. Locally, I have ApacheMQ installed on my Windows Machine. And using this simple Spring JMS example mentioned here, I was able to see how to send and receive message thing works in Spring JMS and my ApacheMQ looks like the following af...
I'm developing a single page application where the first page contains the subjects and the next one contains items of the chosen subjects. The items are stored in a JSON object fetched from the server and have only two properties - name and id. My questions is - generally speaking - should I divide my fetch from the s...
I'm currently developing an SaaS application in PHP, with Laravel, using its own DB class. Let's pretend we've got 2 classes under 2 namespaces, plus Laravel's own DB - so Illuminate\Support\Facades\DB; Developer\App\Core\Queries; Developer\App\Section; They're our 3 classes. With our custom classes, we've got File 1:...
I am designing some software for transportation companies (air, ground, water, etc). In these industries, you have rest rules where you need to get a certain amount of rest in between activities. So lets say trucker/pilot/sailor has an activity to go from A to B that takes 4 hours, then has a 30 min break than wants t...
Let's take this unit test. Unit testing guidelines state that I should only have 1 assert per test, unless I'm testing the state of an object. In this case, Muxer.Muxe is a wrapper around FFMPEG that generates the right command line and executes it. Having the function return "Success" really tells me nothing about whe...
I'm trying to develop a way to represent something that has an URI inside of it, let's say: {someVariable}{separator}{URI}{separator}{anotherVariable} where someVariable is alphanumeric. I just can't figure out what the separator should be, having in mind that it should: Unambiguously represent a separator Be small (...
I am designing a Job scheduling software. Users of the software will define the job definition in XML like format https://github.com/etingof/apacheconfig/: e.g. <job> job_name myjob <command> command_name command1 command_exec_string 'echo from command1 </command> <command> comm...
I have just started reading the book Applying UML and Patterns by Craig Larman. I find it very interesting because it challenges many of what I have been told at work. I read that requirements aren't fully collected in one go in agile and it takes many iterations to complete requirements gathering. If that is the case,...
I am learning HSMs and I can see a problem that I don’t know how to address. The problem is shown in the image bellow. Inside S1, substates S11 and S12 are continuously changing in reaction to TIMERTICK event. At the same time the superstate S1 needs also to keep track of TIMERTICK event in order to change to S2 after...
At the moment I have a frontend client calling several backend REST APIs. For example a call may be to get information about a certain vehicle. Then the client will call REST API A to get some performance data for the vehicle and REST API B to get some model or other static data. This is becoming tedious to handle in t...
I approached our architect with a solution in which all of our microservices verify the auth of the user invoking the call. Basically, what I've been doing for years, on different projects. He basically said that I'm digging my own grave and proposed an infrastructural layer, a proxy, which will authorize the requests ...
I want to create the following distributed system: Spring back-end microservices containing the domain logic, a UAA (authentication) service, a Eureka service registry/discovery, a Spring Cloud Config service, and a Zuul API gateway. I am wondering what is the proper way of serving an Angular front-end application. At...
I'm writing the back-end for a chat application. The database being used is MongoDB, which uses objects that have their own unique IDs. I've run into a problem; I have two document types, channels and users, and said types need to reference each other. The user object needs a list of channels it can participate in, a...
Suppose I have a server and a client. When I send a message to the client, would I be sending a ServerMessage, or a ClientMessage? The other way to think about it - when I receive a message, it is a ClientMessage or a ServerMessage? Or is it ClientMessage in both cases?!
I am making a program that tracks whether an employee has checked in on a software app that day. The employee can check in at any time, so long as they check in before their shift ends. If they don't check in, then a notification gets sent to their supervisor (where they might get in some trouble :) ). My question is h...
I'm working on a plugin for some drafting software. The plugin takes the form of a dynamically loaded mach-o bundle. The software vendor provides a template plugin in the form of an XCode project. The whole thing is written in C++, but XCode doesn't seem to support C++ in it's testing bundle targets. Tests could be wri...
This question is related but doesn't directly answer my question. I can imagine that understanding category theory helps someone who is designing a programming language, apparently in particular functional programming languages. But what I find hard to understand is, how would a software engineer benefit from a knowled...
I would like to write a program in C that forks then execs three different processes. Afterwards, two of the programs will be suspended and only one of the three will be outputting to stdout. Is is possible to later on suspend the process currently running on stdout, resume one of the other suspended processes and have...
Use case: We have a product which ties a set of resources to a concrete user. Now we would like to provide the customers with an API so that an automated client application can have access to a subset of a concrete user's resources. A single user's resources can be accessed by multiple client applications (potentially ...
I have a backend that does not support emoji characters in all of its fields, so I want to block them directly in the frontend application. I'm in the register section, and I want to limit the possible characters for the email field. I know that RFC 5322 specifies that many particularities can be found in those address...
So, I'm having some value objects in my domain, and when I'm using them in one of my builders it looks like this: .withSomething(Id.of(123), Specifiers.of(MySpecifier.of("233"), MySpecifier.of("23423"))); and in method I have: withSomething(Id id, Specifiers specifiers){ //id.value()... } This seems too wordy for m...
Recently I stood up a Redis server and tested the idea of storing application 'states' that only existed in our application and were never stored in our database. Don't know if we will ultimately do this but for the first time this information was available external to the application. What I did notice above all else ...
I am developing a RESTful API designed primarily (but not exclusively) for consumption by a web application. For the purposes of this question, the API is a set of GET endpoints. The main endpoint is /people/ and understands a large amount of query parameters to refine the result set. The web application's splash page ...
Suppose I have a REST end point. UI sends some parameters to this REST end point which are required for a stored procedure to run properly. Since this stored procedure is going to take a long time to run, I am planning to use JMS and put this step to JMS Queue. Now, I am not very clear about what to put in the JMS Q...
I am currently attempting to create a gravitational n-body simulation using a modified Barnes-Hut algorithm, to be more amicable to GPU computation. This is primarily as a learning project. My goal is to simulate a number of stars comparable to that in real galaxies, meaning on the order of hundreds of billions to tens...
I'm all on board with functional programming in Javascript - particularly within the context of using React and Redux. Something that I've been running into again and again, is how easy it is to accidentally mutate objects and create odd bugs. That is, where the const keyword prevents the variable from being reassign...
I am a backend developer and was having this argument yesterday with a frontend dev in my team about whether or not should I let him fetch the displayable text message about the result of an operation from the backend. My argument was that since it is a presentation layer decision, it should remain with the UI. They sh...
I am looking for an approach / algorithm for using OCR (like Tesseract) to extract only bold text from an image. The Python code I wrote can already identify small letters and numbers, but it cannot distinguish between bold and non-bold text. Does someone have an idea, for example, for some preprocessing or postprocess...
Consider a token issuer/validator. Every token is PKI signed. Is it more secure to use a new key-pair (performance could be ignored for now) per request or is it no difference to have only one key-pair for all? It's a theoretical question, an implementation could be for example to generate a key-pair with expiration u...
I'm just learning about clean architecture and I'm trying to design a proof of concept for an application I want to build soon. In the Clean Architecture the Presentation layer and the Domain Model layer are separated by the Application layer. I understand how this make sense for stateless applications, like a Web base...
What I'm looking for is a pattern for the client triggering a server process, then the server process signalling the client when its finished. preferably with examples available in .NET or dotnetcore My application is accessed through a REST api. I have a full-featured windows client (WPF) and a smaller web client. So...
Lets say there exist some service at some organization that exposes information on a company's assets, from employees, company-issued devices (laptops and issues) to the the large xerox printers on each floor and the large servers in the many different server rooms. Each of these objects (laptops, enterprise printers, ...
I want to to follow a clean architecture rules (with domain and architecture layers). I have a problem with properties that an entity should or should not have. Let's say that I have a User domain. It has all the business related properties (like first name, last name, email, mobile phone number, etc.). But there are ...
I have a Controller in ASP Core MVC. I'm trying to trim down the dependency injected services in the constructor so I can start building unit tests more easily. However, I have some services being injected that are only used in one or two controller actions. For example, I inject ILocationService because in a couple of...
A few months back, I was working on designing a client API (FooManager) for adding/removing/fetching a list of objects (Bar). The requirements were simple- 1. Fetch operation is CPU-intensive and should be asynchronous. 2. API should be clear about when what data is available. The options I thought of were- Option #1 (...
One of the architectural challenges we are facing on a project is ensuring data consistency over our microservice domains. We have two rules that we are trying hard to enforce: 1. Services cannot directly communicate with one another (primarily to reduce latency and prevent deadlocks) and 2. Each service only has dire...
I currently capture well structured forecast data in a SQL Server. An example of this data is below: What this tells me is that each day, I receive a forecast for the next three days. Note that in the real world, I may receive a forecast each hour (DateOfForecast) for the next 48 hours ('DateInQuestion') at 15 minute...
I'm creating a survey app and I don't know how to design database. I need surveys with multiple questions and multiple types of questions. There are 3 ways that I could think of: a) Create a database table for surveys and every type of question and connect them with Survey_id column. b) Create a database table for que...
As far as I have seen then async/await, callbacks and promises are and can only be used to achieve asynchronous programming. Correct? So my questions are: 1) Is it correct that the former three is used for asynchronous programming only? 2) If yes, then which of them is the best and why? 3) If no, then how they differ? ...
I've been doing some research on multi-tenant systems and micro-services and I'm a bit confused by this. If each micro-service has it's own database, and implements the support of multi-tenancy in it's api - what service is responsible for telling the micro-service what account Ids map to which customers? Is there a si...
Say you have a bunch of microservices each accessing dedicated databases. Due to business logic reasons, data from some DBs need to be replicated to other DBs (e.g. to serve as local cache). One way to handle replication is to stream changes done to DB 1 (e.g. using my Debezium) into a queue (e.g. Kafka). Queue consume...
Often in my own personal Python libraries, I do something like this: class MyClass: # ... def plot(self): import someGraphicsLibrary as graphicslib graphicslib.plot(self.data) The reason is that initialising someGraphicsLibrary takes some time, up to a few seconds for one of the libraries I u...