instruction
stringlengths
34
36.1k
I have been using an external library for a while now. Unfortunately, it stopped receiving updates, and has since been adopted into my codebase. The issue is the library was poorly documented in the first place. It was picked out of necessity and because it was the only option. Now my question is, how should I document...
We have the following system: References that identify a product and have a family which identifies a group in which the reference belongs. Families that are a way to group references, for example, if we sell electronics we could have a family to identify the keyboards, another to identify the screens and so on. Rates ...
Overview Today we have a monolithic service that deals with realtime time data. The monolithic are composed by follow stack: Django + AuroraDB Cluster (Postgres AWS) + Varnish cache and cloudfront at the edge. This service is fed by a third part data provider, which in peak times, provider 5k message/minute, with this,...
I'm aware that there are a few accepted implementations of how signed integers are stored, specifically negative values. There's two's complement, one's complement, and sign/magnitude. For Visual C++, which one is implemented? I am a bit uncertain. I've always thought that it was sign/magnitude implementation. Is this ...
I'm working with a basic REST API, through user interaction on the UI, the JSON object is built up, including Arrays and a POST is sent to an endpoint using this object as the request body. For example: "data": { "id": "424", "types": [ "01", "02" ] } So this data object is part of the body that will be sent ...
In my town, recently a delivery company has been opened (think DoorDash but on a much smaller scale and only doing local deliveries). Now what really confuses me is that they charge pennies for each delivery and they offer a quite smooth delivery tracking feature. Now, I know for a fact that they are using Google’s API...
How often should we do git comit --amend --date=now [target] especially when editing a commit while rebasing or doing a fixup? If the answer is always, is it OK to let existing commits that follow the amended commit keep their author dates which is now earlier than the amended one? Let's presume the commits aren't di...
I'm currently trying to update the linux kernel used in a xilinx SoC, my company has an internal repo/fork of xilinx open source linux with a bunch of kernel drivers for our custom hardware & kernel config stuff. Our current fork is based on xlnx_rebase_v5.4 & we're trying to upgrade to xlnx_rebase_v5.15_LTS. So far, t...
I'm trying to find a way to achieve abstraction with the lowest possible overhead. This is for an embedded system (Cortex-M4), I use the latest gcc compiler arm-none-eabi. Let's say we have a pure abstract classes containing only pure virtual functions. class Animal { virtual void sound() = 0; virtual void eat(...
I am developing a REST API where users can request data from one or more sensors, using the following scheme: GET /sensors - returns a list of available sensors GET /sensors/<sensor_ids>/data - returns data for one or more sensors, specified by sensor_ids But the client also wants users to be able to send a request wi...
So a lot of the time my utils end up with a structure that mirrors the core library. I might end up writing a multiline version of str.center, an itertools-y function that returns the first or last element of an iterator that matches a predicate, a datetime function that returns the end of the current day, maybe a cust...
┌────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ │ │ ┌──────────────────────────────────────────────────────────────────────────────────────────────┐ │ │ │ ...
I was asked to refactor some C++ code recently for the purposes of increasing unit testing coverage. The problem was that the code was tightly coupled on one compilation unit, so we had the equivalent of this: beatles.h class beatles { ... } beatles.cpp class john { ... } class paul { ... } class ringo { ... } class g...
I am a noob in design principles and design patterns, this might seem like a very silly question. Some classes in my code have the following structure (image linked): https://ibb.co/nrp1t2g As you can see, I have an interface implemented by 3 classes, and each class overrides the interface method execute(string, long, ...
The CPython implementation seems to have the same modules written both in C (e.g., datetime in .c) and also in .py for the same module (e.g., datetime in .py). My question is which version is used when I use datetime in my .py file when using the CPython interpreter? And why are there two module versions in the first p...
Suppose I have a web application that processes a request as follows. A user fills in a form and submits it. (e.g., to register as a new user for my application) The request is passed to the appropriate view/controller in the backend of my application. (e.g., a request CREATE /user is passed on to a UserController) Th...
I face some situations similar to the following simplified one: @Component class ServiceOne { @Autowired ServiceTwo two; void act() { ... two.a(); ... } } @Component class ServiceTwo { // suppose it has a LOT of methods void a() { ... } void b() { ... } void c() { ....
Goal I'm working on libraries published as nuget packages and I would like the version of those packages to update automatically based on the changes I make. In other words, I would like something that automatically adjusts the major, minor, and patch numbers based on the changes of the API surface of the library. This...
Just for the example: I have a system which needs to fetch social media timeline on a specific time interval based on user preferences. Let's say we have user A, B, C, and so on. Let's say again we have time interval options from every 5 minutes to every 60 minutes, a user can choose the interval as they want. User A ...
In a web app I'm writing, a singed-in user is recognized by their cookie containing a session identifier. That session id has sixty-four bits of entropy, so I believe brute-force attacks are impossible in practice. However, not signing it to prevent tampering still feels less secure than it ought to be. I'd also like t...
Despite checked exceptions being generally bad practice and anti-pattern, I find one feature very useful: having list of checked exceptions part of function signature. Checked exceptions are "business exceptions", something that requires from the source code or user to do something to recover and continue normal functi...
There was this question on my mock and I am just really confused about it. I tried to learn about class diagrams in more detail but there was no information that explained to the detail of the complexity of this class diagram, could someone please explain why the correct options for this question are correct and why th...
What exactly is the purpose of React JS? I've heard a few things, like: It updates the page without refreshing. It is modular and can reduce redundant coding. It is faster than updating the DOM object with JS. The only one I can probably agree with is the last one. I don't understand why React JS is so important for ...
If I have two APIs that I'm considering to be two separate micro-services, each with their own database, how would I handle worker processes for each of these micro-services? For example, if each API would launch a long running task that needs to be handed off to a worker, should these two APIs share the same worker po...
Maybe a repeated question, so you all could link me if you know an older answer. I'm creating a small web application, using MVC, for a volunteer project that I participate. Right now I'm doing a feature that shows volunteers and their respective students. A volunteer could teach many students and a student is mentored...
Suppose I have a program that returns data from an API. If its cache of the data is too old, the program downloads more data from the API, caches it, and outputs the new data. Else, the program outputs the cached data. Should the function that downloads the data be separate from the function that caches the data? Shoul...
I am building a cross-platform application and have planned to use Blazor. I have made similar applications in the past but using ASP.Net Core for the back-end and Angular for the front-end. I always had a strong separation between the front and back-end in those applications, which is always good. The back-end was wri...
I was reading about LSP (Liskov Substitution Principle) in a book called Clean Architecture: A Craftsman's Guide to Software Structure and Design. I have a question regarding how this would be implemented in C++. On page 95, there is a figure explaining LSP using a simple example: My interpretation of the figure in C+...
We have recently started using Agile methodology implemented with Jira. We are struggling to decide how best to arrange Sprints, Epics, Stories, etc when working across different departments. For example, let's say we're going to make 'Feature A'. At a basic level, sufficient for this question, 'Feature A' needs to go ...
I am currently building a web based solution based on an application used in my organization. The application have an integration (SOAP-based API). To keep things simple, I want to build a analytics dashboard based on the data available in the application. My question here is: Do I save the data from the application, w...
I'm writing a Hardware Abstraction Layer (HAL) to abstract a hardware peripheral on an mcu. The driver peripheral looks like this. Driver module. Includes hal.h void drv_init(void); void drv_set(int x); int drv_get(void); void ISR_Handler(void); // impmenets hal_ functions ... Driver modules includes hal.h implements ...
I am trying to implement code for switching states of a couple laboratory devices. My considerations are: how should I link the state objects, state machine object and device manager object to follow SOLID prinziples. Should StateMachineContext know about DeviceManager object? - explanation and code are below. I will ...
Relational database is mostly used for storing editable user data. But how about storing non-editable lists of information? Possible examples are: GUI-related: main menu items, selectbox options, list of links, set of UI colors application logic: list of user types and their privileges, default table view configuratio...
Our product involves many (dozens) front and back-end modules which work in together with each other. We have decided to completely replace one of the largest which means we plan to port it to the new programming language/technologies. Most likely we do an initial direct port, verify the functionality then look at tidy...
We're using some FSM library that allows you to define entry and exit actions. For some reason, somebody needed to do this fsm.Configure(State.A) .Permit(Trigger.A, State.B) .OnEntry(() => { IsAuto = false; fsm.Fire(Trigger.C); }) This mea...
My apologies if some details here are deliberately vague, I don't want to get side-tracked by the specifics of the language, frameworks, third-party API, etc. Some months ago, I developed some code to ease working with a specific third-party API. As the code seemed to be something that I, even if no-one else, would use...
I currently have a generic Azure repository AzureRepository<TEntity> store internally a list of table transaction actions like so. private readonly IList<TableTransactionAction> tableTransactionActions; The generic repository implements CRUD methods like this.. public void Delete(TEntity entity) { tableTransactionA...
For a while now I have been toying with the idea of using source code as a file storage format. My question: How to support format version changes? (loading of older files with structural differences) An example would be a settings file. JSON: { "version": 1, "email": "name@example.com" } Then there is typically...
I am working on a project which will have a recommendation system and I am in the database design phase, I have a good foundation in programming but databases is a new topic for me, I have designed a database but I don't really know if it's good or not. but mainly the database should serve the following: store users ...
Or ways to get better run time than a nested loop? How would you design this? I hope this is the place to ask semi-vague software engineering questions. My simple simulation is like this: There is a population of X number of people. Every day, people go to work, which creates some quantity of something. After work, the...
Pretty simple question, but googling brought me nowhere: What is the purpose of input ports in the hexagonal architecture? We are doing Java and seem to have some misunderstandings regarding the input part of this pattern. We presume: Domain Core / Business Logic: This part of the architecture describes our business a...
I work in a production company where my colleagues calculate costprices based on 3D models and their respective operations. Apart from workactivities where a user has to insert an operation time and setuptime, most operations are calculated automaticly. Currently, this is done in an Excelsheet. I am responsible for imp...
Assume I have a request: app.post('/order', ()=>{ // task 1 // task 2 // task 3 }) and task1 and task2 is completed but task3 failed. for example a user paid order successfully but saving order in database fails. specially in node.js application that global environment is shared among all http clients and if app c...
I am building a new Python library project to be consumed by several of my application projects. The existing code consumes environment variables for various configuration settings. Should my library project read configuration from environment variables? I've always learned that libraries shouldn't make assumptions ...
I am working on an Authentication system (java based) that will authenticate users and create a session for them. This session is valid for 5 hours. I do not want the same user to have multiple sessions at the same time. For this reason, every time a user logs in, user details are stored in a table. Its primary key is ...
I thought, In a microservice architecture, only the "Configuration Server" will be responsible for providing configuration to individual microservices even if it's a small config. So that we can change it from a central point without going through individual microservices for changing the config. Just want to clear my ...
I've seen that with the Dictionary API now has methods with bool TryGetValue<TKey, TValue>(TKey key, out TValue value) and I like this kind of methods because they're signaling to the other devs that you must not check the value but the output of the Try method. And now that I've seen this I've a tendency to this for m...
I have taken over the maintenance and development of a mature .NET Framework ASP.NET MVC application which uses an Entity Framework repository pattern. Several developers have worked on it before me and there are various styles. Database access is predominently accomplished though a mixture of EF LINQ and raw SQL. Most...
I use the Laravel framework. I've got controllers, like CustomerActivityController, and I've got a service layer with services like CustomerActivityService. Say I want to create a new customer activity via an API call in JSON format. The controller receives a JSON string as request data, and that JSON is parsed to an a...
I have two classes. "System" and "Bluetooth". I want to have a really loose coherency between these two classes as they should be able to exist or not without depending on each other's existence. system class should be able to notify the Bluetooth class when data is available to be sent by Bluetooth and vice versa, the...
For this question we got for a mock test we did and I have put the correct options in bold Consider the following use case diagram, is it correct to state that: a. Customer directly interacts with Bank via Valid customer. b. Only valid customers can undertake withdrawal, deposit, and transfer transactions. c. It is po...
I have a multitenant application where a user can belong to multiple tenants. I'm using Identity-Server 4 for the authentication. I have two applications Angular and API. When a user is not authenticated, it's being redirected to the Identity-Server and proceeds authentication. Once the ID4 ensures that the client cred...
I have recently joined in a new company as a frontend developer and I got access to their current repository which is made in ReactJS. I can see that current team is not very experienced in reactJS and standards. Some examples like not using redux or any state management lots of unused packages Using class based compo...
I have been working on an Android application for some time, and ever since the beginning I've developed a practice of splitting my class's (mostly activity/fragment) code up into multiple files. This is because the Udemy course from which I learned Android development had an instructor who followed this practice. Thes...
The web application I am working on is currently (partially) tested automatically. All scenarios are hardcoded in custom code in this way : WebElement bt = findButtonWithLabel("foo") bt.click(); WebElement input = ... input.sendKeys("..."); // ... do that // ... verify the text "baz" is present on the page I want to s...
I see the term legacy signature a lot in the documentation of programming languages. For example in the php documentation : Passing the separator after the array (i.e. using the legacy signature) has been deprecated. But I can’t figure out what it means. I googled it but the results seemed to have no correlation w...
I have the following problem - I write the code for object data manager, and one of requirements is being able to save/load data into some persistent data storage. I want to make it as the following: there is an interface, IPersistentDataService. if user uses an option to save/load from file, they can give arbitrary f...
The Python Package Index (PyPI) is a public repository, and it seems that anyone can upload packages to it using a tool like twine. The openness of the system raises some questions: Say, a person/organization tries to publish a package, but discovers that the name is already taken. How does PyPI resolve these situatio...
There is a number of devices with Internet access but they are on LANs and have no public IPs. As time goes by more devices will be added. I need to be able to communicate with each device on demand (metrics, diagnostics, updates, ...). I do not need or want full root access. I understand I could create an SSH tunnel i...
I previously asked this on StackOverflow, but doesn't fit there and I was suggested to move it here. I was thinking about using two seperate backend languages for seperating concerns in a project of mine. Another reason would be learning. One backend would be a local windows service working with a special/proprietary i...
[I'm using the term interface here with C#'s interface in mind. I won't tag the question with a C# tag because it really isn't a C# question.] In my work we do unit and integration tests but we don't follow TDD. The tests are often written after the classes. In this work, I often see interfaces that matches the whole c...
So far my weakest side has been proper code structuring and organization. I wanted to know how I can properly apply separation of concerns to the following code to make it more organized. I have a function deleteCurrentList(). It does two things: deletes the currently selected list and navigates back to the previous pa...
I'm reading values from a (PE) binary file. The values have a known length and position in the file and are stored with no padding (right next to each other). They store various types (int, long, pointer, array...). I'm trying to parse those binary structures and store them in a useful way. The obvious way to do it is ...
Consider a context where we have Users saving Questions and adding personal Tags to them. In a graph-based paradigm, a first approach could be something like: (User)-[SAVES {tags}]->(Question) However, with this solution tags are treated as properties of the relationship, and I want to have Tags as nodes (just like Use...
I want to build a search with basic typo tolerance. There are quite a few string similarity algorithms (and implementations for almost all languages I guess). However, humans tend to make some typos more frequently than others. E.g mixing up the order of letters when typing, e.g tpying instead of typing hitting the ke...
Given an auction system, there are several ways to apply a discount to the transaction's final amount, e.g. Special discount for a given seller discount for a given buyer Discount for a specific buyer and item combo etc... Given how confusing and complex the business logic could be for discounts, there is a proposal ...
Given the (old) debate over whether Singletons are overused/abused/are worth it - would it be a bad idea to inject the dependencies as default parameters? In this way, we could get rid of defining singletons for the dependency container registry for the corresponding interfaces - while still leaving the objects in ques...
Is it possible in theory to have a programming language that allows for object lifetimes that exist beyond the current scope but without using heap? As a little background, in embedded development it can often be advantageous to avoid heap and lean heavily on the stack. On our team we use the stack as a large object g...
My service B is part of a chain of services and calls a downstream service C. A --> B --> C Service C is returning HTTP 500 errors for any error it faced, including bad requests or input validation errors that normally should be 4** errors. There is no option to change / update service C. Since service B is stuck betwe...
I'm wondering if there are some best practices to deploy Docker images to Digital Ocean using Terraform. Because I don't expect much load and don't need failover features etc. I'm not aiming to deploy to kubernetes. At least not for the moment. I just wanna deploy a standalone Docker app. This leads me to the question ...
Given the microservices pattern is the decomposition of software by business capability with ownership of state, and a single customer view is an aggregated, central, "single" data store of all customer data that can be used to drive application functionality, are these two patterns able to live together or are they in...
Sometimes code will need to be moved. A common example is some logic that exists in a controller needs to get moved to a helper class so it can be called from outside of that controller. So someone else who didn't write that original logic will cut the code from the controller and paste it into their new class. When th...
Imagine a scenario where a gift card has been purchased with cash, the gift card is duplicated, and each card is used to purchase an iPad at a self-service counter at exactly the same time. What are the possible ways to prevent or mitigate this duplicate transaction in an Always On architecture? I have come up with: P...
I have the below given data model itemid - name - collectionitemid example: itemid |name | collectionItemId ------------------------------- 101 | abc | null 102 | def | 101 103 | ghi | 101 104 | jkl | null 105 | mno | null In the above model, there are items and collections, there can be no collectionId...
For anything larger than a 64 bit integer, why would I want to pass by value? [Update] The question was closed, because it was not specific enough. One comment suggested that I specify a language. I deliberately did not do that, thinking that this site should be language agnostic. I was prompted to ask this when I was...
We are just starting with event driven (and clean) architecture. So far we have two main entrypoints, a consumer (reader from a Redis Stream / Kafka Topic), and an API. As this is almost a modular monolith and not a proper isolated microservice, we added an extra layer that we called the Processor, it basically redirec...
There's a public FOSS library available online, which has not seen any commits by its author for about 3 years. 2 years ago the maintainer added a README.md comment saying he's sorry for being unavailable and will soon attend to bug reports and PRs. But - he hasn't. He appears with his real (?) name, a photo, and a lin...
I'm developing a commercial closed-source application that will have a user-interface, and the back-end will be generating C++ code that needs to be compiled to produce a final end result. When I distribute this application to the end-users, do I distribute the compiler as a component of the installation or will users ...
I work developing software, and very often I find inconsistency in the company's code. The thing is, there is a method named createOrUpdate(), and this method basically does what its name says, creates or updates a given record. However, I believe this method violates the Single Responsibility Principle, because it doe...
I'm starting to run into this sort of dilemma while many third-party APIs, but I will use MongoDB for my examples. Consider the following code: var settings = MongoClientSettings.FromConnectionString(connectionString); settings.ServerApi = new ServerApi(ServerApiVersion.V1); _mongoClient = new MongoCl...
I have a use case to create a service that consume messages from a message queue, process them, store them in the DB, and expose the processed results via an API. Therefore, the service I'm going to create will have to have both an API as well as listen to events. I want to clarify if this is an anti-pattern in a micro...
I'm taking another look at the pros and cons of the Visitor design pattern for a talk. There's obviously the issue that the Visitor has to be aware of every class it has specific handling for, but that's an inherent feature of the pattern. The bigger problem I have is that, unless I've misunderstood something, every vi...
I have a simulation in Python which reads its configuration from a toml file. Since I have tons of parameters, the toml file can grow quite large. This is an example file, similar in structure to my actual configuration file: city.toml name = 'New York' [[houses]] address = 'Foo Street 42' color = 'red' [[houses.res...
I am working on a program that will listen to a queue of incoming message and will process each message differently depending on the metadata of that message. The messages must be processed in order and if a message fails to be processed, it will block the queue until that individual message is processed. The specific ...
This MDN article here summarises quite well the technique of Content Negotiation on a REST API. In essence, if we have a GET /student/:id endpoint, we might want to see different representations of that resource, (html, pdf, json, xml), and we can do this by attaching an Accept header to the request. They are all the s...
I am working on a small project with microservices architecture in Spring Boot. As to not make unnecessary calls to users-microservice, I have duplicated some necessary User data (id, name, summary, photo) also into the posts-microservice, by having an Entity named UserExt ('external'). The posts-microservice contains ...
Doing TDD in a kata is simple. A red test, small amount of code, green test, and refactor. Repeat. And that's it. But, I work on a real application. With a REST controller, a service layer for business logic, a database layer and a converter from entity classes to data transfer classes. How can I start TDD in such case...
I am new on DDD and hexagonal architecture and I am stuck in deciding where to place a very simple piece of code. To code is a simple JWT decode. For SRP reasons, I want to isolate this action into an specific class like the next one, but the question is where... class JWTDecoder def initialize(id_token, signing_key)...
I have an application that needs to publish events to an event broker and consume events from the event broker. I want to do this with an event bus. This event bus should have one public method: dispatch. I do not understand how this works. It has been described to me as this: the event bus will publish messages to the...
When doing PR reviews, should the reviewer be checking that the code is correct (e.g. the logic is correct, etc.) or should the only focus be higher level concepts (e.g. architectural/functional/etc.)? I've been doing a lot of code correctness checking in PRs, mainly because we have been seeing some quality issues, and...
I'm working on an application where it has financial control for the incomes and expenses of the company. These informations can be controled by accounts (bank accounts - can be 1 or more), categories and subcategories. The main objective is to display the current month financial information (or the same information on...
Currently I am reading UML Distilled - Third Edition (Martin Fowler) to catch up some new thoughts and spot interesting things I am not yet aware of. On of those things I came up is the differentiation between generalization and classification. In Chapter 5 - Class Diagrams: Advanced Concepts, Martin Fowler wrote at th...
I'm trying to design an application that uses the microservices architecture. The service would have an api gateway, a user service and then a seperate service for each analytic source. For example, lets say I had twitter analytics data and instagram analytics data. There would be a seperate microservice for twitter an...
My workplace's database has a pattern that I've not seen before. Every column that is intended to be a key, whether primary or foreign, ends in _SK. This is shorthand for "surrogate key". It appears to be an informal way to tell the developer that said column is safe to use in joins and won't have any type mismatches o...
Let's say I have a CQRS system where my write model contains the business rules. My read model is simply a DTO; it is a collection of properties and "dumb". Now if you were to create a REST api, it would use this read model and return it. Now I want to add HATEOAS to this REST api. Meaning that instead of just returnin...
I need to write (in PHP, if that matters) my own password generator to generate simple passwords. Passwords that will be used by kids or elderly people only. That will generate passwords that are easy to remember, yet still has at least a minimum level of security. Something probably as close to XKCD #936 as possible. ...
I am developing a front end application given a back end with some API. The application has two similar views. Both views make use of a big table that's also used as a form . For example, in the table there are some values which are inputs or check boxes, or even buttons. That table also comes with a nice search...
I've mainly studied SQL structures, and I know that the representation of the entities can look something like this: However, I'm building this app with MongoDB, so NoSQL DB. I'm aware that MongoDB is non relational. Is there a standard way of representing these kind of databases? Is it possible to use the previous fo...
I'm working on a design for an HTTP based API that takes in requests to perform a long-running task that requires CPU and RAM intensive processing. To give an impression of the compute requirements, when deploying this to a k8s cluster, I allocate about 3.5 GB of RAM and 1 vCPU to each pod, and the VM is a high-compute...
The api has one endpoint with some parameters. Based on these parameters I can predict how long the processing of the request would take. It can go from seconds(s) to tens of seconds. When expected time is small, I want to make response synchronously, and return 200 upon completion. For heavier requests I'd like to res...