instruction
stringlengths
34
36.1k
In most build systems and development environments, there tends to be exactly one dependency tree per project - each module depends on a constant set of other modules to do its job, with the only leniency being different backwards-compatible versions of the same module. I'm currently going through several circles of he...
I'm creating a prototype mobile app that will store data locally in an sqLite database and also on the cloud (CloudKit for now). The cloud storage uses a certain way of storing the data, and sqlite uses another. my class looks like this: public class MyDataClass { public int ID; public string Name; ...
Currently reading Steve McConnell "Code complete". "General issues in using variables" chapter, "Binding time" section. He says about variable's binding time in such languages as C++ and Java, that have phases like compiling. Coding time (use of magic numbers) Compile time (use of a named constant) Load time (reading ...
I have a class, which uses a timer, to do some time-dependent things. Now, I do create the timer inside the class: class MyClass { public: Myclass(arg1, arg2, ...) :m_timer(new Timer(delay)) ... private: Timer* m_timer; ... } The timer has a few functions, like isRunning(), isExpired(), reset() However, when...
I have a C#-based system that works relatively well. It reads data from kafka, processes the data and then writes it out to MSSQL. The kafka topic has been partitioned into 10 partitions - and after 2 years, the team is considering increasing the number of partitions because the cluster is showing signs of not managing...
Why most frameworks (at least in PHP. I suppose in other languages, too) use the environment variables to set a corresponding configuration parameter and then access the value through a config object/function (e.g config('mysql.passqord') or $config->get('mysql.password') ). I won't argue on whether environment variab...
I'm having a hard time wrapping my head around the use of async/await and regular sync function calls in JavaScript. Let's say I have two functions: Function 1: async function doSomething() { const result = await doExpensiveOperation() const result2 = await doAnotherExpensiveOperation() return { result, res...
This is an example of a typical function from a project I used to work on. I have troubling grasping unit testing because if I want to test this function properly, I would have to write about 50-100 unit tests to cover most of the possible code paths to ensure all the logic works correctly, and this is just a very smal...
After my scrum certification, I had a chance to be selected as the team lead of a small project in my company. The goals is to made a choice on the new SAP the company will use. We are a team of 6 persons with cross skills. But I don't know how to handle that. The most example that I saw was how to do that for IT proje...
Let's suppose that I have two bounded contexts: A and B. In books I'm reading authors will only write "Context A maps into Microservice A". Now I'm working on a project (university assignment) in which I have one big context (A) that can (in my opinion) include a sub-context (B), as they both have the "same vision of t...
I want to build a chat application with a stateless server as backend. Users have an online and offline status. When a user connects to the server, the server marks that user as online. Now imagine a user disconnects because his battery died. The user can not notify the server he is going offline. How would a stateless...
In an Model-View-Controller (MVC) design pattern, What goes where? What code goes to model and to controller? I know (do I?) that business logic should be define in a model, but a lot of example I find on the internet only use the model to define the data. Take Microsoft's example of model for instance, it only writes ...
In Agile software development, when is a story or task considered blocked? Does the task need to be in progress? Or is the fact that a dependency is not completed, enough, for a task to be considered blocked? For example, the UI team needs an API from the backend in order to complete a task. If the UI team can work on ...
Take the following class, without [PublicAPI] attribute, ReSharper says that all public members can be made private. using System; using JetBrains.Annotations; namespace ObjMtl { // [PublicAPI] [NoReorder] public sealed class WavefrontMaterialColor { public float R; public float B; ...
I'm writing a CRUD app in Python that exposes web API. At first I wrote functions for communicating with DB and wrote tests for these functions. def crud(): # do something with db def test_crud(): crud() # check crud tables now have all required rows Then I wrote functions for API routes, which do some input...
My goal is to learn more about OOP patterns and use DRY principles. I am trying this for wrapping an os command that interacts with a database using classes: This works fine: import subprocess class Blah: command = '/usr/bin/database_exec ' def execute(self, action, user): self.action = acti...
I'm maintaining a small C library; let's call it libfoo. It has quite a few users (actually it's complicated - it's the main fork of a highly popular library which has been abandoned); and it sports a spiffy CMake-based build mechanism. My repo directory structure is: <root> | +--- src | | | + foo.h |...
Is it OK to create a variable which only purpose is to increase readability? Example: public class Example { private final HowLongCanARepositoryNameReallyBeRepository howLongCanARepositoryNameReallyBeRepository; public boolean method( final HowLongCanAMethodArgumentNameReallyBeArgument howLongCanAMethodArgumen...
The typical example, the e-commerce system. Let's say the Order is in the Sales bounded context. Every Order contains many OrderLine, which stores the ProductId. The Product is in the Product Catalog bounded context. Every Product has its own ProductId. I understand that the ProductId in Product Catalog bounded context...
I'm working on a project that has the purpose to execute tasks in intervals. The tasks and it's properties can be configured through the Configuration Website. The data is being stored in the Configuration Database. The Windows-Service loads all the data from the Configuration Database on startup and then executes the ...
This is Indirection according to Wikipedia Assign the responsibility to an intermediate object to mediate between other components or services so that they are not directly coupled. Controller seems to do this exactly, except that it is concerned with UI and Input events, while Indirection is more general. Am I wrong...
In Daily Coding Problem, Miller&Wu have the following problem : Given an array of integers, return a new array where each element in the new array is number of smaller elements to the right of that element in the original input array. Their suggested solution is (in python): import bisect def smaller_counts(lst): r...
When inter-communicating through http requests between Microservices it is quite easy to reply with error messages to users, you can just catch the error of a different Service and forward it to the user. But how does Error handling work when communicating through a message queue? For example, a user makes a request to...
There is an application of ours which has some experimental features. We want to enable it when user wants to enable. So they will change it in the UI and we are saving those to DB. So we added those settings in database as key value pairs. DB table is designed as follows. ----------------------------------------------...
As an example imagine I generate a UUID/GUID for an ID in a json file. { "25d01302-2558-4c44-bf9d-385b1cc51377": ["somevalues"] } is it ok or generally frowned upon to do something like { "25d01302-2558-4c44-bf9d-385b1cc51377": ["somevalue"], "25d013o3-2558-4c44-bf9d-385b1cc51377": ["someothervalue"] } the seco...
It seems best practice is to build the final artifact, in full, at the earliest stage. And then the stages that follow (testing, deployment) should use same artifact throughout, to protect against some sort of mismatch between what was tested, and what gets deployed. How do runtimes come to play here? My specific case ...
In our Jira board we might have 5 tickets for different API endpoints - for example: ListArticle GetArticle CreateArticle DeleteArticle When we create these new endpoints, there is some initial work that needs to take place to get our infrastructure ready for the endpoints. This only needs to be done once across all ...
So, I have the following two functions in THE SAME class: void start() { ... m_pRunnable = createRunnable( [spDiskManager = m_spDiskManager, path = m_path, &success = m_isFolderCreated]() { success = spDiskManager->createDirectory(path); }); m_spWorkThread->invokeWi...
I'm concerned with the practices on my team regarding following REST and HTTP verbs precisely. For example, when we hit a get endpoint for a resource/resources that doesn't exist, we return a 404. Shouldn't we return an empty list with a 200? I thought 404 was reserved for a URL that didn't exist. Does your organizatio...
I know that a lot of compilers use an assembler to compile to machine code, to make an executable (compiled program). Some people even made their own assemblers, or they just use an existing assembler, or they just transcompile to C, or they just use some other VM like JVM, or LLVM. What's the fastest and easiest way t...
Due to circumstances I'm now working in a small software company. We make e-mail marketing management software and serve some big customers as our national railways and a big bank. The software has been developed about 6 years ago by two guys, one who left, the other now leading architect. The problem starts with him. ...
The case is that I have a signup form for students where they can choose between different lessons in multiple rounds. Each lesson in each round has a defined available space. The total amount of space in each round is equal to the number of students which need to sign up. Students cannot pick the same lesson twice in ...
I have a code that reads a YAML file that consists of several parameters whose values are used throughout the code. For clarity, the YAML file has the following structure: PARAM_1: value_1 PARAM_2: value_2 PARAM_N: value_N These values are never changed after the YAML file is loaded into the program. When the YAML fil...
As a forewarning, this is for a school project with other school teammates, so my question is just for the sake of learning best practices. We are creating a recommendation system web app which currently consists of 3 services (react front-end, Flask server, postgres database), where the database we are using is just a...
Is there an equivalent to Banker's Algorithm but for project management? For example you have several teams with different tasks and there is a deadlock, how do you resolve and prevent these situations? (For example, team A must do task X and team B must do task Y, but to do Y team A needs to finish X and to do X team ...
Description is too long, but this is a pain point. I just want to understand whether this is also practice of Agile, if yes, how to overcome some of the issues mentioned below. Thank you. We are using agile scrum for our projects and we have 2 weeks sprints. At each sprint we are delivering "something". We have huge a...
I write a software which trades with crypto currency via big exchanges. Using the clean architecture approach I have defined some core entities, some business cases and then created an outer ring of adapters which implement my Marketplace interface. The function which retrieves the current spot price from the Kraken ex...
I'm a recovering perfectionist. According to my colleagues, I am also a good software engineer, but one of the feedback I have often received is that I tend to dive too deep too soon. Suppose I start working on a new feature that requires going into the code base of another team - I often end up trying to understand ho...
Exogenous exceptions are that kind of exception that are unavoidable because they are throwed outside of our system's pristine logic. A good practice is to throw wrapped exceptions in lower layers like the DAL. However, in my application i have a lot of filesystem access, and I came up with recursive functions, like th...
What is a good way to secure http communication between two backend services which are not hosted on the same network? One way might be to have a shared secret in both services but I feel like that is not secure. Is there a better way or an established standard?
What are the best practices when using global variables? Normally, the common answer to this is to avoid using global variables and use local variables, properties and arguments to pass data around. However, I'm working with a domain specific language that does not support these concepts. In the language I'm using, th...
I have 1-20 agents that issue requests over time with roughly ~50 in total in flight at any given time. Many of these requests are identical. The tasks are idempotent, but if two identical requests were to evaluate in parallel, the evaluation is still costly even though the final results could be stored in a thread saf...
I'm developing a system in which a ClassA object can have multiple ClassB and ClassC objects. And for store these objects in a relational DB model I create the following tables: This is a simplified example of the real system. My problem arises when I need to update ClassA objects because I need to check if the modif...
As part of a microservice-based system design, I'm struggling to decide where system configurations should reside in terms of domain ownership. For example, let's assume I'm designing a "store system" where for simplicity I want to discuss the following domains that have today 1 microservice for: Orders Inventory Now...
You have n lists, each serves as a global dictionary. Everything else is handled via IDs that represent the index in the appropriate list. Typically, this is some type of integer. However, trying to access index i in list A when it is meant for list B would result in nonsense at best or a crash at worst. While I can us...
As far as I understand, the best practice for programmatic access to the version of a Java application is to: Specify version via build system (e.g. in Gradle). Include the version string as a manifest attribute in the jar file. Access it in application source code via class java.util.jar.Manifest. Is there a good wa...
I am currently planning a movie recommendation application. Within this context, the user can fill out a form including different information (e.g. title, description, etc.). The new entry gets then saved to an external database. Amongst those fields, I also would like to include a category input where autocompletion s...
I am struggling to reconcile some good recommendations, relating to the microservice architecture and Agile and DevOps, that are mutually exclusive in my mind. On one side we have the recommendation that each microservice should have a small, two-pizza team that owns it (e.g. see "Service per team"). This is the model ...
As we know that RGB monitors requires separates signals for red, green, and blue components of the image but television monitors uses single composite signals. For this composite signal use YIQ color model. But don't understand what's the significance of Y, I, Q components? Can anybody explain just the intuition rather...
I see there are many user stories that only contain Story Acceptance Criteria Where to put the detailed requirements? Is that unnecessary?
I'm tinkering with the new streaming plugin provided with RabbitMQ, and researching how to implement event driven architectures in general. I noticed in the default configuration (maybe I have it configured wrong) if I have one app consisting of two consumers - and one producer produces 5,000 messages that both consume...
Current situation Right now I have a method like Data lookupData(Key id) { std::lock_guard<std::mutex> lock(m_mutex); auto it = m_dict.find(id); if(it == m_dict.end()) { return Data::Empty; } else { return it->second; } } Problem However I now have a situation where, i...
It is quite common to separate C++ code into cpp and hpp files and to define the hpp files as the interface of the code. Therefore, when you use the code as a library, you can expose the interface, but offer the rest as a compiled library. It also allows to separate different components of the code in a way that one co...
I'm studying use case and activity diagrams and I get confused about the difference between activity diagram and the normal flow specified in the use case specification table, aren't both of them specify the flow of our system ?
I have a method, that takes a list of students, and returns the student with the best score. Part of me wants to call it Student getBestStudent(List<Student> students), but I think that get refers to the methods, that make a relatively heavy database/service calls. Here I do just simple filtering. Another part of me wa...
We are working on a .NET desktop application written in C# and WPF, that communicates with a REST API server. The software has a layered design and consists of multiple projects. One project for the presentation and ViewModels (we follow the MVVM pattern). One project for the domain layer. The business logic like serv...
I'm currently developing message imap-based module in crm app and i'm trying to connect dots using ddd principals. I've started with three main entities, all bound under Account Aggregate: Account - Email account. Has multiple Folders. Folder - Folder in email account (ex. Inbox, Sent, Draft). Has multiple Messages. M...
I tend to create a variable whenever I need an uncircumstantially same value as to that of an earlier value more than once (the values are not happening to be the same by chance rather they actually have to be the same). I think of them as the integration variables, as their particular value may have of no importance b...
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...