instruction
stringlengths
34
36.1k
Say a branch is created with many merges/commits, then you figure out 1 merge was bad. Would it be better to undo it with rebase -i or with git revert or by manually undoing some changes and adding them in a new commit? It seems like both revert and manually undoing it with new commits both add an unnecessary extra c...
Background: I was working on a web-socket application integrated into a more conventional http request based website that uses REST APIs. Task: I need to retrieve user history from the database for that application. It is a given that the application is open when we need to retrieve this history. Further, triggering u...
I've run into some strange behavior on an application I'm developing in C using the windows API. Im trying to implement a closed connection server-client interface. However, for whatever reason connect() is failing consistently after between 1-50 successful iterations of the below pseudocode: (WSA initialization is om...
Suppose I have a method which is something like void getCalled(Predicate<Integer> predicate, List<Integer> lst){ lst.stream().filter(predicate).forEach(...); } The thing is, for this predicate I will have exactly two choices, which are negations of each other. So the predicates are: public class Helper { public ...
The service that is built works on requests reply method using Kafka consumers. This service communicates with external systems . Whenever an external system requests a message(via KAfka) They had to send the client_id and an idempotent key. 2.The service would be saving this unique combination of client_id and idem...
To some extent, this is a wide question, because I do not know in which direction I should move. I am using Polymaps to show markers on a map. The markers are static but the visualization depends on the values of the input data. For the map I read the data like this: var b = read_function("data.json", function(a) {...
This is part of a bigger problem, which is to find out if point XYZ exists in any of n (XYZ -> XYZ) "boxes". I'm currently splitting up the problem into a smaller one, by focusing on one dimension first and "filtering" till either a range is found, or it's not; How can I find out if my number X is in any of n ranges wi...
I have some years of oop programming experience,I though I know what abstraction is (using abstract class and interface), but I am confused with the definition that appear in a book which says: "The process of filtering the available information and arriving at a subset that is essential for your application is called ...
I'm trying to understand if there is a manager/broker/coordinator class in frameworks and I hope so, but what possible ways are in a framework to make it run the pluggable extensions and what the term is for the name of that responsible part. In the Build dynamically extensible frameworks article there are some keywor...
In the domain of system-modeling (e, systemVerilog, matlab, phyton), lists are obsoleting arrays, stacks and queues(*) altogether. Other domains that use python, perl and ruby have that same mindset, as well. I am a system-modeler and a List aficionado that is new to c# and java (for hi-school teaching). c# seem so gre...
The background of this question is stemming from an article about someone who operates a website that is powered by a solar panel and the carbon footprint that we produce in the software space. Data centers use around 2% of the world's energy. It's made me think a bit further about what I can do as an engineer to be a...
This is likely in the wrong section but I'm curious if there is a good way to select unique and distinct colors for plotting data on charts? My current method is to hard code a set plot limit with color codes predefined. Im sure there is a random generator but the colors must be noticeably different for legibility. Are...
A long time ago - and long before I joined the project - my project was migrated from clearcase to git. This migration led to the following file layout: . ├── bar │ ├── bar.c │ └── bar.h ├── foo │ ├── foo.c │ └── foo.h └── patches ├── bar │ └── bar.c └── foo └── foo.h On the day of the cl...
let's say I have 3 customers A, B and C. I have application (whatever what this application is) I have front-end (let's say in angular2) and back-end (in Spring). On the beggining I have one common version of front-end and back-end, but after some time customer A wants something unique on front (what have to be handle...
In my project, we have a couple different back-end APIs/endpoints that are called by the same front-end page at different times. All of these endpoints are sort of related to the overall "theme" or "purpose" of the page, but they are called at different times, for different reasons, and return different data. The data ...
Background In Uncle Bob's Clean Architecture, use case interactors are responsible for the orchestration of business objects to accomplish some user goal. As an easy example, an e-commerce application might have a use case to purchase items in a shopping cart: the interactor receives a request (DTO) to make a purchase,...
I have a code that is something like this in a class string method x (){ foreach(a in alist){ //do something } return string; } integer method y (){ foreach(a in alist){ //do something } return integer; } double method z (){ foreach(a in alist){ //do something } return double; } I sens...
I've inherited a project that has a codebase in src/, but it also has precompiled binaries of dependency software in bin/. I would like to move away from having precompiled software as part of our repository, since (1) it doesn't work for all users and (2) they won't be updated when the source code of their own repo ch...
Just a little explanation: "I'm used to be a solo front-end developer in my company and using default folder-structure and way of coding which vue-cli provided, it is good for a solo developer and small applications, but the project is going to scale up and be an enterprise level app, which takes me more times to deve...
I have to build a dynamic rules engine in say, Java, where a user can define a certain list of filters and trigger a certain event based on them. The rules will be a long chain of conditions, such as: if condition1 AND (condition2 OR condition3) AND condition4 then trigger(event) where conditionN is any opera...
I just started our bachelor thesis, and want to ask you how to make a proper documentation. There are two pieces of software in our project's scope: a microcontroller software (node), and a server software (control_room). We wish to place all project documents in the software repository. This way all information can b...
Let's say there is a member SomeMethod in an interface ISomeInterface as follows: public interface ISomeInterface { int SomeMethod(string a); } For the purposes of my program, all consumers of ISomeInterface act upon the assumption that the returned int is greater than 5. Three ways come to mind to solve this - 1)...
I'm in the starting phases of designing an API. I'd like it to be Restful and comply with what's commonly considered best practices. One of my resources need to accept several query string parameters. Here's an example: { "pick_up": { "datetime": "20200301T1400", "location": { "lat": 40.68231, "ln...
Say an API returns the following pieces of data: daily_price number_of_days total_price Assume that the API will always have the number_of_days and at least daily_price or total_price. In cases when the API only has the daily_price or total_price, should the API compute the missing value (e.g. daily_price * number_of...
I have an existing production Oracle Database. However, there are performance issues for certain kind of operations, because of the volume of the data, or the complexity of queries. That's why I regularly export/dump each Oracle table to a CSV. Then such CSVs are converted to Parquet files in order to allow very high ...
This is an overly simplistic example of a domain model for a time keeping domain. I only started on it today as a way to practice the techniques I'm learning while reading Implementing Domain-Driven-Design by Vaughn Vernon. I am using the Axon framework to model my Aggregate (posted below). One big question I had in m...
I've come across a table that has about 200 columns. About 150 of these can be grouped into 5-10 tables that make real world "sense", and seeing as most of these entries are never used I figured it would save a lot of null pointers and reduce the size of the database drastically if I did this. e.g. lets say the current...
Would it be fair to say that almost all unit test frameworks use assertions, or a single assertion, to determine whether or not a test has passed or failed? In particular, are there any frameworks which instead compare textual output from a test against a known-good 'golden' version to determine whether the test has pa...
I wanted to learn more about DNS, and I happened to have a copy of Computer Networking: A Top-Down Approach 4th Edition lying around. Section 2.5.1 (page 132) suggests using DNS as a load balancer: DNS is also used to perform load distribution among replicated servers, such as replicated Web servers. Busy sites, such ...
Well in working with scrum it's always seen as important to make clearly defined stop and start points of small tasks. However how do you capture "ongoing" tasks into a scrum system? Like on friday after deployment we typically have "work on documentation and code review of old code to check for bad practices". This ha...
Context: I'm building a popup widget. The html and css files are stored in S3. I need to get those files asynchronously and then continue with the rest of the logic. In the code below, I'm getting the html file from S3 and setting the contents of a popup div to be equal to the contents of this file. The issue: I have...
I'm building a Restful API and trying to use JSON:API format for my response. Looking at https://jsonapi.org/format/, it states: A resource object MUST contain at least the following top-level members: id type Exception: The id member is not required when the resource object originates at the client and represen...
I am trying to build a API for doing CRUD on images with their caption. So far I can think of option1: sending the images in form-data as list of images and their corresponding captions in another list and map them according the list index. Cons: mapping according to index may lead to human error and seems somehow inc...
A manufacturer sells different flavour chocolates. Customers can place an order for any number of each flavour chocolate, from zero upwards. Some combinations of chocolates are frequently ordered, so the manufacture has prepackaged these combinations in his warehouse to make dispatch quicker (which saves money). There'...
My question is not about dilemma between clean code vs performance, but I want to understand exact issue with declaring variables and sharing them between functions. I read in many threads, that from performance point of view it is good practice to declare basic variables like int, float, bool etc. as close each other ...
In some C projects, function names start with a common prefix indicative of the module name, for example: mymodule_do_this_stuff(); mymodule_do_that_stuff(); Is there a justification for doing so when the linkage is internal, and there is no possibility of namespace collisions? For example, static void mymodule_do_th...
I have a software project A which makes API calls to a third-party software B that is heavily based on data stored on the file system. Also, those software and file systems are distributed on servers in different locations. I have been thinking of ways of not using a file system, and using a database instead for storin...
I am working at a medium-size semi-govermental organization managing subcontractors for software projects. One of our contractors recently turned in the "source code" for the project they had contracted. I strongly suspect that the code is auto-generated. This bothers me for several reasons (some of which are also ment...
I'm writing a fairly large piece of logic, during which there are 6 points where things could go wrong and execution should stop after logging the error. The error is also stored in an object. However, up to now I have been using a public static final String for this error string. As it is only used in a single place ...
I have a business object which is basically a wrapper around a value of type int. There are some constraints for the value/object: Not every value in int's range is valid1 The valid values are not a predefined discrete set, therefore an enum is not an option Two objects with the same value are always considered equal ...
I have devices thay play video files from their local disk basing on a pre-defined playlist (every device plays exactly the same movie in the same order, every device knows in advance what videos will be played and what is their duration). There is no master device, every one is equal (there is a server though, but it'...
Here are a few examples: Imperative verb Initialize! InitializeWhenCreated! RequireValue! Third-person verb HasValue? RequiresValue? Are there some rules how to choose either imperative verb or third-person verb to use?
I am building a Browser Extension that captures a Selection made by the user in any web page, and stores it in his account. I don't quite know how to proceed with this, however. My initial thought was that I had to build an extension for this functionality [capturing the Selection], and a web app to receive it and deal...
I was reading the Cloud Foundry docs on Pushing Apps with Sidecar Processes. Under Limitations, there was a point stating health-checks: Sidecars only support PID-based health checks. HTTP health-checks for sidecars are not currently supported. I am unable to understand the difference between PID-based and HTTP-bas...
I've a habit I just mechanically do without even thinking too much about it. Whenever a constructor is waiting for some parameters, I consider this a public information that should be available by the calling code later on, if desired. For example: public class FooRepository : IFooRepository { public FooRepository(...
I'm working for a large company that's currently overhauling its network infrastructure, and several departments within the company have expressed interest in APM, desiring a tool for performance monitoring and error catching, customer tracking, business transaction management and the like. However, the organisation's ...
I confess, the question title suggest a "too broad" question, but here me out first... I am only interested in verifying my findings in that regard. All the following situations have the following in common: Binaries and supporting files (no user data) of an unspecified application should be installed onto the target ...
I have a common style (common.scss) and a text direction (RTL, LTR) option file (option-document-direction-rtl.scss, option-document-direction-ltr.scss). And by switching the reading of these files, the css file with RTL / LTR changed is output by method like gulp.js. _common.scss body { max-width: 1120px; backgrou...
Currently an enum in our project takes properties in the constructor. They are practically guaranteed to be entirely different across every different enum. Now I'd like to add an property which is a simple boolean - and it's only different from the default in a very few specific cases. There's 2 sensible approaches I c...
I have a city review app and will let people review the cities where they have been. Forget about users for a while. So in the db will look like this CITIES: REVIEWS: | id | name | | id | CityId | score | |----|----------| |----|--------|-------| | 1 | Tokyo | | 1 | 1 | 3 | | 2 | ...
I'm looking for general advice regarding the structure of applications. In applications I've been building recently, I've started to use a class (I'll refer to it as DataManager for the rest of the question) to hold all my individual objects, and all related methods. I make the DataManager accessible by all other class...
I'm suppose to identify 3 CK metrics and the most appropriate class to refactor so as to increase encapsulation, modularity and reduce the complexity of the following project According to my research, from the original metrics proposed by C&K the coupling of objects and lack of cohesion of methods impact all 3 factor...
I guess most of you already met them. You get them from your data sources, see them in your logs, or in the output from your legacy systems. Some strings you can't really read. To derive any useful information from them, you need to decode them first. With files, it is often possible to see the header. With text string...
I'm actually building an application that relies on multiple third parties (like 10-12) and I'm wondering if I should test my application with its third parties integrations. I had a discussion with some folks and it seems that the answers vary in a way that I'm not totally sure of what could be better than the other. ...
I am starting to work in a company. In this company, we have a set of products. These products are inherently related and have many shared functionalities and parts. Each of our products consists of a number of components. Types of these components are small software code, electronic boards, and mechanical pieces. Aft...
This is a question I constantly ask myself when designing a data intensive application: When is it appropriate to use stream() over parallelStream()? Would it make sense to use both? How do I quantify the metrics and conditions to intelligently decide which ones to use at runtime. From what I understand, parallelStream...
I am a little bit confused about simple factory and factory method. My main difficult is the abrut difference between the examples code on the internet, even on wikipedia, where have lots of them, some with Interfaces, some with Switch cases and some even with registers I've create this simple one example, using PHP, b...
I'm not sure where to place the following checks I have now in the material domain class. The issue is, that I need to validate that material exists and is valid in external database. Only after that validation I can be sure that I can use this material in our new project and store it in database. The Material object i...
I'm starting on a greenfield project and haven't done or architected the sign-up/sign-in and auth part of the backend in a very long time, so my knowledge on the nowadays' good practices is very limited. I've basically only done basic local sign-up/sign-in functionality. The app is related to social networking, so thou...
I have a design question about data. I have a class "T" that has a single interface handling two data types as described below. The class T is constructed to handle one of the two data types. Users of T class do not need to know which type of data T class handles. Data class "L" that has a known (limited) number of i...
I've been a relentless proponent of small files. I prefer one function export per file, functions with everything-in-one-view, and breaking up UI components as much as sensible (which is why I love React). There are many benefits to this from a code-maintenance and clarity perspective (IMO), but I have never assessed w...
I wrote a lot of code with the intention of it being usable not only in the WordPress space, but everywhere and because of that, I've been very, very against returning WP_Errors and resorted to only returning bool when something went wrong. Naturally, that's not enough because a boolean doesn't give you any context as ...
I have an application that consists of multiple sections of which each section will need to load data from various API calls. Now I'm thinking of taking advantage of Session variables(or caching) to store some data based on User ID so that in case of a user reloads the page continuously it would prevent unnecessary cal...
My employer recently learned of Laravel, and has asked us to migrate much of our development to it. None of us have issues with this, as we’ve all played around with it. We have two main in-house products: an api, and a web app which calls said api. The discussion we’re currently having, is does it make sense to put b...
This is probably a very basic question, but I have never worked on a team before and I'm not sure if there is an obvious answer or if I'm too bad at googling. Regardless, I can't find a clear answer to how this is done in practice. Let's say I'm on a team with 9 other people working part time on a school project for th...
we have a monolith that basically reaches close to a 100k IoT devices/routers and tries to gather some information about them. As you can imagine, this can take close up to 40 hours for the process to complete(due to badly designed monolith + slow network that reaches these devices) Now I am trying to break this IoT de...
I am developing a blog website, for each post, it has a list of tags, just like stackoverflow. There is no doubt that in the server side, i will expose a api like blog/edit to the client side, and the request parameter like: class BlogEditParam{ private List<String> tags; } So definitely i need to validate the tag...
Recently, I have been told by others to look into containerization of my stateless web applications (in this case .NET Core 2.x and 3.1). All of my dependencies are retrieved from public and private Nuget feeds. For a few years, I have been deploying to Azure App Services (Web apps) with no issues and only some very s...
I have a piece of code (a Facade) that creates every single infrastructure component on aws. private void synthesizeStack() { Deployer<Vpc> vpcDeployer = new VpcDeployer(this); Deployer<Bucket> s3Deployer = new S3Deployer(this); Vpc vpc = vpcDeployer.deploy(); Bucket bucket = s3Deployer.deploy(); ...
I'm trying to clean up some of my code using some best practices, and read that comments are almost always a bad idea for future maintainability. I've managed to get rid of most of them by refactoring to methods with good names. However, there are several comments sprinkled around that explain why a single line of cod...
I'm working with several Excel worksheets and workbooks that need to consolidated or linked to each other. These workbooks will track client interactions for different team members. I did the initial consolidation in Microsoft Excel, but realized that going forward, there's a risk of people overwriting each other or wo...
This is a difficult question that can involve many people, it is a real scenario and can have real consequences. A big organization with about 100 developers, working on different teams. The teams work with different front-end technologies, maintaining different products for the same company. One team has experience w...
I have the following use case about a video rental store which has the following actors: Member (Gold, Ordinal) Assistant Supplier Clerk The system is a desktop application for renting and reserving videos, and the shop has a range of videos in stock for members gold members can borrow a maximum of 10 videos, while ...
In this and this stack overflow questions, the answers state that C as a compiler backend is a bad idea. But why? C has many compilers that can heavily optimize it. Every platform has a compiler that supports it, and it can be compiled to every architecture in existence. In addition, languages like Nim and V support ge...
How about instead of #define bool _Bool #define true 1 #define false 0 #define __bool_true_false_are_defined 1 We should have this: #define bool _Bool #define true (bool)1 #define false (bool)0 #define __bool_true_false_are_defined (bool)1 so that the issue specified in this question won't happen, by casting the lit...
Traditionally it's assumed that we should treat create read update delete as separate concepts. However, I have noticed that the following pattern seems more usable for certain contexts [create, update, delete], [read]. For example: In the context where what's allowed for a new object may be virtually indistinguishable...
From what I understand two components A and B should only communicate with one another via an interface. Ideally this interface should be in its own separate assembly so that the client need not be loaded with the dependencies of any particular interface implementation. The question then is how do I pass information su...
According to Is "avoid the yo-yo problem" a valid reason to allow the "primitive obsession"?, I should define "price" like this: public class Main{ private Price price; } public class Price{ private double priceValue; public static void roundToValidValue(double priceValue){ } } instead of public clas...
I would like to understand what happens in a request which includes a .pfx certificate to authenticate to client to the server. I know how to implement this in python or use it in postman, but I don't understand what happens in the background. In which part (header, body) of the request is the certificate included?
I have data spread across two tables shipments and shipment_data. Currently I have the standard auto increment primary key id for shipments and a manually assigned unique primary key id for shipment_data. The primary key on shipment_data is also a foreign key referencing id on shipments. In my mind this seems more eff...
Currently I'm working on creating something with the following general structure. I want to call 4 different APIs in sequential order (the results of one are needed for the next one). If one throws an exception, undo the efforts of the previous APIs with their sister delete APIs. Currently my structure/ control flow lo...
I'm the manager of a reasonably small sized development department with 13 developers, 5 testers/QA, and 2 UX-designers. The support is split into two parts "Customer service" (CS) and "technical support" (TS). However, today these are quite intertwined. TS and CS share the burden of answering phones and reroutes ques...
I have an application which uses lambda and fargate (task) containers for compute, EventBridge for communication, S3 and DynamoDB for storage and exposes data out via an API Gateway. From my reading I can see that I can use PrivateLink or similar to expose each of these services into a VPC. However, all the documenta...
I try to design a client application for a messaging application. The client can send and receive messages, the client can connect/disconnect. My problem is that I don't know how to incorporate the Server class. Where would one put it in the diagram?
Which is better to use? react class based stateful component or react hooks functional stateful component? I've searched a bit but couldn't find what is preferred to use.
I'm working on a certain group repository. This repo has an issue tracker, but - it's not intended for all issues, and certainly ot for our day-to-day development work. The point is - I need to track issues with my code (and perhaps the code of others ) - myself. How would you suggest I do this "private issue tracking...
Need your help to clarify primitive concepts: In an embedded system, when a program runs on the processor (ARM as an example), in my understanding that it is because the "code to be executed" is loaded in the main memory. My question is: Is "the code to be executed" called "executable", what does "executable" mean? ...
Sometimes when working with other developers with git version control I run into a problem where the git graph suddenly spawns countless parallels lines like in this image. Image from here. I have no idea what actions cause this and how to prevent this issue. Usually this happens with just a couple of branches like ma...
I have seen people point me to many different "origins" of TDD. Some will point me to Kent Beck's rediscovery in the late 1990s with XP. Others will mention the 1960s best practice of annotating the results on the sides of the punch cards to check things faster and more accurately. And, still, some will point me to var...
We're in the process of moving everything to K8s and one of our applications is a small .NET Core 2.2 console app that runs a Hangfire background job server. At the moment the app runs as a Windows service, but that's obviously about to change. The problem that I ran into is that I'm not sure which approach is better f...
I am currently writing a Python program that retrieves the pixels from two BMP files and finds the percent difference between them (without using the Pillow library for the purpose of learning). I can think of two ways to approach this problem: 1) Read the pixels from each file in separate streams and compare the resul...
When the caller gives me a call, I need to evaluate n number of criteria which currently I'm doing like if (a & b & c & d & e) Day by day the conditions are growing and it's really hard to read and understand even for me (who actually wrote the code). Is there any better way of doing this?
I have created a class that implements behavior which is difficult to test without some intimate knowledge of internal state. I'd like not to clutter the class's public API with accessors for this internal state, and I'd also like to add some friction to other programmers writing code depending on this internal state. ...
Sorry for the weird title but I couldn't think of a better way to explain it. I saw someone do this once and didn't think it was a good idea but I wanted to check. Basically, he wanted to return the numbers 0-3 and do two different things with them. Say he wanted to use one as a key to a dictionary and the other in a v...
I can't believe DataTable/SqlDataAdapter massively beat out System.Data.Linq.DataContext.ExecuteCommand and ExecuteNonQuery (tried with both Stored Procedures and command text) and just straight SqlConnection/SqlCommand ExecuteCommand and ExecuteNonQuery called during looping. I was going to finally upgrade a legacy a...
After searching for some Abstract Factory examples using modern programming languages, I have some dillemas about the sensu lato of conceptual UML schema of Abstract, more specificly about the Client (Application) Class and its relationships On wikipedia example, the Client code has relationships with the Factory and e...
Regarding the understanding of Northbound interface and Sounthbound interface of a system, which one will be correct? A In understanding A, the traffic from/to higher level system is northbound interface (blue), while that from/to lower level system is southbound interface (orange). B In understanding B, the traf...
I am working on an (PHP) application where users have so called workspaces. A workspace is a folder with a specific structure and bunch of specific files - user information and some workspace metadata is stored in the DB. To separate the concerns I split all classes into those which access the database and those who ac...
I asked this question on StackOverflow recently: Is there a Map in Java that supports looking up Keys by (non-Unique) Value? As I suspected, the answer was "no", but I'm wondering why there is no data structure that captures the relationship in question: Value put(Key, Value) List<Key> lookup(Value) Is a fairly common ...
I know that Primary-backup replicated distributed systems guarantee sequential consistency. My question is whether multi-primary systems also achieve that. I mean if they use consensus (i.e: Paxos algorithm) to agree on an order for the received requests, then I suppose sequential consistency is achieved. But if they ...