instruction
stringlengths
34
36.1k
Part of the Aggregate + Event Sourcing (A+ES) methodology feels uncomfortable. Why does it feel uncomfortable? (As I've read from other questions and the book itself, it's a new-ish way of thinking, and the literature may not be great.) I think part of it is the separation between state ownership, and state transition ...
I see a lot of reasons to use binary over text-based formats. With binary, I find it a lot easier. I can use fread(data, sizeof(struct DataStruct), 1, fileptr) to read, or fwrite to write data. I find that a lot easier than finding and using someone else's bloated library to parse and encode data in JSON or XML. Since...
I am getting started with software testing in Java and was wondering if test-driven dev and white-box testing could be combined directly... If not, what ways can we extend TDD to combine white box testing?
I'm using semantic-release to auto find out the next version based on the git commit. It's working fine with creating new version, upload to npm and create new git tag. And semantic-release is executed whenever code is merged to master. However, in Node.js or front-end project, usually we have a file named package.json...
Premise A web application that has a frontend / backend separation. The frontend can be the JS framework of the month, which talks to a REST API in the backend. The backend part of the system accepts commands, which are delegated via application services to a Rich Domain Model created by applying Domain Driven Design p...
I have a React App (created via create-react-app) secured with OAUTH2. Currently all dynamic content is via REST APIs, secured with the same OAUTH2 token issued at login. It is hosted on AWS. I want to implement a picture library and here are two React components that i'm considering: https://www.npmjs.com/package/rea...
While I am reading The Pragmatic Programmer e2, I came across Tip 38: Crash Early. Basically, the author, at least to my understanding, advises to avoid catching exceptions and let the program crash. He goes on saying: One of the benefits of detecting problems as soon as you can is that you can crash earlier, and cras...
If my foo.py is merely foo_var = 1 and bar.py is merely import foo, I know I can write baz.py that says from bar import foo_var, but should I? (Or should I instead do from foo import foo_var?) Is there any reason why chaining imports like this would be bad?
I saw a lot of examples of decoupling domain models from Identity models. For my knowledge, currently IIdentity is included in standard .NET library, so is this actual now and should I follow this approach? Thanks in advance!
I've been using Graphviz a little and just found out about PlantUML which is quite similar. I make diagrams but later the processes or systems depicted by the diagrams might change so I need to make changes to the diagrams, hence it is important that code used to generate the diagrams is maintainable. I was wondering i...
I recently joined a team who are using github Pull Request feature as the single code review tool. In previous teams, I was used to reviews done on a fully checked-out code base, done using IDE tools, code coverage and static code analysis tools, etc. Compared to these reviews what I get today through github is abysmal...
Today, we learnt about sign extension to solve the problem where adding positive number to another positive one gives a negative. But my professor didn't mention at all when we should use it and how much extension should I do? How may I know when to stop?
I don't want to spam you with a ton of code, but please have a quick look at this boiler-plate method: In this scenario let's say I have a ProcessingText.py file (class) that I finished its unit testing, including the methods setTextToClean(text) and getCleanedText(). And I have another file, UI.py (a class also), that...
I am wondering about this. This is a sort of follow-up to my last question here: In the MVC pattern, what has the responsibility for creating the view? because now I've run into the question of how to deal with multi-threading in this application. For readers who have not read that, the application is a desktop applica...
In a bit of a quandary. I am using Cloud Run on GCP for backend services, and it will auto-scale based on HTTP load, potentially scaling down to 0 if there is no traffic for awhile. I have a product with 3 backend restful services running on Cloud Run, and the backend services need to communicate with each other. They ...
def create() -> socket.socket: ... return sock def create_(func: callable)-> None: ... func(sock) return What are the names of those two interfaces between* a socket creator and code using that socket? Perhaps touch on situations in which one is considerably more appropriate. * - sockets are just ...
I'm Java developer and I'm now learning Javascript creating a personal project. I don't know how to handle different errors in Javascript in a clean way and I can't find a good solution on the web. I'm consuming some external APIs using axios. The external resource use a pagination system, so when I get back a 204 stat...
Let's assume I use Kafka as an event store and put there all the lifecycle events of an order. Now I need to get the current state of this order in my system in during some business process. What's the best way to get the state of this order? Some random ideas coming to my mind: Before putting an event in the event st...
Assuming that we have a project called: "WizardProject". The WizardProject, which currently stands at version 1.x.x, has a mostly Java based stack and active development has been discontinued on it. Now, we want to bring the WizardProject back to life. Everything is new, but the same idea behind it, as well as the same...
I have 2 endpoints: enpoint A can only be called if endpoint B has been called before at least once. After endpoint B has been called, endpoint A can be called multiple times. endpoint B can be called multiple times without problems. Endpoint B loads certain data that must be present in the system, before we import a...
I am designing an application that works with REST API requests for dealing with information stored in a database. The user will add, edit, delete information in this client and after SAVE the information will be rolled out to the server (database) with the corresponding API request (GET, POST, PUT, DELETE) Now I have ...
Where I work, we have some integration tests which spin up a new SQL database instance in Docker, so that we can test the repository logic for write actions as well as read actions. We have a test for the "Create" method, which returns the ID of the newly created resource. Should my test assert just be that the ID of t...
In my application I'm dealing with periods. A period is defined by it's end date. A period may shrink or grow, can restart and can have a priority. This is modeled using the following struct: public struct Period { public DateTime EndDate { get; set; } public bool CanShrink { get; set; } public bool CanGrow...
I'm currently working on a farming IoT system and confused about the architecture so I wanted to get your views. I'm using a relational DB (PosgreSQL). I have multiple customers, each customer has one or more farmhouse and each farmhouse has one or more field. I have IoT devices on each field, from a few to 200 hundred...
I was asked this question in an interview of Crypto company for the role of backend developer. Please suggest me another stack-site if this is not the place to ask this question. There is a subsystem A which sends the data to another subsystem B as a file in.txt. Subsystem B then processes this file and produces an out...
In the text book software engineering by Sommerville , there is an example where he uses it to illustrate the famous type of software architecture "Client-Server Architecture", here it is : "a Client server model for a multi user, web based system for providing a film and photograph library. In this system, several se...
The result of processing an HTTP request consists of mappings. Each mapping is from an order number to an object. Is it a good practice to return this as an HTTP response whose body is a Map<String, Object>? How about a List where the object contains the order number string as an attribute. If none of these is a good p...
In one of the company's im involved with there is a problem between one manager and a programmer. They are both very good at their jobs, but there is constant clashes. I would like to get some feedback to help me sort this out. I did some research on the topic, including using my account at https://www.oreilly.com/ but...
Here is a very basic example to illustrate my point class SomeClass { publicMethod1(param1, param2) { if (param1 === "some value") { // do stuff } else { // do stuff } this.privateMethod(true); } publicMethod2(param1, param2, param3, param4) { ...
I was under the impression that Filebeat is only necessary if I wish to provide a constant, paced, fresh input to logstash. But the tutorial here starts with configuring Filebeat to send log lines to logstash.... I am confused. I am a total newbie rookie to ELK and I don't understand why Filebeat is needed if I used th...
Say I have a website/platform that allows people to submit business names in order to build a high quality business name database. You can apply this to any subject or topic, such as building a database of travel destinations, of movie titles, of quotes, etc. One of the main problems is how to guarantee accuracy and qu...
Lets say I have the following code in my GamePanel class: public GamePanel(Menu menu){ this.addMouseListener(new PlanterListener(this)) PlanterListener class: public PlanterListener(GamePanel game){ this.game=game; this.plantActive=game.getPboard().getPlantActive(); this.stage=game.getStage(); ...
Suppose someone designs an indexable iterator class, i.e. an iterator that supports __getitem__ for (non-negative) integer indexes such as the following: In [1] it = indexed_iter("abcdefghij") In [2]: next(it) Out[2]: 'a' In [3]: next(it) Out[3]: 'b' In [4]: it[1] Out[4]: ??? In [5]: it[2] Out[5]: ??? In [6]: next...
This is a bit of an invented example but I think it best illustrates my question: Say I'm creating a chess replay event API. Say I have a lot of different "events" I want to keep track of, in a specified order. Here might be some examples: A move event — this contains the previous and new square. A timer event — this...
For sure, there is a well-known topic here on SE, however, it is almost 10 years old, and answers that were excellent by then, might be obsolete now and there could be modern easier ways (but I don't claim of that, just ask) . Does anyone know, if during last 10 years, there was any significant advance, so we could hav...
I want to lead an Angular + NodeJS project. As this is my first experience, I thought about using UML diagram as both designing/architecting the project and also the project's documentation. But I am not sure if using UML diagrams is a good idea? I mean it takes longer time and many details that I don't know if is it n...
I have a class that looks something like this: class Entity { public string Id { get; set; } public List<Entity> Children { get; set; } public void DoStuff(Data data) { // stuff foreach (var child in Children) { child.DoStuff(data); } } } An...
We just started a small startup company with 4-5 guys and since now we were working by talking to each other about the requirements and maybe some hand drawn sketches about the front end of the project and how it would be look like. But we decided to extend our company and hire more frontend + backend developers and mo...
01 - BACKGROUND: I'm a typical non-programmer R user for 6+ years. Which means: i) I`m comfortable with the language most of the time and have written R packages for myself, but ii) writing C++ code (Rcpp) is not something I've done iii) R is fast enough for my purposes and data size 02 - PROBLEM STATEMENT: Few months ...
I have a data which is a std::vector of a "small collection" of items of a given type struct Bunny {};. I was vague about "small collection" because for now it's a collection of two of them, and so I'm just using the following alias using Bunnies = std::array<Bunny,2>; // probably it'd be better to make it a struct, so...
You're writing the code for an API that accepts payloads from users and, before performing the actual write/update/delete in the db must validate the input for consistency and this is done by consulting various backend services. The client basically waits for an "accepted" or "rejected" response. Obviously, you don't w...
I'm very new to writing immutable code. Would there be any fundamental issues trying to transpile arbitrary mutable code person.age = 20 into immutable code person = { ...person, age: 21 }? I am aware that it would change equality, such that "oldReferenceToPerson != newReferenceToPerson" after a change. EDIT: A comment...
All the examples across the internet try to pretend that every application is run on a single thread. There is no problem with synchronization, multithreading etc. Uncle Bob, in his "Clean Architecture" book mentions the topic but very briefly and suggests to postpone some decision as long as possible. But real applica...
I'm trying to implement a solution that stores every product from a shop, and then allows me to search them either by ID (an integer index), description (string) or barcode (string). The idea I came up with is to have a sorted list with products ID as keys and Product objects as value, this would allow me to search qui...
What's a good way of storing and referencing files of different types (csv, pdf, jpg, html), each of which needs my own custom metadata? The metadata stores details of the content and how it was created. Ideally I could add metadata to the file itself, for CSV that's going to be #comments. PDF similarly supports it's o...
I've got basic proficiency in PHP, JavaScript, html, and SQL. I also use Postman little a bit. I hope a solution to my problem can be found within those skills, but I'm willing to learn a new language if necessary. Using PHP, I've written myself a page of admin tools to be able to run my business. One feature I'd like,...
I have a set of algorithms to choose from based on their execution speed. I know that it is very hard to get an accurate measurement due to the process scheduling, the time that is actually consumed to get the measurement ... etc. I was wondering if a microcontroller ( like arduino uno) can provide better accuracy comp...
I have an n x n matrix which I need to convert into a list sorted by value. Starting with the maximum value cell at (row x1, col y1), I must immediately exclude all cells where (x >= x1, y <= y1) or (x <= x1, y >= y1). There are n x n cells, and each of them is getting compared to (n - x1) * y1 + x * (n - y1) cells. Th...
This is a question I have always wondered Is it as simple as repetitive pinging of a server in a seperate thread or is it more complicated than that? I am only talking about the app version not the browser as it is obvious that browsers have direct access to a servers database
I'm trying to understand the motivation of these two patterns. I think the listener pattern is just a pub-sub, and the use case is mainly in a distributed manner, for example, the AWS SNS is just a distributed implementation of this pattern. The whiteboard pattern is just a special case for listener pattern where it is...
Suppose I have two "modules", A, and B (I'm choosing not to use classes, because you generally can't create an instance of a module, which makes this question simpler). These modules contain methods suited for dealing with the same particular type of (arbitrary) data. Crucially, the representation/format of this data i...
I've a data streaming platform (Nifi) where I need to transfer tables of data between databases on given schedules. I want to be able to calculate in advance the optimum batch/schedule size i should use. Assume I've three databases with different number of tables, each with a specific row count and row size. The schedu...
Say I have a library function that expects a JSON-encoded object and does some things with it: function foo(bar) { const baz = JSON.parse(bar); doTheThing(baz); doTheOtherThing(baz.qux); } Now I encounter an object that is not already JSON-encoded but I want to do the same things with it. Since I don't wa...
In pseudo code: given numbers x and y, if x is greater than zero, subtract the magnitude of y from x, otherwise add the magnitude of y to x. It's ok if x goes from being positive to negative or vice versa. In python I've been doing this like so def shift_func(x: int, y: int) -> int: function = "__sub__" if x <= ...
I am trying to make an animation system that affects different types so I thought I would use generics. I have an animation controller that gets all animation objects into a collection (or at least that was the plan) then then run the animation on all the animation objects. The problem is I can't do it this way in C# a...
Intro I'm creating an app and I'm not sure if the structure of the solution is correct. I have a BaseController that uses generics. This controller is inherited by others that do not have to reimplement the code and just add functionality. The BaseController uses an IRepositoryService that has common logic to interact ...
I'm writing in C++, but this problem applies to most non-high-level languages, and possibly some high-level ones as well. I have a graph of heterogeneous nodes. The graph can be instantiated by different subsystems (e.g. it can be read from a file or generated by one out of many algorithms). I have several algorithms t...
In my Domain, I have numerous objects that are expressed by Identity alone. Specifically, several of my Subdomains exist only to represent something that has been created. For example, in a video game with combat, I have a Weapon concept. Each Weapon is Unique. A Weapon(bronze_sword) is different than a Weapon(steel_da...
So far, I've been using logging only in main() mostly. I do not log anything in my functions or classes but sometimes I feel like it would be helpful. What I would do now: def init_logger(): # set up logging to file logging.basicConfig(filename=LOG, format='%(asctime)s - %(name)s - %(leveln...
Recently I'm studying Saga pattern, but I'm struggling to imagine how it will work in real system. Standard example is making an order, which consist of reserving flight, hotel and a car. We can assume that we have following services: ordering service flights booking service hotels booking service cars booking service...
In an engineering company, there are many engineers that edit in Excel/VBA Spreadsheets to perform some engineering calculations.They all do more or less similar things: calculate, manage engineering stability, buildings, infrastructure etc.. They perform calculations based on data and formulas. Or draw a picture of un...
wanted to know if this is possible. Consider we have Branch A that is in a PR waiting to be merged. On a local branch, I pull the changes made in branch A and now they exist in my branch B. I continue to do work on branch B and now I'm ready to push. Q1: If I create a PR of branch B into Branch A, will this be reflect...
I have the following constructor in a class for a code I'm writing an assignment on for school: public Plant(int xPos, int yPos,int width,int height, int hp,String imageLocation,String audioLocation,Stage stage) The only parameter I find valuable to show in the UML diagram I'm creating is Stage. Could the other parame...
I have developed a Fantasy Draft system utilizing ASP.NET Core SignalR, along with Azure's SignalR service (for backplane/scaling stuff). Last year I utilized a poor-mans' javascript version that just polled the database every 5 seconds to check for new "picks" in the draft, or any changes that may have happened in the...
I need some advice on an IOT project I am working on. Here are some details about what I am trying to do: Use Case: Periodically receive data from the 3rd party vendor API in real time and allow users to set alerts when certain conditions are met in their data. Simple example: Send me an alert when temperature goes bel...
As an exercise in code architecture, I was writing a C++ wrapper for a window library called GLFW3. In this library, when a window's X button is pressed, you can register a callback that reacts to such event. The callback needs to look like this: void callback_name(GLFWwindow* handle); That is, it needs to be a pointe...
I'm working on a domain where we keep track of food that is stored on various locations, like the fridge or the cellar. While implementing the domain, I was wondering what the best name would be for the domain class that represents such a storage location. Until now, I've used the name StorageUnit or StorageLocation, b...
I need to document my design, in particular, the design patterns used, and would like to use the standard terminology. From Refactoring Guru, "Factory Method defines a method, which should be used for creating objects instead of direct constructor call. Subclasses can override this method to change the class of objects...
Basically, in our scenario, data has to be sent from a WordPress form to Dynamics 365. My current approach is putting it into an email body in JSON format, that is then extracted and further processed by Power Automate flow. ("Power Automate" is Microsoft's "low code" / "no code" product) Everything is working fine but...
I am cruising through a situation where I am my own backend and fronend developer. Let's say I have a basic backend API with some call /register/{area}. The {area} piece is dynamic and can change. Now I have a nice frontend application in angular that provides a selection of various area entries, Let's say they can be ...
I am trying to start using GitHub flow in my project. I like that it is simple and, more importantly, it encourages continuous delivery. However, there is one thing about this flow that I cannot understand: how do I test my changes? The 5th step of the official guide says: Once your pull request has been reviewed and ...
I'm developing a package for Laravel & Lumen in the same code base, but I encountered some problems. Well, in the beginning, I thought it could have the same code and work for both frameworks, however it had! But on the way of development it turned out; it didn’t work and I had to separate code into two branches. As yo...
I have been reading about system design and was going through this popular article - A Word on Scalability The author here says: An always-on service is said to be scalable if adding resources to facilitate redundancy does not result in a loss of performance. and then again: It requires applications and platforms to...
Context: I'm working on an embedded system with many small functional modules. The business logic within each module is made as simple as possible, but those modules generally need to gather bits of information from other places within the system to do their work. So far, to support unit testing and generally break de...
I am intending to come from the perspective of development choices, code reviews, and general testing against defined environments (Development, Test, Production, etc.). I will be using C# as the primary coding reference. What I am looking for: Is there anything with the following code change that could have been reco...
My question may sound very naïve to someone, but it is what it is. I have below scenario: Relational MySQL Database with BIGINT primary keys and foreign keys Spring boot as a backend (technology doesn't matter here) Angular as a frontend (again technology doesn't matter) This system is a large system and there are ma...
I need to write an algorithm to allocate x number of tasks to 2 processors per day. I know the following: Exact amount of time it will take to complete each task The exact amount of time available for each processor for the day I need to try and use the exact number of resources every day, or have as little extra pro...
When I want to execute some code under the condition that a variable has one of two (or more) values I can use the OR operator: if (var == x || var == y) { DoSomething(); } But I'm not sure whether I should do this directly, when var is a getXY() function, that might even include some expensive checks: // Is this ...
I have the following code public class MyCollection<T> { public void Add(T obj) { ... } public int Count { get; } } and the following unit test to check whether Add increases the Count property by one: [Fact] public void Add_ShouldIncreaseCount() { var collection = new MyCollection<int>(); var oldCoun...
Let’s say I have three files, all of which import a fairly large module. But I’ve divided them because they have different functions. Now each of the JavaScript files needs an initial statement like const a = require('./') Is this considered bad practice?
At the moment my code looks like this. I have simplified the UML so it does not contain unnecessary information. I have used abstract factory design pattern. My job is to create shapes. The problem is that these shapes are really complex to create. ShapeFactory has to know multiple different values to be able to creat...
I want to have a Python application - complete in itself - that allows the user to extend it via scripting (or a plugin model) in Python. But I want the script/plugin to have an isolated environment (within the same process) to run in. How do I do this? For concreteness - the app performs dynamic geometry visualizat...
I'm trying to write a new API that can support many devices. There will be at least 50k devices in the beginning that will connect to the server using an HTTP API on a daily basis to receive updates. The number of devices increases with time (with new installations). The devices need to contact the server once per day ...
I must store prices for various items on multiple dates. The table schema would look like this: CREATE TABLE date_wise_price ( item_code varchar, date date, price numeric(19,4) ) An alternate table schema for this could be to store prices date range-wise, which results in a smaller number of records stored...
I'm writing in C++, but this problem could apply to any other language. This post is a continuation of this question (I thought the question is different enough to fit a new post better. If I'm wrong, I'm happy to edit the old one). I have a graph of heterogeneous nodes. All the nodes derive from a base Node class that...
i am a lawyer and currently writing an essay about data access in ioT environments. I often stumble over the distinction between read access and write access. Could someone provide me with an example, preferably in an ioT, mobile app oder plattform context. (a little context for those who are interested: My argument is...
I have a given set S of strings, and a length l, and I am looking for the number of strings of length l that contains every string of S. A naive approach would be to generate every string of length l (I have a given alphabet), and for each check whether it contains every string of S. However, this is clearly very ineff...
TLDR How do you keep track of which version of which microservice is deployed in which environment? In Details Say your company has dozens of Microservices and 5 different environments (Dev, QA, Prod, ... ). Deployments of services are partially automatic and partially manually, depends on the different environments an...
I've recently joined a firm, where we are working with Progress 4GL from OpenEdge, release 11.6. As I have quite some experience in other programming environment, I'm really surprised by the extremely old-fashioned tools and technology (I started working with Delphi 4 in 1998, and this was already more modern than the ...
What's the difference between writing OO code that depends on internal state and writing a pure function that expects an argument that is a data structure of a specific type (and thus has internal data that could be different)? So function f(x) where x is a complex object that may be { foo: 'bar', biz: 'blah' } but wil...
I'm considering building a feature in a customer service application that allows users to build their own chatbots and use them to respond to customer input. I've worked with Dialogflow in the past, and I know how to build and leverage a single agent, but I want to know if it's possible to use Dialogflow in a feature t...
We have a REST API Get request which downloads a file from the server. This file needs to be updated whenever there is a latest version. Currently this is done by deleting the existing file and moving the latest file as new one. As the file is being held due to high traffic nature of service, deletion of file is not ha...
I'd like to start by saying that I'm new to DDD and I'm creating a hobby system to practice some concepts, so this question might be trivial, but not so much for me. I have the following scenario: I have a given user that should be able to add exercise to the system, so I have two models User and Exercise, and I have a...
Let's say I have a REST api endpoint that is getting a resource called a "purchasable" (an item that a user can purchase). Here is an example of what this might look like. Endpoint: GET /purchasables/253 Responds with: { "id": "253", "name": "T shirt", "price": 1234, "discounts": [ .... ] } ...
Take a simple example: string1 = "" string2 = "foo" string1 is empty or null, which is clear. But what about string2? I wouldn't call it "full". "Non-empty" or "non-null" works, but is there not a single word that unambiguously captures the meaning of "not empty" in the context of a string?
What are internal and external polymorphism? I understand what static and dynamic polymorphism means. How does static and dynamic polymorphism relate to internal and external polymorphism? These terms come up in one of the Robert C. Martins Clean code videos when he talks about design patterns and says "Template method...
I have a class class A { List<int> a; A() { this.a = []; } void add(int x) { a.append(x) } List<int> display() { return a; } } This is a simple class I want to write in a TDD approach. my question is how do you write the test for the display() since the add() need to be called to make the te...
Recently, I've been studying Clean Architecture and I have some doubts. I want to make a REST API that adheres to this architecture. To do that, I define my entities, use-cases, etc. For each endpoint, I use a different controller that calls for a use-case. My problem is that for all examples of controllers that I have...
This problem arises in the context of a web application. When we send a request from front-end to back-end, we must map the data, e.g. in post request: { something : this.something } When we receive it, we must map it to a .new() method like some_class.new(something = input['something']) Also, someone must make the .n...
I have a new site that allows you to play sounds of letters on click. Each letter produces a separate sound. I went from roughly 500kb for .wav files to around 30kb for each sound file. That's a lot to load for each sound (200 sounds so far). Can we optimize this for mobile browsers? Should I combine all sounds into a ...