instruction
stringlengths
34
36.1k
I have a marketplace application and I stored data in a PostgreSQL. I have performance problem for product search, I know I can improve search performance if I use Elasticsearch instead of PostgreSQL but I'm confused for is Elasticsearch strong as PostgreSQL (RDBMS) in create, update or delete operations. which makes s...
I have to send a POST request with some data to a RESTful API. Right now I have a C program that creates a socket, connects with the host and successfully sends the POST request. After some C magic, the request is formed as follows: POST http://remotemanager.digi.com/ws/sci HTTP/1.1 Host: remotemanager.digi.com Content...
Scenario: In Case I have MS "MS-1" Orchestration detect high volume Orchestration create additional node with cloned MS "MS-2" "MS-2" get request and update its DB Question : How MS "MS-1" will be updated with the new record "MS-2" insert.
What's the best practice for maintaining app configuration for multiple test environments, (and production)? At the moment I am keeping all the config in the code repo (a bitbucket server). Configs are text files in /config folders with subdirectories for each test environments (eg. config/SIT, config/UAT, config/PROD)...
I was wondering how does a Company make sure that a Commercial License was purchased for a Framework they are providing? For Example Qt is a Framework for C++ and it can be downloaded and used freely. If someone is developing software in a Commercial way and he uses a free License how it is possible that he gets fined...
We have a several GIT repos in Azure DevOps with .NET Core web applications that are related to each other with the use of submodule (we used autocreation of NuGet Packages in a private NuGet store, but this was hard to debug and maintain). And we also have a master branch with CI/CD pipeline to a test environment and ...
There are different kinds of ACLs I've generally implemented: Does a user have access to a resourcetype(API)? Does a user have access to a resource(Object)? Does a resource have access to another resource? Is a resourcetype supported for a resource? Restrict outcome of one metaresoucetype(Seach) based on restrictions ...
I'm just starting to put software design principles and agile into practice. I'm taking baby steps and so far I've started implementing the following for my software projects... A github project board with github issues acting as my User Stories. I'm under the understanding that a huge SRS isn't necessary, but I'd li...
I have a AWS Lambda function that a user makes a GET request to and it returns presigned URL. The user then uploads an image by making a PUT request to that URL. Since AWS S3 PUT requests limits object uploads to only one per URL, How would I send multiple images? Am I supposed to use a loop on the current number of i...
I am thinking of splitting a service serving multiple endpoints into microservices that can serve a set of endpoints but the problem is that the two services have certain logic in common. can the two services use libraries to address this? is it even a good idea to split it up? to give a hypothetical analogy, lets say ...
I am working with Perforce for 10 years. Our repository has around 500.000 submits and our submits are either C/C++ source code or (binary) dependencies. The lack of editor support for Perforce was always a downer. So recently I finally started evaluating Git and I enjoy the concept. I already see it's not the shiny wo...
There is a java code base based on the Spring Boot framework. As an activity I want to navigate the code path of every API method to check for the checked exceptions that are thrown at different points in the code path. Now I am aware that the exceptions thrown in the code path would have to be either caught & handled...
I sometimes end up with services encapsulating the responsibility of doing some sort of business process for which there are several possible outputs. Typically one of those output is success and the others represent the possible failures of the process itself. To fix the idea consider the following interfaces and cla...
I am working on converting a milestone project into microservices. All these services are in seperate docker containers. I am using event-driven pattern where I have used RabbitMQ as the message broker with celery being the async task queue. Celery is storing task information in Redis, which is again in a separate cont...
The application I'm developing has: controllers (they are responsible for processing RESTful API calls), services (their methods are being called by controllers, they are responsible for operations with various objects), repositories (their method are being by controllers when they are manipulating various objects) an...
I'm not quite sure how to best name this, or even precisely what it is that I'm asking here because it's kinda vague and intuitive, but... I hope my explanation will make sense. Over my years of programming carreer I've had the honor of working with many different frameworks. Some were homebrew, others were in public d...
I posted this question originally in Code Review, but then thought that I could possibly get more feedback about the design here. I just finished writing a simple Snake clone in C++ with the goal of having an actual design this time and to adhere to the SOLID principles of OOP. So I made a class diagram of the game and...
My manager asked me how much it costs (in money, currency, $) to make a REST API request from our client application to one of our services. We do not use cloud, we have on-prem servers. The payload size averages around 5kb, and the client app makes around 750 million requests a week. I don't even know where to start...
I want to create a system of user reviews and replies to the reviews in a website. There can be replies to replies. I'm using mongodb database which I think is an important detail. The review document looks roughly like this: { review: { reviewid: String, userid: String, reviewRating: Int, reviewConte...
Having an application that defines a plugin API, I was wondering how (if possible at all) to achieve both stability and performance (see below for what that means) at the same time. A plugin in my application is just a processing task, which takes a data structure whose format is defined in the plugin API and transform...
We have a fairly large database with some fairly large tables (100s of millions of rows). Some of those tables are reported on. We have indexes in place to make this as fast as possible, but still we hit limits on what we can achieve. As such we limit any reporting to 1 months worth of data per user. I am trying to f...
I've heard about vector clocks and how to test if a message was sent before another message. E.g. Message A was sent before message B if every element of the vector of message A is smaller or equal then the belonging element of the vector of message B. Also, there needs to be at least one element in the vector of messa...
If consumers of my API have their software on AWS, their ip address is subject to change if they are scaling their services horizontally (adding more machines). This means that I can't whitelist a single ip address to ensure only the trusted consumer is able to access my API as it will be constantly changing if I under...
I wrote a lot of software in C# and Python. I tried to make the overall architecture testable by using the "Clean Architecture" and Dependency Injection. This works well for C# (and python). Now I move to a new company where I will program C (it will be a new codebase). Some years ago I already wrote much C, but withou...
I am trying to create different versions of a software manual from a single source which is in MS Word format. Is it possible to do this algorithmically or must it be done manually for every version? Specifically, our software has three different types of licenses and each one corresponds to a specific subset of the bu...
I know 100% that there already is a solution out there for what I am asking but with all the research I have done, I can't seem to find it. Problem: Currently, a CS student trying to do independent studies to stay ahead. Recently, I have been wondering how different languages/frameworks implement Event Handling and I h...
Backstory: I am unable to use RDS, as I need to install cartridges in my PostgreSQL instances. I have been trying to pin down an architecture for PostgreSQL running on EC2 instances for a few days. Most information I could find online use separate software tools like HAProxy or PGPool, or more fully fledged DB clusteri...
I am creating a booking system that will allow users to make a reservations for whole days. When a user wants to initially make a reservation, they select the day(s) and then will have 10 minutes to fill out the rest of their information. How I achieved this was having a booked field and a lockedUntil field so that oth...
As an interview assignment for software developer, I have received the task. I have a list of children, and the task is: sort children ascending by their birth_date timestamp, breaking ties by ID The structure of child is: "child": { "id": "14" "name": "John" "birth_date": "1990-12-20T11:50:48Z" } I can not get ...
I have seen numerous posts on this subject but none really answered my questions. I have some user input that is inserted into my DB and displayed back to the user later. Before inserting it into the DB I validate the input. When I need to display it back to the user I have been using two different methods. The first i...
I have been writing tests for a lot of long if/else trees recently, and I'm finding it a little discouraging. I want to speak in concrete terms, so consider the following example (I'll write in Ruby syntax but the example is quite general): A user can either be an admin? or not (boolean method). A file can either be p...
In PHP, you can have a collection as an array as a class property. This collection can have a function add that takes multiple (type-hinted) parameters, as such: add( Markup $markup, Style $style = Null), the keyword here is Null, the system tells you that "hey, you don't have to add this, but you can do it, but it has...
I get the idea of the factory pattern, but I feel that it is really not necessary to use this pattern. For example, below is some code I saw (C#) that use factory method: public interface IAnimal { void Speak(); } public class Dog : IAnimal { public void Speak() { Console.WriteLine("Dog says: Bow-Wow.")...
I am developing a Spring application which has a few different modules. There will be a bunch of users added in the database. I want to add a feature, which will allow me to track users' availability, which will be set by themselves. It will be a simple toggle between available and unavailable. Each user must have a c...
Suppose you have a client-server architecture structured with a Client class that asynchronously implements the Send() and Receive() functions. You also have a base Message class and several other classes inherited from that class, based on the type of communication. This is the scenario: When a message is received, ...
An example web application X allows its clients to upload various resources, e.g. images. These uploaded resources can also be removed by the user at a later time. My question is this: what are the general practices regarding resource retention/removal? When, if ever, does it make sense to remove the actual files from ...
I'm developing an application where graphs need to be populated from realtime data. The Real-Time data comes from a Kafka Queue. How should I send this real-time data to the front-end which is in Angular8? So far I have thought of two approaches: Use a push-based queue mechanism from the server over the Kafka queue, ...
There's AntD library with various UX components. Right now I required to wrap all components which I'm using in another layer, to make an abstraction. For example, if I'm using AntForm component I required to wrap it as follows: import React from 'react'; import AntForm from 'antd/es/form'; import { FormProps } from '...
As a bit of a background, we create a website where a "third party" can organize a sport event, letting us handle enrollment and other checks. Well on our website ever since we implemented a cookie "wall" we have been getting more and more requests and complains. What I discover is that most people put "marketing" cook...
I am trying to understand better the decorator pattern. I have read an article with an example implementation in java and of course, GoF book. Do I always need an abstract parent for the decorator? For instance, in the example I have an abstract ChistmasTree and its implementation, and an abstract TreeDecorator inh...
I am designing my first ever database architecture, no real framework to build up on. So I am working on my own! Terrifying. A huge question I have is for having two separate tables, one being products, and one being components, and joining them to create a specific part list for a certain build. I'm still messing aro...
My goal was to be able to create an object which is composed by other objects without having to know beforehand what these objects were, then do checks to see if they actually exist, then add them to my collection and so on -- avoid all that fuss. My use-case is that I have a Tooltip which I output to the markup. Now,...
I'm having trouble finding an answer for this when I search variants of my question. A use case I'm thinking of is a client makes a GET request to API server A for some data, but in order to provide that data it has to make a request to API server B. For whatever reason the endpoint at B is a POST endpoint (let's say e...
The problem was already discussed here. But there was not consensus on this topic. I have some thoughts on how insert operation can be implemented for some popular file systems. If FS has extent-based structure (eg ext4, ntfs, probably btrfs) we can utilize this feature to make modification of middle file's parts indep...
I built an audio processing web app using Rails. The user uploads a song to the website. The song is then decomposed into individual elements and then modified and recombined. I am using a an open source command line tool that is being called from the rails controller. My Problem: It takes around 2 to 3 minutes to do...
I am working on converting an existing python based monolith solution to a microservice. The current flow is pretty straight forward: Accept XLSX as input -> Run some complex algorithms based on input and a default file(XLSX)-> generate XMLs The same application cater to multiple projects. The default files are project...
I'm working in a new project and I'm trying to use the Clean Architecture approach with Repository pattern. I'm using .net core 3, C#, Automapper, MediatR and Dapper. I have these layers: Domain (in the center, the core of all): here I have the business Entities, Aggregations and Value Objects with their validations ru...
I have a web application that allows user view our data that front-end in JavaScript fetches the data via a Restful request to back-end, then render it in the application. The size of each data can range from few KB to 500MB where most of them are around 100MB. According to the requirement, this data is for viewing onl...
I'm not an architect, but am trying to put together a diagram which represents the architecture of the application which I am maintaining. I have one question (but welcome any comments about the diagram itself, as I have not training in this discipline). I've essentially called the layer, where all my Application Servi...
I am in the process of implementing an API for the OPTIONS request for a pre-flight check on CORS calls. The Allowed-Origins host between local, test and prod will all be different so I moved this to a dotenv file. Now though when I create my unit test to validate this there is an issue Lets say that local has a value...
I'm now working with an API project, where I'm developing new API endpoints and the final result at the end of the life cycle is as follows: a client should receive updated data out of what it sent to API after UI actions in website. So there is API and UI, the client sends data to API then as a response gets custom UR...
I am relatively new to programming but have noticed a lot of people when creating strings using variables do something like the below to put a variable into a string. I am curious at the difference/reason why this seems to be preferred by the senior developers I know and to also get opinions on why to use one over the ...
Looking for the correct architecture, that should take into consideration - future edge-cases, bugs and pitfalls, performance, cloud pricing, ease of building and maintaining and security. I have a serverless app, hosted at AWS. It uses Lambdas and several DynamoDB tables for most of the BE logic (managed with aws-am...
In a microservices architecture where each component does one thing, how do you handle GUI logic? How do you avoid building a front end web application that has a lot of smarts built into it where it knows some of the internal workings of each microservice it calls? Let's say we have a website for employees in Acme t...
I'm a beginner studying interfaces in Java through some quizzes and I came through this question: What are Java Interface used for? I can opt among one of the following three choices: A. They're used to describe the API of various classes. B. They're used to avoid having to specify the contract for methods. C. They'...
I'm trying to deepen my understanding on this, the only thing I know for sure is that Iterator is an interface in Java. I've been reading CS literature, for example here and here and looking for similar questions here. All I've come up is just a bit confusing to me: I read, for example, that "abstract datatypes simply ...
I've heard of some techniques to optimize code and make it faster: On one side are clearly relevant optimization: use of better algorithms, benchmarking, etc. On the other side are techniques with a more doubtful relevance. I don’t know if they are a myth or a reality or just deprecated usage. My question is about t...
Just to clarify: This is not a rant. I'm genuinely curious and it's a genuine question our of straight curiosity. I want to become a better developer and even little details like this count. So, don't get me wrong, this is not a technical question about what a Dictionary<string, string> does. It's a question about when...
I have multiple APIs doing the same thing but the code is copied for each API. The names of fields and formats of certain fields like dates are different between the various APIs, but everything is ultimately the same. I would like to remove duplication of logic and change these APIs to call the service layer. I have s...
I built an async multi-client TCP server for RPC usage. It's working well but I've found it difficult to unit test certain functionality: Connect 2x clients, is client count 2 Connect 1x client, disconnect client, is client count zero I want to test that the server is robust with handling disconnects and multiple c...
I am trying to draw up a sequence diagram to show how my web client will interact with my backend over a websocket connection. I am using a websocket middleware to manage the stream connections. What is the best practice of sequence diagram in this case? Should I include the stream creation in it? Or it is simply showi...
I have an object: const riders = { Dave: { gender: 'male', age: 13, }, Nina: { gender: 'female', age: 16, }, Mike: { gender: 'male', age: 12, } }; Should I make the object name rider(s) plural or singular? I'm asking this, because I know arrays ar...
Sorry about the vague question, please do suggest different formulations. Anyway here is the kernel of the question: How many classes representing an entity/resource or whatever you want to call it, should you have? Let's take it on the example of User object. Often I see you have UserEntity used on the repository leve...
Recently I have asked this question: How do you rewrite the code which using generics and functionals in Java 8 and mixing oop and functional programming by using only object-oriented? on stackoverflow and I couldn't get an answer but there are some comments and further one saying that maybe this is an Inner Platform E...
According to the standards like ISO 29119 & ASPICE, the left side of the V-Model contains Requirements, Architecture Design and Detailed Design. On the test side, there are Unit/Component Test, Integration Test, Qualification Test. And the ISO 29119 mentions tests shall be performed against WHAT is expected of the test...
It seems 5 years ago there was a proposal for a HTTP SEARCH request, but it does not appear to have been adopted and it not widely supported. Are there any factual documents or citations which shed light on the reasoning behind why SEARCH has not been adopted by working groups or standards organizations? There is also...
I have some entities and some value objects that need to record the moment they were made. Now I read that a value object is a collection of properties with its own set of rules, and two value objects with the same properties are indistinguishable. Now, I'm probably going to use the standard C# DateTime data type for t...
I'm building a REST api and want to make sure to follow the best practices. I need to expose a method which will return a 'Document' entity by its 'Lot' number. It is possible that for a specific 'Lot', there's no 'Document' entity found. Also, property 'LotId' is not the key for 'Document' entity, it has his own key ...
According to my experience, Wikipedia and prior answers, a scripting language is vague category of languages which are high-level (no manual memory management) and interpreted. Popular examples are Python, Ruby, Perl and Tcl. Some scripting languages can be "embedded". For example: Lua is frequently embedded in video ...
Background: I'm writing a clinical trials simulator. The user defines future trial options, eg a trial with 100 placebo patients, 200 treatment patients, "optimistic" outcome scenario, etc. There can be 1-20,000 of such options. For each option 10,000 - 100,000 trial results are simulated. The simulated data are later...
I have a general question about design pattern for an enterprise application. I read a lot about it but its actually hard to find an answer because most you find it rater about how to design a data warehouse (DW) or about how to design pipeline, ETL and so on. But I'm stucking on a more top-layer question. Setup I have...
Java 7+ allows to use underscores in numeric literals,which do not affect the value of the literal, yet are useful for grouping. Examples from the Java 7 documentation, entitled "Underscores in Numeric Literals": long creditCardNumber = 1234_5678_9012_3456L; long socialSecurityNumber = 999_99_9999L; float pi = 3.14_15...
I am making a game to help childern learn Urdu (Urdu Boli = Urdu Language) This is the high level context diagram of the game.Considering an RPG can any additions be made to the diagram?
Say I have a C++ function /** * @param path If empty, the system default is used */ void foo(const std::string& path); And in my implementation I have a default handling for empty paths void foo(const std::string& path) { if (path.empty()) { // Use some default } else { // Use the given path ...
Consider this snippet: class Foo { int m_fileDescriptor; public: Bar transformIntoBar() { Bar bar(m_fileDescriptor); m_fileDescriptor = -1; return bar; } }; As you can see, once Foo "transforms" into Bar, its m_fileDescriptor becomes -1, which renders the entire object invalid. ...
I am working with/writing a good amount of code in python using pandas dataframes. One thing I'm really struggling with is how to enforce a "schema" of sorts or make it apparent what data fields are inside the dataframe. For example say I have a dataframe df with the following columns customer_id | order_id | order_amo...
I have run into a situation in React where I want to run a function F in a useEffect hook whenever a value V1 from the store changes. F uses another value from the store V2. I only want to run F when V1 changes, but to have access to the latest value of V2. This means I wouldn't want to include V2 in the list of depend...
I've noticed on web and mobile apps, when scrolling down to the bottom of a list with thousands of entries it reaches the bottom instantly but appears to be scrolling through every entry. How is this visual effect achieved? What is the common way to implement this simulation of fast-scroll?
I'm developing a SaaS application where I'm required to keep track and publish every change in a changelog. I've started to follow a Semantic Versioning approach and also using Continuous Delivery. Because I use nvie's branching model, let's say: I have version 1.0 in master. develop and master are the same. from deve...
I have a particular problem addressing the PostgreSQL advisory locking functions using the bigint variants. Basically I want to create a 64 bit bigint value from a text type obtained with the PostgreSQL md5() function from an arbitrary text_input_context input. The idea is to emulate / simulate a table row lock behav...
I am trying to identify the pros and cons of two approaches to create an object to return from my generic API. I am thinking the first approach I am sketching out has the advantage of being easier to understand by offshore developers, while the second approach lends itself better to concurrency or more complicated logi...
I am working on converting an existing python based monolith solution to a microservice. The current flow is pretty straight forward: Accept XLSX as input -> Run some complex algorithms based on input -> generate XMLs I have created two services using Flask Restplus: storage - this deals with store/download/delete of ...
I have created a real-time GPS tracking web-based system using Java Servlets as a backend solution whereas the front end is using javascript with ajax requests and WebSockets. (Both the front and backend are operating together as a Web application) Basically, the system is a web interface that shows at real-time vehicl...
I'm working on a project that we will deploy to Google Cloud Platform. The services we want to use include cloud run, SQL, and cloud storage. We will use several deployments for different phases of development; namely development, staging, and production. I'm worried about security mostly regarding who can access what....
I'm developing a client library. I'd like to provide both Sync and Async interfaces to endpoints on a server. They would be rather easy to implement as completely separate entities, but I would like to follow DRY principles and other best practices. How could one implement such clients, and are there any established pa...
In Scheme, the general form of a procedure definition is: (define (<name> <parameters>) <body>) where <body> accepts a sequence of expressions, allowing this kind of procedure definitions: > (define (f) 1 2 3) > (f) 3 Likewise, the general form of a conditional expression is: (cond (<predicate> <consequent>) (<pred...
I am making a Java and Spring webapp that scrapes data from a web and then publishes it through an API. Some of the raw scrapped data is in the form of Set<SomeObject> which I then convert to a Set<ConvertedObject>. The thing is, there is a field that has a repeating value in a lot of SomeObject and I want to avoid con...
In my program I've included the header for an external library (GLFW) in my Main class. Everything I need to use that library for can be handled in my main class, with the exception of two sneaky little methods that I need in a separate class. #include <GLFW/glfw3.h> #include "graphics/Display.hpp" int main() { g...
Introduction I intend to create a .NET WinForms application (this will be a toy application) which connects to a SQL Server database backend. I have designed and implemented an object-oriented model in C# with classes corresponding to DB tables, as part of the Model. After doing some research, I have decided to impleme...
I'm writing a "generic" achievement system for my MMORPG project, it needs to be friendly & efficient for my game designers (without having to write code to add new achievements). If anyone got some suggestions about good alternatives, I'll be glad to give it a check. (Lua, C# scripting...), many things I've not yet do...
Currently I am cleaning up hard to maintain and test if else clutter which is based on conditions which have to be checked in isolations: What is the basic semantic of the conditions? Big Entity Objects have to be checked based on two entity keys namely Trans and Right for state change as in the example Below: if (o...
I'm trying to convert this table into an ORM schema: The solution given by the book is this one: It connects all the paramether to the Member one. This is my solution, which I think it's less complicated, but I don't know if it is equivalent: What do you think about my solution? Is it right?
I am writing an implementation of a binary search tree and in doing this I need a method that splits an array in two. I am unsure where it is appropriate to place this method. What I mean by "where to place" is if I am going to monkey patch the array class, create a class method belonging to Tree, create a global metho...
I have a general question about loading data into a data warehouse (DW). This is basically a followup to an older question of mine. I have a general understanding problem about fill the [Date] dimension. Setup I have a IoT base business model basically like this: Project Location Customer [...] DataSource Device -...
I am creating this project based on event sourcing and cqrs. My write and read model are on different databases (and machines) and are connected through an event bus (in particular I am using MassTransit with rabbitmq for the transport) When an event is generated it is stored in my write model and published on the queu...
Where I work we occasionally come across really challenging defects, which require a great deal of technical expertise, skill and patience to resolve. Getting our most talented engineers to work on these issues (especially on legacy code) can be quite challenging. My question to the community is this: Have you successf...
I'm trying to understand how separation of duties works between various job functions as a security measure. For starters, there are computer (hardware) operations, applications programs, and systems programs. From what I understand, computer operators are supposed to be confined to hardware and hard data. They are not...
I need some help to understand if the code below could be refactored to something less straightforward, less repetitive and more towards any appropriate pattern. What I feel uncomfortable with in the code is the flow of repetitive tasks with the same pattern like: // Get the result from some operation (API call / or a...
To give an arbitrary example, let's say that I'm storing two objects, Item and Box, in the same database. These objects have a one-to-one relationship. Item has the following properties: ID (string) BoxID (string) Price (int) Box has the following properties: ID (string) ItemID (string) ItemLastUpdated (timestamp) ...
I have kind of a unique usecase: Phones that are used to connect to the app might be shared Connections are very unstable (sometimes no connection for half a day) Data should be accessible through the interface only by an authenticated user The data should be accessible after the first login for each user Users are no...