instruction
stringlengths
34
36.1k
I have a resource called Client and it has the following attributes id, name, redirect URLs(ArrayList). class Client{ int id; String name; List<String> redirectUrls; } I have all CRUD http request mappings over resource Client. In the get method I fetch the resource from database and give to client, however m...
I have a question about the structure of requirements. Ian Sommerville (Software Engineering 10th Edition, 2016) divides requirements into User Requirements, System Requirements, Functional Requirements and Non-Functional Requirements. Can I understand this structure in a way that user and system requirements are one a...
Please consider a class diagram and a component diagram as shown below. In the class diagram I use association classes to represent the relationship between two classes (BaseLink and ShoulderLink) as well as between a class and an association class (Motor and J1). In the component diagram, I can represent properties ho...
I often find it helpful to use KDoc/Javadoc comments inside of a class or function instead of normal comments. IntelliJ colorizes them more obviously by default and, more importantly, allows hyperlinking to definitions. I'm wondering if it is considered bad practice to do so. For example: /** * Standard kdoc comment h...
I have an API call that returns products to be displayed on a Point-of-Sale system. the current account I have has about 7000 products. Initially I made the API return all products at once, this works for users that have 1-1000 products and the Point-of-Sale loads relatively quickly. However when users have more than 1...
I'm looking at creating a class which accepts a string to define a Unix socket address. Linux supports three types of addresses for Unix sockets: File based addresses (also called named domain addresses) Abstract addresses Unnamed addresses The first is the conventional method which works on pretty much all Unices. T...
On Wikipedia, the article Programming paradigms defines declarative as a paradigm in which the programmer merely declares properties of the desired result, but not how to compute it; imperative as a paradigm in which the programmer instructs the machine how to change its state. Is assignment declarative or imperative...
Here's a simple example: an API returns a list of possible options with the following structure: { "familystatus": [ { "Id": 1, "Name": "single" }, { "Id": 2, "Name": "married" } ], "gender": [ { "Id": 1, "Name": "male" }, { "Id": 2, "Nam...
I have a hard time understanding how to combine a rule-based decision making approach for an agent in an agent-based model I try to develop. The interface of the agent is a very simple one. public interface IAgent { public string ID { get; } public Action Percept(IPercept percept); } For the sake of the example...
I came across quite a subtle bug the other day, where there are two sections of similar code that were supposed to use different variables, but copy-pasting had lead them to use the same variable. I've reduced it to the the example below. static float module_variable; float foo() { float a = calculate_a(); flo...
there is two interfaces A and B: public interface A { } public interface B extends A{ } A and B have one subclass each: public abstract class ABase implements A{ } public abstract class BBase implements B{ } and now I want make BBase extends ABase, like this: public abstract class BBase extends ABase implements B{...
Say I have a hypothetical factory method whose single responsibility is to create MyObjects. However, MyObject should only ever be constructed with an ordered list. Further, MyObjects without an ordered list should never exist my world. Is it the responsibility of the factory to make sure the list is ordered before cre...
I have a function that takes two objects and uses a switch on the enum types of the objects. The problem I have is this is getting painful to manage as I add more and more primitive types and i need two case statements for each variation. My switch is setup like this: switch (obj1.Type, obj2.Type){ case (GeometryTy...
In my group we are debating whether to version each one of our system components or not. While I find many talk about "how" to version each component (semver for example) I don't find enough reasoning to do that. What I can think about is that If a version of some component appears to be faulty, we can always use an ol...
I'm working on a project which focuses on simple HTTP-related actions (to get my feet wet really). I'm using the net/http package, which I thought was very convenient for almost all requirements except that it seems a http.Server gives instructions to http.Client if and only if the client has established a connection. ...
I'm reading chapter 20, "Business Rules", of clean architecture book, in this chapter Uncle Bob defines entities as: An Entity is an object within our computer system that embodies a small set of critical business rules operating on Critical Business Data. The Entity object either contains the Critical Business Data o...
I think the question is pretty straight forward but just to clarify, if the client and server are separate machines and need to be able to communicate with each other, does that mean that certain aspects such as synchronization, ack packets, re transmitting, timeouts, etc need to duplicated between the client and serve...
Let's say you have to meet some prerequisites before doing something. For that, I think implementing Supplier<Boolean> is a great candidate since it's widely used, and quick to understand. But, my colleague argues that since it's normally used for lambda definition, defining a separate interface is more clear. Should I...
Software companies like Autodesk, Adobe, etc all offer online licensing schemes with the following features: (1) to use the software, you must login from your workstation to activate your license (2) the software may phone home periodically to ensure the validity of your license and also tell the license server that t...
My Python project performs a complex set of operations, and it's important to make clear which operations it uses and in what order. Therefore, it has a main method that reads like an overview of the project, with the implementation of operations outside the main method.: class Program: def main(self): <--- This sh...
I am currently browsing through Niklas Wirth's compiler construction book. He presents a simple RISC architecture as a target for code generation using the following diagram. The symbols/shapes used are not explained in detail, though. Registers/storage seems to be presented with bold-borders. I wonder what the trapezo...
Logically, not based on how cost we will spend or how much we will hire programmers to do it. Can we (Is it possible to) make a compiler for any dynamic/script/interpreter language, like Lua, Python, JavaScript etc, to compile it to native machine code, as like the result that come from C/C++ , without need to modify t...
This question pertains to properly structuring a class. The object of a class I have is instantiated with multiple parameters. Many of these parameters are then manipulated with each other to derive new values. Currently, I have all of these manipulations as methods in the class. Is it inappropriate to move these me...
Positive: Allow for horizontal scaling of app by replication of instances - without replicating the DB Drawback: latency introduced between 2 machines Is this something necessary for small systems?
Do experienced developers and software architects see entire application in terms of design patterns? In other words experienced developers and software architects able to describe an entire software application in terms of design patterns? By experienced, I mean developers with 10+ years experience. Is that something ...
A contrived example: I have many Thimbles, identified in real-life by their color, that I lend out to friends. I want to know only the most recent friend that is wearing my Thimble. My friends covet my thimbles, so this information changes frequently. Options I can think of are: Keep the lending information in the mai...
I am getting confused at qualification association. I perform qualification when I need to remove many-to-many relationship or when the PK of a particular table is not able to be uniquely identify a row - in this case I make a composite key by qualifying it. That said, I do not understand whether after performing a qua...
I'm an experienced Software Engineer but very weak in concurrency because of no prior experience in that. I've been interviewing with several companies in which I was asked similar kind of questions as given below: If you are designing a fantasy sports application in which there's a contest which can handle only 100 u...
For databases like Postgres and ElasticSearch, updates to existing records are relatively quick. I understand that for these databases, when an update on an existing record is written, the physical location for the existing record isn't updated at that moment, but instead the change is written to an append-only file th...
I want to create a stream class The input stream should read/parse a continuous range from left to right providing convenience methods. The implementation isn't a problem but choosing a consistence API. A basic example would be: input_stream is("Hello! 42"); is.peak(); // 'H' is.read_n(7); // "Hello! " is.read<int>()...
I have: A User entity. A Poll entity. Relationship: User creates polls. Use-case: When an arbitrarily user is clicked his/her profile is loaded and shown. The profile includes a list of polls created by the clicked user. Which of the following api calls is the proper usage of such a use-case? website.com/api/users/...
I googled this and found questions like "How to use Protobuf message as java class without a java outer class?" (https://stackoverflow.com/questions/60312156/how-to-use-protobuf-message-as-java-class-without-a-java-outer-class) which talk about how one might tweak their Protobuf Java code generation. For example, that ...
I have a MySQL database with nodeJS server. I want to implement a notification functionality which is as follows. Once a user registers, I want to (inform) send some particular information to the user that runs in fixed time interval. Something like a task management and tracking. If user A registers at 10am local time...
I recently started discovering event sourcing so I am fairly new on the subject. Imagine having a system (system A) which listens to events of a third party order service (system B). These events can be "OrderCreated", "OrderAmountUpdated", "OrderClosed", etc.. I want system A to build up an order entity based on the e...
Mostly in all routers and operating systems the Longest Prefix Match algorithm is used for searching the trie of IPv4 addresses. Packet filters like Iptables don't need some special data structure for finding IPv4 addresses. I need to implement some data structure, where I could efficiently (log(N)) find IPv4 addresses...
In the simplified database schema depicted below, I'm considering denormalizing by adding a short-circuit key (EventId, relation shown in red) on Appointment. One advantage is not needing a join to access appointments data by event (the usual way it will be queried). An additional advantage involves constraints. I'd ...
I can't seem to find a good enough answer, nor can I reason it out myself. Why deploy to the development environment? In most examples I've seen, automated unit tests and integration tests run as part of CI when we merge a feature into the develop branch. As far as I'm aware, there is no need to deploy when conducting ...
In the Book "Implementing Domain-Driven Design" the author suggests to implement a repository method to provide the next application-generated (not database-generated) ID. Like so: class MyRepo { public MyId nextId() { return new MyId(UUID.fromRandom()); } } That would lead to code like this: var id = reposito...
I've got a state machine implementation in Unity that I'm working on (C#), the plan being that it will be mostly used for AI related things. I'm not sure how I should deal with various "inputs" / how it should interact with knowledge from the outside environment. Two approaches I've considered and tried so far: 1, I ha...
What makes programs like st, zathura, sxiv, and feh load instantly and what makes programs like VS Code and Google Chrome load so slowly in low-spec computers? For example, I have a low-spec laptop running Linux Mint. And when I execute st, it instantly opens an st instance, but when I execute Google Chrome, it takes a...
I'm reading an introductory article about drivers and came about this quote: "Once the device sends data back to the driver, the driver may invoke routines in the original calling program. " I was wondering what this would actually look like(an example). Eg. If I had a program that had the user type in something, windo...
Given the abstract syntax tree (AST) of each line of a function's code, I am asked to generate code for that function's corresponding unit tests, similar to what Microsoft's IntelliTest tool does here: https://docs.microsoft.com/en-us/visualstudio/test/generate-unit-tests-for-your-code-with-intellitest?view=vs-2019. Th...
In a server application, I have a class called Controller which receive the incoming request. I also have a class called Service which do business logic and a class called Database. All classes are "public", but only one of them is really reachable from the "outside", the Controller. I am in a dilemma, should I only te...
Say, for instance, I have this simple function in my domain layer: function canCreateNewUsers (principal: User): boolean { return principal.isSuperAdmin || principal.isAdmin // || ... a bunch of conditions } And this function has already been unit tested in my domain tests. Now say I have another layer, the service ...
Related (but different) question: How do you dive into large code bases? I have always worked on small projects where editing a piece of code is easy: you modify the code, you recompile and in a matter of seconds you can play around with the compiled program. Everyday one may end up doing the "edit compile try" loop ...
I am curious about it because I talked with a friend about the strategy pattern, and we diverge about when we have to use it. Our scenario is that I have to build a view component with 3 variants. All variants have particular colors and ways to resolve the string content, and it is supposed never to change. We don't kn...
I'm working on an application implemented in different microservices, which uses a message broker (event bus) to consume events (simple pub/sub). As for now, in a given microservice, we are spawning 1 thread per event subscriber, which will be running in background checking for new published events (specifically) to pr...
Question on securing JWT token integrity, given the following scenario: Client sends a JWT to server signed with Client's private key Server caches public key, but uses http (and not https) to retrieve the public key to validate that JWT is signed by the client. Attacker intercepts the http connection, changes the pub...
With the current implementation of getaddrinfo(), I'm not given any information about a timeout of the IP address(es) returned. The library implementing that function has the information, but I haven't yet seen a function to retrieve the timeout. What I'm wondering is how do people current implement the concept of conn...
I have been coding in python for a little over a year, and I have learned a lot and developed quite a few applications, in the process. I do not program for my profession, I simply program recreationally. With that said, I am not exposed to new programming techniques/data structures etc., that I would be learning if my...
First let me phrase my understanding of GitHub flow before asking the question: In GitHub flow, we have a main branch, and feature/topic/bugfix/whatever branches branching off that main branch. Once ready, this topic branch is then merged into the main branch. It is important to make this separation between the develop...
I am looking for general guidance or any relevant links for a complex project. We are a small business that sells a construction materials testing software. The client is a Windows application with over 3 million lines of code, written almost entirely in legacy C++98. Business objects are persisted in a SQL database wi...
This question is a follow-up question to Clean Architecture use case testing. Suppose the production code injects Use Case Interactor into the Input Boundary - that happens somewhere in the main component1. But now I want to test the Input Boundary/Output Boundary of the use case. I can only think of two ways to do th...
I am looking to identify a benchmark to shoot for, and to come up with a decent game plan for introducing tests into our systems before deploying new code. Just some backstory My employer is not a tech company and our end users are inside the organization, we are just a department of 2-4 developers supporting a medium ...
I've read the canonical article about GitFlow by Vincent Driessen, and there are 2 things I'm not sure about: In the big diagram in the beginning of the article: In the line of the develop branch, we see some commits that seemed to be just committed directly to the develop branch (not merged from any feature branch)...
I've seen in many places, one of them here (and also in the guiding questions of GitVersion) that, when coming to determine whether or not to use GitFlow, one key consideration is whether or not I need to maintain several versions in production. So if the answer is yes - GitFlow can fit you. What objective advantage do...
In WPF when Datagrid's CanUserDeleteRows property is set to true, then conveniently I don't need to implement deletion of elements from an underlying data structure. But it does mean that deletion mechanism is not testable as deletion can only be invoked from GUI. Or maybe it is OK because the behaviour was (presumably...
Background I am building a web app that allows the user to integrate with multiple services like Google, Twitter, Github etc. using OAuth2.0. Currently, I retrieve the refresh token on sign-in to service and store it in my DB. (encrypted before storing). (Access Tokens are discarded after use). The application is hoste...
I'm refactoring a code base to have something more easier to read and follow SRP. However I'm at the point I'm unsure what the best design is. Currently it looks like this: A thread receives a "command" to execute. The "command" is always the same, it takes the form of an encoded message to send to a WS. The message fi...
In a DDD-CQRS scenario, should my commands in the Application/Service layer always be just a facade to different aggregation method and other inner layers like repository calls in the infrastructure layer? Or should commands retain business logic inside it (consequently transferring that logic from domain models to the...
So I wondered how matplotlib (or equivalents) makes graphics appear on your screen. I found that matplotlib does not do the drawing itself; instead it is built on TKinter, which is built on TK, which is...and the rabbit hole/stack continues. Is the software package/library/code at the bottom of this stack achieving thi...
I have a Django application of 2 GB running and I need to receive a CSV file of more than 1 GB, read it and load the data to a PostgreSQL DB in IBM Cloud. The problem is that if I receive the file, it would have to be stored locally and I will definitely have to increase the memory of the server or handle it in a diffe...
(Hi I’m new here - I believe this question suits here from the guide saying “ architecture, and design” - however if there is a better place, just pop me a comment. As there’s no actual code it doesn’t suit stack overflow ) I am designing a simple site and app where people can create alerts for product stock availabili...
I need to stream changes from my MongoDB instance to Elasticsearch. I also need to perform complex transformations on changed documents. After doing some research I narrowed my options down to 2: MongoDB native change streams Using a Kafka connector like Debezium to capture MongoDB and stream them to Kafka, then have ...
Here's a scenario I need help with. Say you have a dating app (distributed, multiple instances), that has a table likes | id | user_id | liked_id |notification_sent| If User A likes User B Insert into likes If likes contains (B likes A) Send match notification(A,B) Set notification_sent true for...
I have a data science codebase that contains several classes. Several of the methods in the classes rely upon various helper functions. These functions will just precede the class definitions in my module. My question is, is it accepted practice to have these helper functions outside of a class? The benefit of this ...
If developing event-driven application(more precisely event sourcing application) that will run solely on 1 machine are RabbitMQ Streams an overkill, or maybe a misfit? In theory RabbitMQ Streams seem nicer than manual callback in code that are hard to track and monitor, but then on the other hand RabbitMQ Streams seem...
As part of my master's thesis, I am currently working on a framework for building microservice-based service systems. Based on my research, I am able to define important design criteria that the system must fulfill. In order to make these design criteria usable in practice, I want to draw on proven design patterns. How...
It seems to me that there is a conflict between clean architecture and the recommendation not to use instanceof. Consider the following code: class ParentEntity { } class AEntity extends ParentEntity { List<Integer> entityIds; } class SaveUseCase { IEntityRepository entityRepository; void save(List<Paren...
We have an existing code base in Python which doesn't yet use any code formatting tool. Now we have settled on YAPF as a tool and also created its configuration file. To me it is not clear how to reformat the code base without causing havoc in further rebases. At the moment we rebase everything onto master such that it...
I am practicing design patterns and OO concepts such as inheritance in java and I'm writing an application that represents a vending machine. I have two questions focused on ideal structure and design patterns: What is an alternative way to decide which treat from the vending machine to manufacture based on the passed...
I have a question regarding the architecture of microservices and event sourcing. Imagine that I have the User service and the Franchise service. In the Users entity on the user service I have an attribute called franchise_id that contains which franchise this user belongs to. When a franchise is created in the franchi...
I happen to have a reason why I might want to dereference a nullptr. Of course when I do, my program crashes, and from what I gather, this is due to the compiler playing it safe and stopping my program, rather than risking the program acting upon the dereferenced nullptr, which is undefined behaviour. So my question is...
I have a Node.js HTTP REST API server and a Node.js WS server. I separated them into 2 entrypoints so that they can be more easily debugged and run separated from each other, but now I need the REST API to produce results inside the WS server, to send specific data to WS clients that are connected, depending on which o...
I have a distributed application backed by a distributed database. (Distributed here means running across multiple hosts with one or more instances on each host). Application has several toolings around it, each does a different operation such as getting some form of update, starting certain application-specific proces...
I have a general design question. Suppose I have a List: List<String> list = new ArrayList<>(); list.add("Str 1"); list.add("Str 2"); list.add("Str 3"); I need to process the elements of that list in a loop. There are at least 3 options that I can think of. Passing only the list the perform the operations: public Lis...
Suppose we have multiple services which each of them uses its own db(SQL or NoSQL, could be physically distributed). How can handle queries which require data from two or more microservices? PS 1 As an example suppose Users (id, first_name, last_name,...) and Orders (id, user_id, goods_id,order_date,...) are two micro-...
In a Restful API, it is better to use GET to list a collection. However, in our scenario, we allow people query with a list of parameters (say CodeList) and then return details. As we allow upto 500 codes in the codelist parameter, it is possible that the size limit of 2,048 characters for a GET url is not enough. What...
In our project we are using Django and Django Rest Framework as main application to get/query the data from database and send it to the frontend. Those endpoints are very fast as they should be. However we need to implement some sort of ETL module that would get data form excel files or clients CRMs and that would take...
An important view in our application is a big table of entities. For the purposes of this question I'll use an analogy for our entities - so let's say it's vehicles. There's half a dozen different kinds of vehicles, and they share a lot of fields, like the brand and whether it is currently available. However, there's a...
You have the following situation: You have an SQL database containing two tables product and product_images You would like the user to be able to add, remove, or move around existing images They can perform those actions from a form which downloads the current state of the product and displays each picture in order. W...
What would be a secure way of storing client secrets used for authentication (webservices) in Xamarin/Android apps ? Secure Storage, which interacts with Android Keystore, seems very useful for storing sensitive data acquired at runtime, such as access tokens, but not for sensitive data that needs to be immediately acc...
I am building an application which will provide users with custom pages served under the subdomain within my application domain. What I want to do as next step is to allow users to create CNAME which can point their subdomain. The issue which I see is to serve them with the valid SSL certificate for their domain. The w...
Sorry that this is a general question, but I believe this is a good resource to ask this sort of advice. I would consider myself a junior developer. Most of my coding career has been working for a small company (5-10 people) where we develop a lot of GIS products. We have hundreds of products, scripts, and data sources...
I'm developing a microservice application divided into 4 layers (API, Application, Domain and Infrastructure). The composition root of my application is an assembly in the API layer. From what I understand all the binding and registering of dependencies in an application using a DI framework should be done in the compo...
What are the advantages and disadvantages of including JS/CSS inside the HTML instead of separated files? Specifically concerned about performance issues, for example, if the CSS and JS are small and simple, and they are not going to be used in any other page, is it better to include them with the HTML so there is only...
I am studying the heap sort algorithm from the book Introduction to Algorithms by Thomas H. Corman. It differentiates between the length of the array, A.length, as "the number of elements in the array" , and A.heapsize, as "represents how many elements in the heap are stored within array A" I am trying to visualize...
this is a followup question to the following StackExchange question - If you had a medium size company, several developers - but zero tests written in your REST API's - where would you start? At the time our applications were started, Microsoft provided OAuth2, but the nodejs interface wasn't exactly complete. So we bu...
Until today I had a static C++ library with no separation between the public interface and internal headers. My other apps just linked to it, included the required headers, and used whatever they needed. I want to change this, so I created something like //myLib.h class myLib { void doSomthing(); InterfaceA *g...
I'm not sure how I should think regarding my database design. I have made this database schema below. And I'm trying to think about the relationship between the entities. I have read through online that many-to-many should be avoided as much as possible and it makes sense. But in my case here, can it be avoided and how...
Our team is exploring microfrontends as part of the suite of applications we currently offer our clients. A few questions come to mind which I'd appreciate thoughts on: I understand how a 'shell' or 'container' app can 'host' various 'remotes' which are self standing apps in themselves and, as such, be a 'suite' provid...
I have different versions of modules and they should all work together with the same shared library which could also have different versions like displayed in the image below: From a daily use perspective, should I always use the latest version of the Shared Library for every Module create a framework that allows usi...
I have several enums that need to be defined and shared between collections. A practical example: There are X colors available "Light Blue", "Red", "Purple".... people can like items of several colors items can use several colors I need to be able to change name of color "Red" to "Cherry Red" and all the associations...
I have a dataset stored in ElasticSearch, only for searching purposes (the source of truth is external). Each index has an associated schema and there are associated queries. From time to time, the structure changes. When doing that, I update all the indexes by dropping and recreating them from the source of truth (wit...
So I'm currently running an analysis task for my company. I won't go into too much detail but we are dealing with medical records and other confidential data. Previously this application was only used internally but now there's come a business requirement that would allow for external access by an unauthenticated user ...
In an object oriented language like Java or PHP (other perspectives welcome as well) if I use a fluent interface like this: my_pizza = (new Pizza).withTopping("pineapple"); another_pizza = my_pizza.withGarlic(true); would one expect withGarlic() to clone the pizza or would one expect my_pizza to change (into a culinar...
I have a multithreaded backend application. It is inputted x, and outputs y, and this makes up a "job". A job can take up to several seconds to complete. The application is fed input via HTTP requests, and once the job is completed it will return a response to the HTTP (so the response time can be several seconds). The...
I'm looking for an efficient way to create appointments between teachers and students. I want teacher to be able of make their students know their availabilities : For example, A Teacher writes on the application that he is free for an appointment on Monday from 8am to 9am. The Student wants an appointment with his tea...
I used Google search to convert numbers from one numeral system to another. 10 to binary is 0b1010; 10 to hexadecimal is 0xA. What's the meaning of 'b' and 'x', accordingly? I think these are abbrevations from binary and hexadecimal. I understand the way converting works. I thought 10 to binary is 1010 and A to hexad...
I'm building a login system using OAuth to integrate with various social networks. The flow is very simple, first, the user is redirected to their social network to grant permission to read the necessary information, and after that my application has access to the following user information: auth_id, auth_provider, ema...