instruction
stringlengths
34
36.1k
I have released works with MIT licence, others with CC BY-SA, etc. But for a specific work, I'd like to share it with Creative Commons BY-SA-NC, i.e. I don't want people who will modify/fork it to make a commercial use of it. Can I still sell this software (or service linked to it) myself? I read that having one "publi...
I have a Python project that looks something like this. project/ tests/ __init__.py tests.py main_module/ __init__.py sub_modules/ ... task1.py task2.py ... outputs/ data/ For context, main_module implements a whole bunch of numerical computing code a...
I am implementing the clean architecture. The use case should not know details about the UI because the UI is in a more outer layer. Same goes for the data layer. For the data, the use case should work through a repository without knowing the details of how the repository works. I like to err on the side of putting mor...
I hope this is the right forum for this question, but I'm just looking to understand how Google Docs and Sheets works. How can multiple users edit the same sheet and see live changes without having to refresh their screen? I'm an old school web developer who's been out of the game for a while and was curious how someth...
In Tanenbaum's Computer Networks book Three concepts are central to the OSI model: Services. Interfaces. Protocols. Probably the biggest contribution of the OSI model is that it makes the distinction between these three concepts explicit. Each layer performs some services for the layer above it. The service definiti...
I've often come across situations where pattern matching in a string is formalized, but the reverse is not. Say I invent a new string pattern that can be expressed by regex /([0-9a-z])*:([0-9a-z])*@([0-9a-z])/. Expressing that regex as data to your friendly local programming language, the standard lib will be able to c...
I have a type which is fairly heavy (maintains an off-heap object), and which can be uniquely derived from a String. It requires cleanup, so of course the type has a close() method, but it is used in contexts where clients may not be sure when they are done with their object; or they may simply not be aware they are su...
I have 2 POJO classes, DatabaseRecord and MyCustomRecord. In my service logic, I wanted to convert the object of type DatabaseRecord to object of type MyCustomRecord. The code for converting should be as simple as below: public MyCustomRecord toMyCustomRecord(DatabaseRecord databaseRecord) { MyCustomRecord customReco...
I need some help finding references to solutions to this problem. This is the basis of a real-world application I'm working on, rather than an academic problem. There are 4 main objects: Water (litres) Producer (location) Consumer (location) Carrier (water). Consumers can order water. A carrier will collect it from t...
We're trying to migrate to either a cheap hosting or aws Kubernetes to cut costs. Our website is a game site and has around 100 users. The servers include 2 mysql db, 2 tomcat server and a management server. It doesn't use much resource. So I've been thinking of launching a single node k8s and launch these servers as a...
To execute a system call, a program must execute a special trap instruction. Why is it called a "trap" instruction? What is the etymology of this usage of the word "trap"? Is it related to the usual English word trap? Is something is getting "trapped" as in "unable to escape"?
Sometimes I need to express the abstraction of anything that can be declared. For example, in C, they'd be: functions classes variables constants in Ruby, they'd be: modules classes variables constants Is there a term for this? Is it "symbol"? Or, is it "data structure" correct (in particular, considering functions...
I'm trying to implement microservices and I'm still super new to the subject, but, I was able to answer most of questions. However, one of the questions that I can't come up with a good solution to is how do I make my consumer idempotent when my publisher publishes at least once? What happens without making Consumer i...
Steve yegge wrote an article called "Execution in the Kingdom of Nouns" back in 2006, 14 years later I still find the points he made valid. For example, "Action is what gives life its spice... (but) Object Oriented Programming puts the Nouns first and foremost ... nouns are things, and things are prized beyond all acti...
I am exploring using a microservice architecture. Among others, this would include three services, an Orders Service, a Products Service, and a Fulfillment Service. Let's say the Fulfillment Service needs information about an order. What would be the more common and most accepted method for Fulfillment Service to acces...
I'm reaching out with the following situation: I'm the author of an application that saves a file format to disk. There are real users using the application in their workflows. Frequently, I want to change the file format. But I don't want to break users workflows! The above is a bit vague because I don't want to app...
I was wondering if there was a way to encode binary data, such as Crypto addresses into a natural language format, in a similar fashion to how what3words.com can encode locations into three easy-to-remember words. Would it be possible to use something like a recurrent neural network with a deterministic word sampling f...
I am trying to make a project which will help me to implement feature based licensing in future projects. The projects in this solution are C#/WPF Projects. So I have a Helper-Project with a class "Licensing" which contains the following function: public bool CheckLicenseForFeatureId(int featureId) { // return true/...
I am trying to come up with a design for an application I am working on. Here is a basic picture of what I am looking to do. Everything up to the Data Layer is totally fine but the Data Layer makes request from the Network Layer as shown in the picture, and that is one way, from Data Layer to Network Layer. Here is my...
I want to make an app that runs for 30 days and then stops. The platform is Windows or linux. The following approaches seem feasible but can be broken: Use system time: Easily broken by changing system time Use a piece of information on the computer hardware: Easily altered Use internet to connect to external server...
I have a .NET Core application that is hosted as multiple load balanced instances (separate servers, obviously pointing to the same database). I have written a service within the application that polls a table in the database every 5 seconds, each row returned with a "Pending" flag is updated with some new values and s...
I am reading a document of Varnish and I get the important VCL state image shown below. We know we often use UML as a standard to draw a state machine. but this image is not, is it follow another standard? or not? I can understand the start/end diagram (hexagon), state diagram(two rectangle), judgement condition(rhombu...
I have a Converter which use a Resolver to determine which Factory to use when converting a Resource to a Entity. To do so, I need to be sure that the Factory has a createFromResource method. The problem: I am not able to create an interface handling the Factories because of the contravariance of arguments. The Factory...
Essentially, I'm building a Query Builder (in C#, if that's relevant) which has this sort of interface, exposing more statically typed functions as the query gets more refined. AnimalQueryBuilder - HasId(id): AnimalQueryBuilder - IsHealthy(): AnimalQueryBuilder - IsDog(): DogQueryBuilder - IsCat(): CatQueryBuilder ...
As an example, let's assume our application needs some way to communicate with other systems using HTTP. interface HttpClient { fun <T> get(url: String, returnType: Class<T>): T fun post(url: String, body: Any) } Now it seems like good practice to have our components depend on this interface and not on an implemen...
I'm trying to get a better understanding of how tox and GitLab CI (with docker runners) would work together, as they seem to have a bit of overlap in what each does. I think I may be missing something on exactly the purpose of tox as well. Here's tox's stated purpose: tox is a generic virtualenv management and test co...
We implemented a TaskManager class for this purpose: execute a number of tasks asynchronously (off the UI thread) one after the other. Basically, this class includes a queue of tasks and the functions to run/execute them. Considering that the class is a hybrid between a collection and a manager, the question is: Should...
I'm implementing a stack-based virtual machine in C. The following variables are used by pretty much every function: memory array various pointers to memory offsets program counter stack stack pointer frame pointer (less so) Ordinarily, I'd avoid the use of globals. However, in this situation handing these around bet...
Consider a list of items (take a list of voice channels) where each item has these attributes System::vc: List of voice channels. System::on_join(member, before, after): On the event when a member joins a VoiceChannel the first time, it's before is Null and after is a VoiceChannel. When a member switches voice channe...
When exploring a new codebase, what would be some methods of storing personal notes or annotations alongside the code? If I were the only maintainer, I might consider added an actual code comment into the code, but doing so in a team would just pollute the code and the git logs. Ideally there might be something that is...
Consider the following scenario: This year, 2019, the finals of the African Cup of Nations soccer tournament were hosted by Egypt. A number of countries were involved, in fact, 24 of them, even though this number can vary for each tournament. Each country had a number of players that participated. The African football ...
I just started reading The Pragmatic Programmer e2. I came a cross the topic of avoiding Duplication with Data Sources, which I did not fully understand. The pragraph reads as follows: Many Data sources allow you to introspect on their data schema. This can be used to remove much of the duplication between them and yo...
Given a set of processes running on a cluster of hosts, I'm designing a system that load balances the hosts through live migrations (carried out by an external service) of the processes. The goal of the load balancing is to minimize or prevent resource starvation, a situation in which processes are not allocated the am...
I am working on a distributed application that uses the Manager Worker pattern. The application's manager node submits work to worker nodes through a WorkerNode object (allowing WorkerNode to be treated as the server itself). The manager node can also submit work to its' internal WorkPool this is currently done by call...
A program I'm developing has two threads running similar but different task: thread1: timer1.start() writeToExternalDB1(consumedData) timer1.end() thread2: timer2.start() writeToExternalDB2(consumedData) timer2.end() I want to compare the writing performance of the two external database. I have timers around the writ...
I'm entirely uninitiated to the world of web development, and only have a tentative grasp on Django and web development through the test server it works through. From the guide I'm reading, the author turns to using Nginx once he starts working on site deployment, because Django is "not designed for real-life workloads...
I currently have a service class RoutineService.cs that contains methods that each perform one thing, call the repository and return that exact same object. With how simple it is, is my service layer necessary? I feel like it is better to inject the RoutineRepository Service into the controller and skip the service l...
I want to create a DB table to keep the sensor readings from the physical sensors (weather station). What I was thinking is to create following: +--------------------------+ | readings | +----+------+------+-------+ | id | type | unit | value | +----+------+------+-------+ | 1 | 1 | 1 | 35.0 | ...
I'm having a use case of a node editor, my node editor has "Sockets", dots highlighted here Sockets are distinguished by "EntryType" class, which is a "blueprint" definition for Entry, in this case type name is "Number", sockets have to access color information according to EntryType. Here's an Entry highlighted Entr...
When you have sharding, horizontal partitioning, you have multiple DBMS instances, and your server app chooses which one to use by some rule that uses record IDs. Well, for example, we have partitioning by some userId, so that each DB server contains data of 4 thousand users, so that DB server. is chosen by userId // 4...
this is a highly theoretical question about my parallelization approach. First of all, I want to inform everybody that I do not claim that I am the 'inventor' of that approach but I couldn't find any information about something like that. I will explain my idea through example. I assume that every task that is a depen...
I am writing the embedded firmware for an effect pedal. The pedal's ui consists of a few knobs a few buttons and a few leds and it consists of various control modes each corresponding to a seperate effect. So each mode changes the meaning of the knobs, the buttons and led indications. This is implemented as a sum type ...
Usually when I read Event Sourcing examples - they are pretty simple. When trying to implement something even more complex - it seems to get pretty ugly pretty quickly. Let me explain this on one simple example: I have a Car and car have Door (2 doors only). Now, the single use-case I have here is startCar - which will...
I've been working on a system that is using event-sourced persistence for it's data model. It is using a standard model of sequence of events with aggregates being rehydrated from those events and projections used for more complex queries. One thing that has been bothering me lately is the question of refactoring. As w...
Suppose we have a service which allows users to store files on a disk. The service should keep track of disk space used by a user and enforce a limit on the available space. Google Drive or Dropbox are obvious examples of such services. But furthermore suppose that size is tracked recursively for all of the user's dire...
I have a Single Page Application that uses React-Router and is served via Go backend. The pre-built static app is accessible at app.com which then uses app.com/api to load dynamic data. If a user goes to app.com and clicks the /widget link everything works fine. However, because the routes all use browser-based routing...
I was required to do a medium ERP with the inventory, Bill of Materials, and production modules. However, I do not know how long it would take me. I am calculating three months for the analysis and lifting of requirements, and 3 months per module. It is a company that manufactures cardboard boxes. However, I don't know...
I have a site where users upload images & can all be viewed on a single page by other users. I want to lazy load images as the user scrolls instead of loading all initially. This is easy enough, but relies on a width/height being set for the images used in calculating if the image is coming close to the viewport. This ...
I have entities in my application that require a unique human friendly identifier that include a sequence integer unique to a subset. For example, in project management software you might have a project called "SUPPORT" and then cases related to this project are automatically sequentially numbered as "SUPPORT-1", "SUPP...
We do have a micro-services architecture with a team assigned to each micro-service considering it as a product on itself. The "real product" is a front-end that uses multiple micro-services to offer functionality to the end-user (no micro front-ends), that means that all the bugs are reported at the front-end level as...
I work on a large and old application consisting of a server and a fat client. Part of what the application does is handle a large-ish (a few 100MBs) database of frequently changing data (~a dozen rows per second). Because of the size, there is a master copy of the database on the server and a local copy on every clien...
I'm struggling to think of a concise way to phrase the question, but assume you were developing an application that managed employees at various company branches. You could potentially model this part of the application like this: It's stipulated that every employee must belong to exactly one branch. To enforce this, ...
So first of all let me explain what I want to achieve: I want to create a basic .NET Core console application which is responsible for loading external extensions (more on this later on), listening for events, connection handling etc. Let's assume this application is a Discord bot or Amazon's Alexa. It is responsible f...
I have this situation where we have a couple of maven repositories. Some are frontend..ish (JSP, Spring Controllers etc.) meant to be deployed as war files and others are for the hibernate mappings etc. which are used as dependencies. I noticed that in most of the pom.xml files for the frontend..ish applications the de...
My understanding of a CQRS architecture is that a micro-service is split to two servers each with its own database such that the first server handles all the writes and the second server handles all the reads. Combining this architecture with event sourcing means that the write side will store events that keep track of...
I'm in a situation where there is a code base that has TypeScript and ESlint but: There are a lot of type errors (code compiles despite errors using Babel) There are a lot of lint warnings. We may want to introduce some new lint rules to solve some particular problems we have (for example, cyclic dependencies really w...
Recently I had a conversation with a colleague, who proposed that a whole app could rely on an event aggregator (or message bus). I think this is a really good pattern if someone wants to decouple publisher and subscriber, especially in cases where we have multiple publishers/subscribers. If there is just one, I think ...
In The Linux Programming Interface Sec 60.4, it talks about design a server that handles multiple requests using multiple processes or threads, or pools of processes or threads. Then it discusses another approach "server farm": Other approaches to handling high client loads involve the use of multiple server systems—a...
I am debating whether to give my files a public url or a limited private one. I am hosting various files for a mobile/web application. These will include product images and videos. Currently only authorized users can access this application, and so the files are private. However, I suppose users may want to directly sh...
After hours of reading blog posts, I understand that React has one-way data binding, and Angular has two-way. But I don't actually know what that means.... React import { useState } from 'react'; import Switch from "./switch"; function App() { const [value, setValue] = useState(false); return ( <Switch i...
In designing a RESTful api the problem arises as to how best to allow resources to be moved between collections. Renaming a resource could be done by using PATCH but this is not the same thing as moving the resource between collections. Also it is not clear whether it is the resource or the collection which should be p...
I'm designing a 3D visualisation applet in Javascript. When used, a Canvas will be created and placed inside an HTML element on a webpage, specified by the developer who is implementing the applet. Various graphical elements will be drawn onto the canvas. One of the requirements is that the applet should support user-d...
I want to perform dependency injection in my Python application without using reflection. My position on reflection is informed largely by the "don't hide things" philosophy (I am unable to find a decent reference to this on google at the moment). What that basically means to me is that code ought to be easily discover...
I'm trying to wrap my head around a Queue system. I have read many resources about it but I keep ghosted with this question. If I have listeners that loops over a collection of users, to send a notification via FCM or APNS or Pusher or SocketIO, etc, for each one of them, and the Event which triggers the listener were...
My English skill is poor because I'm not a native English speaker. Please understand. I write this article because want to discuss about this topic. I think LR parser has no 'practical' advantages over the LL parser. The fact that many tools uses LR parser is not a effective advantage. I think the criteria of practical...
I have a group of squares on a 2d grid, here's an example I need an algorithm to find out whether we are able to remove a square while keeping the entire group connected. Below is an image where I colored squares that are possible to remove in green, and squares that would make the group disconnected if removed in red...
I implement an auth endpoint which takes an email and password and returns a JWT token. Inside the JWT there is a payload containing the user ID. Does it matter from a REST/JWT standards perspective which of these approaches I take? return the token and let the client request the /users/user_id resource on a callback ...
I have a abstract class named MotorizedVehicle that contains an implemented gas- and brake-function. I want to make a Truck class that extends this class and uses gas exactly in the same way as MotorizedVehicle, but with the limitation that it can't move if it's ramp is lowered. My thought is that I am then restricting...
Recently I shared with my team the Builder Pattern(fluent style) for unit testing. I personally like to use that pattern for unit testing, since many objects are usually created and with different parameter configurations. The pattern helps keeping the unit tests short, specially if combined with Object Mother pattern....
Load balancing in is a common topic, but there isn't as much said about load balancing out. I may have an application that can prepare 1mm requests/s but is unable to send them all out at that speed because of network restraints. Is there a concept of an out-balancer? Are there any ready-made solutions out there that c...
I'm trying to figure out if it's possible to have an algorithm that solves a certain problem in better than O(n^2) time. Specifically, I'm looking for an algorithm that, given two lists of two-tuples (e.g. one could be [(a, b), (c, d), (e, f)]), figures out if there exists any pairs of tuples, one from each list, that ...
Quite often I find difficult to decide between implementing operations as functions or as methods because I am not sure how to weight various well-known guidelines for this problem. I would like to know if someone could provide further design insight to help me decide one over the other. To illustrate my point, I will ...
I'm currently working on a .NET project where we'd like to perform some computations directly on the database for efficiency (e.g. performing a join and count on the database to check if a user has permission to perform some action instead of retrieving the entity). However, I'm not sure how this will interact with the...
I started programming in C++ about 6 months ago and started off like many, structuring projects in a C like way. I split .cpp (implementation) and .hpp (header) files and used virtual classes for interfaces. As I have learned more I've realised that the majority of C++ code I've seen is making very extensive use of tem...
I'm fairly new to architecture and I kinda get little endian wrong sometimes. So In this snippet I overflowed the sub-routine's stack frame just to affect the SAVED RBP and when I looked at the SAVED RETURN ADDRESS it didn't seem like it was written in little endian format. My confusion arose after I saw that the paylo...
Is the requirement of a field a functional or nonfunctional requirement? Maybe it is nonfunctional because it is a characteristic of the system. I have to list functional and nonfunctional requirements in two tables. I did this: Functional requirements: Register product: The system must register a product. It will hav...
Computer Systems: a Programmer's Perspective says: 12.4.2 Mapping Variables to Memory Variables in threaded C programs are mapped to virtual memory according to their storage classes: Global variables. A global variable is any variable declared outside of a func- tion. At run time, the read/write area of virtual memor...
I am trying to understand the best practice around the event-driven architectures. say I have 2 services order service and inventory service. An user wants to order product and sends a request to order service Question 1: how to design this? option 1: order-service - do the order transaction order-service - place an or...
Consider the following: public boolean maybeUpdateTime() { if (this.timeReference.isAfter(lastInterval.getBeginning()) { this.timeReference = lastInterval.getEnd(); lastInterval = intervalIterator.next(); return true; } return false; } public void updateState() { // do some stu...
Going native is extremely good for front end development. Whether its using android vs ionics, c++ vs dotnet/java, the benefits to GUI are significant. I was wondering if the same had significant effect on back end code. Is it really that significant if I rewrite my backend processes in native language? To be specific ...
This is a pretty difficult question to frame. But I'll try my best. In some languages, data types are decoupled from the operations they can perform, while in other languages like JavaScript they are tied together. An example: Arrays in Javascript have a filter method so you could easily do array.filter(condition-funct...
A problem been thinking on... I'm on an application that involves two web maps, both showing the same data but in slightly different situations basically (say a different basemap or projection, etc)... They both need to be in sync, so if I add some data to one the other should update. If I remove data from one, the oth...
I have been facing a task to develop a software driver in C++ for a chip which makes available 8 digital inputs over the SPI bus. In the time being I have been thinking about the interface of the driver. The idea which I have is class DigitalInputsDriver { public: enum class Input { Di_00, Di_01, Di_...
in read-write locks, why do we need read locks since processes can read a file at the same time? Would only a write lock suffice? Thanks.
I'm designing a distributed queue message queue and I'm not sure how to get the leader information to another component. This is my current design: I have the following components: FrontEnd: request validation, authentication, SSL offloading, server-side encryption, etc Metadata Service: keeps queue metadata informat...
I am using mediator pattern with 10 clients. It happens that the mediator class size go beyond three digit numbers. I think it is a bad practice to have such big classes. Is this size an indication of using false design pattern? Do you have any recommendation to decrease the code size of this single mediator? Other des...
Our company paid for an agile coach, who - without knowing much about our company - went like this: Story should just encapsulate the value and then and clarified with the business Avoid detailed specs, that is not agile! We were thinking about that but think that just cannot work in standard fixed-price and fixed-...
I'm confused about a matter that I've been unable to figure out. I'm doing some leetcode problems. In backtracking problems, sometimes we use loop within our recursive method to call the recursion but other times, I see solutions where in backtracking they're not using loop to call the recursive method. For example: Th...
This is something that has been bugging me for a bit in a program I am trying to build. It is a desktop GUI application, and I settled on the use of the famous "MVC" (Model-View-Controller) architectural pattern for separating out the GUI and business logic. I've spent many hours wracking my head over various descripti...
Lets say I have a GUI application which tries to adhere to Model-View-Presenter (MVP) as best as possible. In this application I have a list box with items. One should be able to interact with these items via a context menu. But: Which entries in the context menu are shown depend on the state of the item. For example: ...
I'm currently organizing a software project via Jira on my own. Right now I'm the only one who is developing on that project. However it is possible that more people will join the team in the near feature. I'm now wondering how to deal with stories and tasks. I/we don't using Scrum but a Kanban board with three columns...
For a project that's going to live/used/maintained by the developer for a very long time (ex: 20-50 year); Is custom (self made) framework better than (open source) popular frameworks? Basically my highest priority requirement is security and very long term lifetime. My current situation is having to maintain 15 year-i...
I am following the DDD principles and have these Aggregate root classes. The problem is that after some time my class contains 1400 lines of code which makes development experience a little bit worse. Is there any recommended way by DDD how can I split this AggregateRoot class into few classes? I know, it can be said t...
Let’s consider that Context diagram is the diagram that describe the system as a single process and level 0 diagram is the one that decomposes this main process into major process and so on. I am mentioning this because my text books refer to context diagram as level 0 diagram. However , in my course, context diagram i...
Please, consider three pictures, I found in internet: 1: 2: 3: I always thought, that REST and SOAP services are in service layer - see #1. However, if you look at #2, you'll see, that presentation layer provides restful service. #3 shows, that presentation layer includes only REST services, but not SOAP. So, does p...
I'm writing a PHP web application (or actually a Symfony module). One part of it is a nested structure of ValueObjects (meaning: they are immutable and have to be validated on the creating). Such an object can have about ten plain properties and sometimes a couple of further DataObject properties. Semantics: The classe...
I need to finish a task in my homework. I need to include a use case diagram. I have the following situation I have a master, admin, manager, seller and attendant users. It is like this, master is the root user. It is the only user on the system if none was created. The master user can create an admin. The admin is lik...
Btrfs supports crc32c, xxhash, sha256 and blake2b as checksums when storing and reading files. crc32c and xxhash are designed to detect random errors while sha256 and blake2 are considered cryptographically secure. My question is, in what scenarios do I need cryptographically secure checksums in btrfs (or other filesys...
I have implemented authentication on an API Gateway level using NGINX+ and now I have concern if APIs behind it should still to authenticate using API Keys or JWT? What are best practices? My point is that somebody may get to the internal network, intentionally or not, and then use those APIs which are wide open (no au...
I have read multiple pages/blog posts on API key vs JWT and still I'm confused when to use one of them. Most recent one are saying that JWT became a standard for API authentication but then it became confusing for me in few cases described below. JWT "no-brainer" choice is for any UI app which will need to authenticate...