instruction
stringlengths
34
36.1k
I am pondering moving some parts of the system I work on to a monorepo. The structure I have now is something like: +- Project 1 +- pom.xml | +- Jenkinsfile | +- Dockerfile +- Project 2 +- pom.xml | +- Jenkinsfile | +- Dockerfile ... +- pom.xml (parent) +- Jenkinsfile What I...
On a C++ project I got an idea to mix some compile time macro with std::optional to do something like : #include <optional> struct Foobar { std::optional<int> foo; std::optional<int> bar; }; int main() { Foobar foobar; #ifndef DISABLE_FOO foobar.foo = 42; #endif // DISABLE_FOO #ifndef DISA...
I want to write an application where I would delegate certain functionalities to 3rd party libraries. To make sure the code remains modular, I want to put these libraries behind an interface so I can swap out the underlying implementation when needed, or even use multiple different implementations simultaneously. Speci...
I need something clarified. I have been having a discussion with someone and we have conflicting arguments. Hence, I came here to ask looking for your insights. Say we have to implement our own stack class and assume we are using arrays to implement it. Say we can use ArrayList class from Java. And the stack has a size...
I'm currently reading Code Complete by Steve McConnell. In section 12.6, Enumerated Types, he says that we can define first and last entries like limits: Define the first and last entries of an enumeration for use as loop limits Defining the first and last elements in an enumeration to be Color_First, Color_Last, Cou...
I've been grappling with this for a while and figured I would post here to get input. I am a full stack engineer. I work on both front end and back end apps, where sometimes I have to create new microservices, or sometimes I need to create new front end clients to already-existing microservices. The front ends of these...
I am working with a coworker on a project that uses Inductive Automation software. If you don't know what it is, all you need to know is it provides a drag-and-drop GUI designer (based in java swing) and lets you write jython 2.5 or jython 2.7 (depending on the version) at different extension points of components. Pr...
Imagine a program that designs plates with geometric cutouts. You start with a rectangular plate. A plate can have one or more rectangular depressions carved out of it. Each of these can have one or more circular holes cut out of it. I have attached an image with a few sample plates to illustrate what I'm talking about...
I have seen some Bounded Context examples to learn DDD. In those examples, the User Access bounded context (register, login, authorization...) is considered a generic bounded context and could be a shared kernel. I think it's true. It's generic because, without it, the application couldn't work, and we could use the ex...
More specifically this applies only to resources which have asynchronous dependencies themselves (but I think that's majority of them). Concrete example: class Foo : IAsyncDisposable { public ValueTask DisposeAsync { ... } } class Bar : IAsyncDisposable { Foo _foo; public Bar(Foo foo) { _foo =...
I have a function to fetch data from remote API and store it in local database. Its logic is: Is network available, if yes proceed to next step, if no show error massage. Is app launched for first time, if yes then fetch data from API and store it in local database, if no proceed then proceed to next step. Is the da...
In Python, I have a class C which embeds objects from classes A and B. Is it considered good practice to creates shortcuts from the properties of embedded objects of classes A and B as attributes of container class C? The goal is to create a simpler interface in class C, abstracting the implementation details of classe...
I was reading chapter 1 of the book Embedded Systems with ARM Cortex-M Microcontrollers in Assembly Language and C. (3rd Edition, June 2018) I think the figure 1-6 is incorrect. It says that "Data memory and instruction memory are in the same memory address space in Harvard Architecture in many embedded systems." But i...
I have three bounded contexts: Users (generic subdomain), Groups (supporting subdomain) and Events (core domain). Basically users can create/join groups, create events within those groups, and sign up for events within group. This is for educational purposes, probably Users and Groups should be merged into one context....
As per Robert C. Martin in Clean Architecture, he gives a simple UML diagram to illustrate Dependency Inversion. To put it simply, HL1 initially referred to ML1 without interface to invoke F() directly, where the source code dependency was in the same direction as the flow of control between HL1 and ML1. However, it's ...
I will use the typical e-commerce system as an example of my problem here. The e-commerce system has bounded contexts like Sales, Shipping, Identity and Access. The Sales could be a core bounded context. The Shipping is a supporting bounded context. And the Identity and Access is a generic bounded context. The core bou...
I am tasked with designing an API for a car registration service. I don't have all the details yet, but we will receive requests from car dealers via API that my client will then process and forward to the government agency. It's a service to reduce bureaucratic workload for the car dealers. Those dealers are all using...
How could I improve my coding skills aka skills in coding while being in a job? My job is mainly coding and so, my coding should be better and better over time. But the struggle is: There are always deadlines, so there is, you can say, "no time" to improve the coding as it's mainly about getting the job done asap. I ha...
I'm writing a Java program with a custom event manager, which is of course the observer pattern. Should the calls to add event listeners/handlers be in the classes that listens/handles the events such as in their constructor, or outside them such as near the code that calls their constructor? For example, say there's ...
I'd like some insight/heuristics on how to tackle a specific kind of situation. Entity A, B have a parent child relationship with Entity C. Entity A creation is done thru a POST /createA API in Microservice1 and this microservice has APIs to update, edit and delete an instance of A as well. Entity C create is done thru...
I'm building a RESTful web api using Spring Microservices. I am following the Controller/Service/Repository Structure. Where can I find some guidelines on what the responsibility of each class should be? For example, say I'm implementing the following controller: @RestController @RequestMapping(value="v1/license") publ...
We have a simple POST / PUT that requires that some of the body data matches an organization id that is contained in the JWT. If the data doesn't match, that is clearly a 401 but wondering about an appropriate response if the data is simply missing? 400 or 401? Fundamentally, is missing data needed to validate security...
Assuming I have the following struct (just an example) struct string{ int len; char*str; } And I have the function int init_str(struct string*s, int len); which will perform s->len=len; s->str=malloc(len*sizeof(char)) And then I have the function int do_something(struct string*s, ...) which will assume s->s...
I am working on an algorithm that optimizes utilitization of a vehicle. What I have is a list of paths the vehicle is planned to take and between which times (time windows) it has to be at a certain location. I can also calculate the time it takes to get from one location to the next, but I have to take into account th...
So I am pulling data (list of JSON) from an API and want to parse it into Python objects. However the JSON objects of my list returned from my API need to be transformed a bit to fit into my object. I don't know if this transformation should happen inside of the __init__ function or outside of the object. Data pulled f...
I am composing a library for Discrete-Event Simulation of vehicle traffic. Vehicles are modelled as agents, while the network is modelled as a set of interconnected edges and nodes (a bidirectional graph of locations). At some point, vehicles will have to queue up on some nodes/edges, such as, for example, traffic ligh...
I have some REST API microservices (powered mainly with Java / Spring Boot) that communicate with other synchronously and I found out that is a bad practice since they are highly coupled. An example AccountAPI -> PersonAPI (create person) -> if personCreated then call NotificationAPI -> if notific...
Imagine a simple data class: @dataclass class Settings: m: int s: str old = Settings(m=10, s="ten") It feels normal to write new = old.replace(m=1), but we have to write new = replace(old, m=1). It feels so normal that I see people adding a member replace(self, **kwargs) to their dataclass types. I see a single ...
This question is mainly about readability and understanding of the code. Im am also in the process of creating a SCSS framework like Compass and Bourbon. I struggle to write SCSS because I like to see my own code as clean and reusable as possible. I don't have this issue when writing code for a real programmming langua...
Requirements I'm building a system with the following requirements. An Invoice can be paid using multiple Payments (e.g a customer pays the invoice in 2 installments) A Payment can be allocated to multiple Invoices (e.g. a customer pays once for multiple invoices issued to them) I other words, there is a a many-to-ma...
I want to start using Refit, it is a great library, but I'm having some hard time to keep the project structure clean because the library is at the same time the abstraction(interface) and the implementation(just consume it). Based on either of these templates for clean architecture: https://github.com/jasontaylordev/C...
I am very new to the Java world (c# dev) and I have as asked the requirement to store some arrays of byte that should be indexed by a string and I have to keep the initial order of the collection. So I was thinking I should use something like : TreeMap<String, byte[]> but is it the right collection to use? I have read...
I was wondering what is the best approach for a Data visualisation application for WPF and MVVM The key points are: The data is loaded, or needs just a little preparation such as pulling out particular set of data from the underlying structure. The library for the data visualisation in WPF can change in the future, ba...
In the book Patterns, Principles, and Practices of Domain-Driven Design, chapter 16, entities, Avoid the State Pattern; Use Explicit Modeling has brought the great idea of domain modeling to my life. It's easy to implement this idea with Entity. But with Aggregate Root, I find it's hard to implement. In DDD, Aggregate ...
We have following class: class ProcessStore { ConcurrentDictionary<int, MyDisposableClass> _processes = new(); bool _disposed; void Store(int Id) { if(_disposed) { throw; } var mdc = new MyDisposableClass(); _requests.Add(Id, mdc); } void Dispose() { if(_disposed) ...
I usually instantiate arrays inline, because I think it's cleaner. But I've seen a lot of people instantiating them when they're first needed. Is there any reason to do so, except for style? This question is not only for arrays but in general. (Arrays, Objects, Primitives, ...) private static List<IUndoable> undoables ...
I'm creating an API for a web service. There are a couple of endpoints in this API that require some time (lets say +5min) to compute, so I'm creating a prefetch system that will call in the background this endpoints every certain period of time and cache the results, when users call this endpoints, they will get the c...
I was looking into a datasheet of a Real Time Clock (RTC) with a temperature sensor MAX31328. (You can find the datasheet easily). I'd like to convert the raw binary value into decimal format. I have no problem with positive value but I'm not sure regarding negative especially if there is a fraction. So they say that t...
Consider a case, in which a class needs an attribute only in a very limited context. (For example, only during initialization, which is handled by a factory) I do not want to include such an attribute in the class, in order to keep it as simple as possible. In the concrete example, I have a sorted list of tree nodes wi...
I have implemented the cows and bulls game in C++. The code: #include <cstdio> #include <cstdlib> #include <ctime> struct DigitMatches { int matches_in_right_positions; int matches_in_wrong_positions; }; struct MatchesCounterData { int generated_number_left_digits[10]; int guess_number_left_digits[10...
I'm studying to develop an order management system and order dispatch for the couriers, this is a personal project, for study purposes. Some important points about the deliverymen, they are bikers and they are on the street, moving, imagine something like Uber drivers, so it becomes necessary to receive their geolocati...
We are using GitHub as our source code repository along with Visual Studio. We are going to start to use the GitFlow branching model, so a new feature request will be branched off and worked on in isolation. This feature could be worked on by a single developer or multiple developers, e.g. UI, API. However, we also wan...
I don't know if this is the right place to ask more of a "philosophical" question. The more I code in Java, the more I have to bear with Comparable<T>. And the more I bear with this interface, the more my code gets verbose, maybe also cryptic. I'll take my last occurrence of the problem as an example: list.get(j).compa...
I've been using the braces on a new line convention for my java project: public String class() { something; { However I have quite a few methods, like getters, that could be written on one line like: public String getOrderNo(){ return this.orderNo; } So far I have been correcting this so as everything is in the s...
So, I have a whole system built as microservices.On a service level, I'm utilizing Hexagonal Architecture with lightweight DDD (no events, aggregators etc.) I have a service that fetches Users via their Tokens, and then I have to fetch their Permissions accordingly. I'm trying to figure out how to fetch data via EF, wi...
I have used the state pattern for my web application where a user can be in one of three states: activated, required_activation and suspended. I have created 3 states classes as given below (source is in PHP) and a variable named state holds the instance of a state out of 3. class User { private UserState $state; ...
Event Storming is a great method to understand the business processes. Scenario (Use Case Specification) also describes the business process. They both do one thing. But when documenting, the Event Storming is somehow not be used often in my office, but scenario. So as the question, do I need to write scenarios if I us...
Let's say I have a class modeling some kind of object, for example a graph (in the graph theory sense). I will have the graph structure and data inside the class, but what about other more complex behaviors? For example, I want to create a function that transforms the graph in a specific way, or that dumps the graph in...
As title says, I'm currently working on an alaysis model for a little website similar to Reddit for academic purposes. I have one use cases written like this (They're not in English so they may not have been translated accurately): Name: View Section The user opens the page related to a specific section The system dis...
I'm trying to implement the Command Processor pattern using MVVM for WPF. The Command Processor pattern that I'm roughly following is the one described in the book Pattern-Oriented Software Architecture (Volume 1): The Command Processor design pattern separates the request for a service from its execution. A command p...
I wasn't sure whether to post this on StackOverflow or here. Let me know if you think it belongs on StackOverflow. I have an application that will run semi-persistently, i.e. all the time. The application interacts with a financial service through a websocket connection (we are the client-side). We keep the connection ...
I'm working on a Node project (in typescript) that features a variation of clean architecture. I have a pretty clear understanding of the different layers of an application and how they depend on each other. What is not clear to me is where definitions for interfaces and models should exist (say for a repository, a dom...
My Software Engineering teacher just said: "Avoid using continue and break, always make it work without using these". Is there a problem with these instructions? I would say he didn't say something so coherent, but maybe I don't know something about it?
I'm starting a project using Azure as our serverless framework. The project consists of two separate frontends applications that must talk to some backend services, some will be made by me and others by other teams. I plan to implement a BFF between the frontends and the other domain services. My question is regarding ...
I'm using a third party CRM application which allows you to build web forms using drag and drop widgets and the ability to add javascript code to manipulate those widgets. I need to build a form to take payments using another third party payment gateway. The basic process is as follows: customer selects products on th...
So, I'm working on a specific solution that requires the creation of jobs that should run at a specific time, and complete a certain action. We've built a GUI where the client inputs params required for that action, and the time when that job should be started. When that happens, there should be an action in the backgr...
I'm currently reading "Code Complete" by Steve McConnell. In section 12.9 "Creating Your Own Types (Type Aliasing)", in the pre-last paragraph of "Guidelines for Creating Your Own Types" part there are such words: For example, you can define a type INT32 and use it instead of int, or a type LONG64 instead of long. Ori...
I've used the wellknown Dispose Pattern in .NET several times as described in the official docs. Now I have the following, rather simplified code: public class FirstForeignDependency : IDisposable { // all the things from another library that I want to use in my code } public class SecondForeignDependency : IDispo...
Unicode has the following APL characters that don't seem to be used in modern APL. What functions or operators did they represent? Are they still supported for backwards compatibility, but undocumented? I have also seen some of these in code that's no longer in use. Quad circle ⌼ Del tilde ⍫ Quad jot ⌻ Circle jot ⌾ Qu...
I've been trying to get a better understanding of OOP (I'm not the biggest fan of it, but I still want to understand it). One of the core principles of OOP is encapsulation - you're supposed to subdivide your state between different classes and make it so the only way to work with that state is via the public functions...
My understanding of a "browser" as a means of consuming software over the web: Browsers isolate web application execution to an environment which greatly reduces end user vulnerability. Browsers provide an approximately standard environment which developers can target with their software. My understanding of containe...
I am trying to design a simple Soccer game. To keep things simple, I am having a SoccerField to represent the field and a Player class to represent an individual. A SoccerField will contain a list of players. A Player would belong to a SoccerField (Even though a player can exist by itself, during a game, a player will ...
So I'm designing the backend of a platform that often calls other 3rd party APIs. The issues I've noticed were latency issues (sometimes the calls were fast, others a bit slow >15s) and I'm wondering how to handle that. I mostly get resources (and download them every single time). Is there a better practice to have bet...
Simple question, I'm asking here as I don't exactly know how to phrase this question correctly, I'm interested in knowing how SMS providers work, e.g how do they send you that message? who does it go through? how would you send an SMS without a middle man like twilio (without using a sim card)?
I am currently working on a project where there is a class ContactMonitoringJob a Quartz IJob class​ which in brief keeps pulling from a database and checks if any new changes have been introduced like a new contact being added or disabled for example, then generates "Actions" and persists them to the database for furt...
Assume you have a small set of suitable programming languages (e.g., Python, C++, Julia), a clearly defined task (development of software services in the context of computational sciences), and a team of stakeholders with whom you'd like to pick the "most appropriate" language. Assume that the pros and cons of each lan...
In Python, consider a function like the following: def main(*args): value1 = pure_function1(*args) if condition(value1): value = side_effect1(value1) if value: value2 = pure_function2(value) side_effect2(value2) else: value3 = pure_function3(value) ...
When writing platform independent software in C++, can I nowadays safely1 assume that a byte has a size of 8 bits? Or do I have to calculate it like this, for example: #include <climits> std::size_t byteSize = sizeof(char) * CHAR_BIT; 1 In the sense it is standardized or otherwise guaranteed.
I need to think of a way to model how one thing is more "changy" than another. Say I need to index a news website's different news sections with some web crawler. I want to prioritise indexing those sections (e.g. live news or sports) that receive more news items than those that don't (e.g. health or culture). A crude ...
Scrum training usually assumes your company's been contracted to produce software for a client. For example, a business owner might hire your company to develop an application for internal business use (like accounting or submitting expense reports) But what if that's not what your company does? Specifically, what if y...
Objective I have to create way to use the same users to connect to multiple application, and i am thinking about how to do it and how to share the data between the applications. Details Each application will have an REST API and an Angular Frontend. For now i thought about doing a application that will handle the conne...
I have a few different web front ends that I use ActiveX Data Objects and ADODB connections to query an Access Database on a network drive. Usually there's some JavaScript logic that helps build the queries or otherwise parses the returned data. There's no server involved and, for a myriad of reasons, I'm going to try ...
I currently have two applications where one is a landing page (built in react) and another is a web page that lets users explore data (Written in ASP.NET 4.7). I'm currently using resx files to handle translations for the .NET application and I'm using the intl npm package for translations for the react app. I'd like t...
In my event-driven architecture I have a situation where once an event is raised validation needs to occur and I'm wondering how to proceed to the next step in the process if I don't know how many validators there might be. This situation occurs because the users of the software can dynamically extend the domain model ...
I've read that a key portion of a RESTful interface is that the client doesn't have to know what options are available before they hit the page/access the resource. The client starts with the initial URI, and gets enough information to do whatever the application allows them to do afterwards. In the context of manipula...
I would like to make use of a external library to parse the core domain entities. Doing this in a naive way it would look like the following: import { z } from 'zod'; const Audience = z.object({ name: z.string(), id: z.string(), }); type Audience = z.infer<typeof Audience>; const buildMakeAudience = ({ getShortI...
Okay, so, I'm working on an AuthService for my microservices system. I'm putting plenty of logic around single instance of User inside of it itself, just so I can avoid repeating code, breaking SRP or anemic domain models. .. but now I've stumbled upon a certain problem, to be precise: I have this method inside User en...
Let's say we have a simple application that uses a popular approach as Controller -> Service -> Repository pattern under a framework. We would like to write integration tests and start from Controller. Any integration tests against a controller component will eventually run service component instances and my question i...
It seems that design patterns are actually linked to some C++ or Java object models (e.g. they might not fit to Ocaml objects, or to Common Lisp Object System). Or at least tied to a specific programming language (e.g. Common Lisp and C probably have different design patterns?) or some application (e.g. Elephant in Com...
I have my system which receives data from another service and then I show the data to my users. I'd like to store an ID or a link to the data. Then UI will go for the data using the ID/link. If we were to use HATEOAS, we'd go with links, so: Poll the data from that service Store links to the resources When UI opens - ...
How do compilers parse complex data types names like function pointers. The type has to be somehow put into the AST or it has to be processed during parsing. What are the pros and cons of different methods of parsing complex data types? What methods are most commonly used? These are the ways I could think of: Do type ...
How can I validate that the feature (user-story) I created meets the requirement of the end users / stakeholders?
I am trying to implement a layered architecture consisting of; Controller, Service, Repository, Entity. Each module has at least some of the above layers. I am often finding that modules need to share some functionality, for example when creating a BlogPost I may need information about the Account, currently I am injec...
TL;DR: How do you manage the complex development toolchain in different (embedded) projects? In our company we are discussing the toolchain setups in different development teams and how to work together in the future. It is important, that for each project the setup is fixed (e.g. specific versions of all tools like py...
I'm currently reading "Code Complete" by Steve McConnell. In section 13.3 "Global data" in last paragraph "Don’t pretend you’re not using global data by putting all your data into a monster object and passing it everywhere", he said: Putting everything into one huge object might satisfy the letter of the law by avoidi...
I have a library that I am distributing on maven in the new version I will be changing the exceptions some methods are throwing. Is this considered a breaking change? If this is the only change in the new version, should I increment the major version (I am using SemVer 2)?
I would like to display something on my desktop by tapping a button on my mobile app. For example, there is a "show cat" button on my mobile app. When I tap that button, a new window should be opened and display a cat picture on my desktop. The scenario is a bit similar to Zoom. The desktop application is idle (from th...
We have 2 applications that are part of our product, one is written in native C++ and lives in its own solution, and the other is a C# application in its own solution. Both solutions are in the same repository, and we are planning to introduce a database that both of these solutions will be using. There is a discussion...
I've been refactoring guard statements for my project to simply use a custom Ensure class with 2 methods. Some methods require multiple null checks and I implemented a guard method that simply accepts a list. This method will call the singular guard check for each value given. However I don't seem to find any other exa...
I'm attempting to create a project to increase and enhance my coding skills, and I've lately migrated React to Nextjs. I've noticed that NextJs' main point or strength is rendering; Could someone please explain the difference between Static Generation and Server Side Rendering and how they can be used in an e-commerce ...
I have a database that keeps a temperature readouts, which are being added - let's say - every minute: +----+---------------------+-------------+-----------+ | id | timestamp | temperature | sensor_id | +----+---------------------+-------------+-----------+ | 1 | 2021-12-14 10:10:00 | 68.2 | 1...
I'm writing a parser for a markup language in haskell, and a finite state machine fell out of my ideal API. I have code that looks a bit like this: Token = BoldWord String | Word String | ParagraphBreak | HorizontalRule -- etc, etc State = Accept Token State | LineStart | ParagraphStart | WordStart ...
Edit #1 I believe that I misrepresented my intent when writing this question by focusing too much on the issues that have arisen from our misuse/misunderstanding of locks. I am making this edit to try to clear my goal up. I am looking to gain advice on whether or not performing some sort of static analysis and building...
I wonder how to design a good plugin architecture in C++/Qt. The main concern I have is about dependency injection vs globals when it comes to the core components. Plugins should have access to several core functionalities like registering a socket listener, modifiying the tray menu, have acces to the main window, star...
I recently joined a new project that is written in java. The project has been worked on for a few years by different developers, so there are many different code styles across different classes, and I'd like to consolidate this project to a singular design, hopefully to provide a little bit of optimization and/or read...
I need some help with my authentication design. Happy to share any code as needed... Overview I have implemented the Google Sign-in (new web implementation here) button in my client web application. The web app prompts the user to authenticate through google, revives a JWT token from google, POST to a golang web server...
I have two Visitor classes in my code Visitor1 and Visitor2 that execute functions on the classes ElementA and ElementB (both implement the interface Visitable that defines accept(Visitor)). I do not want to support calling visit from Visitor1 on ElementB. I thought of two different ways: Throw an exception when Visit...
I'm dealing with an application that does the following: we have a microservice running on EKS called by jobs that pull XML data off an external system. The data volume can be fairly large (700MB-1GB at times). We cannot control the volume of data, there's no pagination or way to pull a delta. the data gets written to...
I have a memory pool class that manages memory objects of fixed sizes, a bit like a primitive malloc() that can only return memory blocks of a few predefined sizes and unlike malloc() is guaranteed to always be O(1), which makes it suitable for time critical code. To prevent that the pool consumes too much memory, the ...
I have a classical one producer - multiple consumers queue, each item can be processed independently. On rare occasions (<1%) there can be multiple queue items related to the same object the consumer is processing. It is perfectly fine to have that with the only constraint being that the object (potentially referenced ...