instruction
stringlengths
34
36.1k
Our new team suffixes class names with API to indicate that they encapsulate RESTful methods. Eg: "PaymentTemplateAPI", "FeeTemplateAPI" classes. I find it odd since API is a general term that refers to any API/method created using any architecture style (REST, RPC, etc). I would suggest adding suffix "RestAPI" to conv...
I am part of a small project that is doing some research code in C++. Our work involves a lot of mathematics and due to its nature we often need to temporarily use other people's code/libraries. To speed our own iteration times we designed a template based interface that allows to treat almost any vector type, e.g. Eig...
I am creating a web application which has three distinct components as far as I understand. A Nuxt frontend, and Spring Boot backend and Google OAuth2 for authentication using OpenID Connect. Nuxt can be extended with Nuxt-Auth which has support for OAuth2. I just need to give it my Google OAuth2 Client ID and two endp...
If I have two boolean variables B1 and B2 whose value combinations cover four independent behavior functions (MFF, MFT, MTF, MTT), then how many concrete strategy (design pattern) classes should I create? From the single responsibility rule, it seems like I'd need a strategy interface with a single method, and four con...
Here is the scenario: Let's assume that we have a Telephone and a Driver. Here is the definition of the classes (Pseudocode): Telephone: { Id: number, [Unique] TelephoneNumber: string } Driver: { Id: number, Name: string } Telephone Number has a unique constraint. The driver has a relationship with the teleph...
A modern world is full of gigabit/sec switches. There are 2^32 octets (bytes) of the sequence space as per TCP standard. Let's calculate. 1_000_000_000 is 125_000_000 bytes. Conceptually, each byte within the established TCP connection has its own unique sequence number; uniqueness is a must here because without it the...
I've recently found myself using a generics with constraint that a type should inherit from a specific base class, but now I've just realised that this is redundant and unnecessary because the following code: public class SomeClass<T> where T: SomeBaseClass { T SomeProperty{ get; set;} } can be replaced with: publi...
I know that P2P sharing is copying the exact content between the peers. Everyone has the same data. Let's assume the content is very important and I don't want anyone to distribute outside the group. only those who got access to the material can only download. When anyone downloads the content. The material gets marked...
My specific problem is that I have a vertically scrollable window into which I need to place rectangular <div> elements that are locked horizontally and have different widths and heights. Basically each <div> has a different start/end horizontally. The order in which the <div> elements gets placed is based on priority....
In my current development task, I want to validate whether a string is in JSON format or not. When I checked for solutions from resources like StackOverflow I saw many of answers are as below, try{ JsonParser parser = new JsonParser(); parser.parse(passed_json_string); } catch(JsonSyntaxException jse){ System....
My first thought was that I'm "serializing" the complex object, but from what I understand that means I'm reducing it down to a string or binary format which could be passed over a network. While what I am actually doing is converting a complex object to more primitive types like list, dict, str, int, float, etc. The c...
Hello I will try to explain what is my actual understanding of tests and why I have problems to grasp it's utility. Even if I try my hardest to understand the concept of TTD, unit test, integration test, etc. From the most articles that I read it explain HOW to do it (with a trivial example or a framework) and sometime...
Given the classes: public class SocialNetwork { private final Map<String, User> users; ... } public class User { private final String user; private final LinkedList<String> followers; //stores the users that "user" follows ... } I was wondering if it is considered a good design practice (and why) to s...
A Facade is a higher level API over a whole subsystem. A God is class that violates SRP. Where do we draw the line? Does the following code represent any of the two: enum UnitType{Demon, Paladin}; namespace demons { bool are_scary(); static unsigned numbers; void attack(); void phase_out(); } namespac...
I hope I can explain my question clearly. I'm planning to do some real time 2D grayscale image acquisition, and after reading some articles, I noticed that many are using buffers or multithreading or even parallel processing. Below top shows how in single threaded control perform one task at a time and bottom shows how...
I'm working on a project which utilizes DDD, Hexagonal Architecture and Microservices. While working on StorageService, the implementation was quite easy since the features were: CRUD of media files automated backups There was just one aggregate root, and nothing fancy about it. .. but now, I'm digging into ContentSe...
I have some issues selecting an appropriate naming scheme for GitHub repositories that belong to the same project. The main package repo relies on additional repos to generate documentation or run tests. During development on the local machine, those repositories import one another (located in the same root directory)....
I have a monolith CRUD application with a feature - possibility to export some DB entires to an Excel file. The export is done within a background task. Often, however, when user presses the button and expects to get a link with completed download, they may trigger a crash for the server where the webapp is hosted (not...
Is it OK for an API to accept either an object or an array on the same endpoint? I want to allow the user to post multiple items at once. I am thinking of creating a different endpoint, but then it gets hard with the semantics. Maybe prefixing the relevant handler with bulk would do it. I thought that maybe the user ca...
I have a question regarding the modelling of bounded contexts and the context mapping. I have to evaluete and document an existing architecture where two bounded contexts are exchanging information with message events (domain events). Has the bounded context which sends the events an open host service? Or am I getting ...
I am developing an E-Commerce Web application using C# (back-end) and JavaScript (front-end) for a computing shop. This application mainly displays each stored computer, and all information about it (model, price, image, speed, ...). A computer can be a desktop, a laptop, or a server. Each type of computer may have add...
Usually, unit tests are built in a separate project/executable. Ideally, components under tests should have a small number of mockable dependencies, allowing us to do this, among other benefits. But this is sometimes hard or requires a lot of effort. Some examples are legacy code, code that depends on elements that are...
I have a list of python dictionaries (let's assume each dict is flat for the time being). The keys are all strings and the values are strings or real numbers. I would like the user to have the freedom to filter this dict in which ever way they choose to, using some kind of query language. The query can contain nested '...
I have looked at the source code of some standard C functions and wondered what the reason is for null-terminating a string other than to find out its length. e.g. The strlcat() function which is defined in the string.h header. size_t strlcat(dst, src, siz) char *dst; const char *src; size_t siz; { regi...
I find a lot of resources regarding strong consistency versus eventual consistency, and when to choose one or the other. I'm wondering how and when you would have both together. Consider this specific scenario: Order service receives and stores order to database. Order service sends OrderReceived message on the messag...
I have the following architecture: Database (Postgres), Batch(java app - long running operations that delete, update, insert lots of data in the database), Rest API(java app - provides rest services to the front end). The problem is that when the Batches starts to run this spikes the utilization of the database to 100%...
I have some .env files for my backend application and the usual recommendation is to put all .env files in gitignore to not share it in the repo and use something like Github Secrets to store the .env files. That sounds a good thing to do, but if I have a private repo, where only people that should know the .env files ...
I have a service class that does some magic. I want to introduce a new type of functionality - raise an event. I am absolutely sure that decorator pattern is great for this scenario. The problem is that the variables I'd like to pass as an event arguments are created only in that service class function. These variables...
In microservices oriented architecture, service A receives a file and stores it. Later Service A has to pass the data in the file to Service B. We have a choice to send the data, as: batches of rows to Service B's Api or using message queue share the file URL with Service B. Does number 2 seem a reasonable choice? It...
I am building a microservice app where the client sends requests through REST APIs to the backend server, and the backend will communicate with other services using gRPC. I am aware that this is synchronous and is an anti-pattern for a microservice app due to the tightly-coupled attribute. My question is if I were to r...
We are building a multi-device (different vendors, different types) manufacture machinery where these device work together orchestrated by our software and operated by a human being to create various products. We are currently working on establishing an architecture for handling many different devices with an outlook o...
I prefer to create linear git history, which can be fast-forward merged. This was a technical requirement at my previous job, which used BitBucket and required all PRs to be fast-forward-able. We had to always manually rebase onto latest master. A new company I recently joined, using AzureDevOps, likes to have small PR...
I have a bean which executes a method doStuff asynchronous, which of I am uncertain what is the best way to test the logic of that method doStuff. public class MyBean { private final ExecutorService executorService; @Inject public MyBean(ExecutorService executorService) { this.executorService ...
I am maintaining a FOSS library which, for the sake of discussion, consists of a small .h file and a larger .c file (plus build-related files, see below) I've been requested to offer this library as a single header file. My instinct was to just refuse, as one could simply include both the .c and and the .h file, but I ...
I am developing a web app along with a backend API. The backend however must talk to other services, some of which are internal and others are not. In an ideal scenario we would spend time and have a local copy of all services running, but this is not possible due to; some services being 3rd party and other internal se...
I've read the questions regarding the use of random values in unit-tests and, well, I still don't quite understand what the argument against random values is. I'm trying to understand because I've had an entire course dedicated to testing while I was doing my Masters in SE. The course focused heavily on random value ge...
I'm studying systems analysis in my CS class and we've just been taught about Gantt charts, CPA diagrams, and modelling. I'm a bit confused regarding data modelling and process modelling. From my vague understanding, the former involves visual illustrations while the latter involves written ones. Reading up on it seems...
Short Version If we had an application based on a state machine - transitioning between states to run the application: is repetition, and in fact the entire state machine, based on the presence of an event loop? Something like: void Main() { while (_currentState != State.Exit) { switch (_currentState) ...
To illustrate the problem, I'm defining a PositiveNumber class that is a subclass of a Number class. As Python doesn't support type casting, I'm defining the from_number as a convenience method I can use to cast one instance to another. This method is common to all subtypes of the Number class so I'm putting it into th...
I am in the process of implementing onion / clean architecture, and would like to understand better how and when to map to my domain entities. So if we take a specific example where we have a Post and we would like to update a status on this object. Am I correct in thinking that when I receive data in the controller I ...
Assume there is a distributed system which works on the principles of eventual consistency. Let's consider a scenario where I update my profile picture using my phone. If I log in using another system, let's say my personal laptop, it should show me the updated profile picture assuming it routes through the same data c...
Summary: In an organization that wants to use an agile/Scrum software development process, but that also has a large production support / operations burden with an expectation for quick response times, what's the best way to ensure an adequate level of production support / operations without throwing all teams' sprints...
I'm looking to build a service that interacts with an existing web application's database. The service would retrieve data from an api for which the web application users own an account and warehouse/refresh this data for them. I'd like to make sure we can handle potentially large amounts of data for each user. Current...
I've started learning Python recently, and there are some topics I cannot really understand. One is the usage of the decorators in user defined objects, or encapsulation more generally. I mean, let's consider for example: class Dog: def __init__(self,name,age): self.name=name self.age=age Ok so now I ha...
I need transactions in my service to ensure data consistency. I don't know what the best layer is for transactions to be created in. The goal is to have all business logic in a single layer. First, some example business logic: There are the entities of person and hobby. Each person can have multiple hobbies. This means...
I'm working on a somewhat typical notes app that I plan to create with React Native. Since the usage involves a lot of typing, it makes sense that there should also be a web version that users could open on their desktop. Now, if the app was mobile-only I was planning to store the data locally using SQLite and let user...
The Wikipedia article on the Composite Design Pattern includes the following diagram: As you see, there is an association relationship which is child 0..* – 1 parent. However, given that: a Composite class is a Component as well, and every Component has a parent (a Composite)... Doesn't this force an infinite tree o...
Below is an excerpt of Fundamentals of Software Architecture, page 65, which I am reading: The instability metric determines the volatility of a code base. A code base that exhibits high degrees of instability breaks more easily when changed because of high coupling. For example, if a class calls to many other classes...
The Wikipedia article on the Composite Design Pattern includes the following diagram: As you see, there is an association relationship which is child 0..* – 1 parent (association). However, shouldn't it be a composition relationship instead (filled diamond)? To me, it is nonsensical to consider the identity of a node ...
In my library (DLL), I have extensions for List like the next one. <Runtime.CompilerServices.Extension> Public Sub Store(Of TVal As IFullyOperable)(items As List(Of TVal), w As BinaryWriter, closeAfter As Boolean) Try w.Write7BitEncodedInt(items.Count) items.ForEach(Sub(i) i.Store(w)) Catch ex A...
I'm starting a new project in which we will use Client Side Rendering for the frontend. This is my first time working with this kind of technology and I was wondering which would be the best approach to develop non-regular users components (for instance, fragments that only Admins or Moderators should be able to see). ...
Ok I have a bunch of components that all have the same logic but have different css classes. So I wanted to create a sort of factory function that takes the names of the classes as its argument and returns a component. Here is a very simplified example: const buttonFactory = (classes) => (props) => { // ... some logi...
First of all I am not sure if this question should be here or in stackoverflow. I decided to post it here because it is not a coding but architectural challenge. Introduction I have a data base design for an HRM system that I have come up with. For simplicity, I am excluding lot of fields that is not relevant to this q...
I'm wondering if the following approach can be used in order to increase parallel processing of Kafka messages. Suppose there's a topic with N partitions. At some point the system hits a bottleneck in terms of parallel processing (N partitions are not enough anymore) and the order of messages is important so adding mor...
Context Let's say I have a Shape class (I'll use C# for the code snippets) that represents a 2D shape, like a triangle or a circle. These shapes have an area, so I'll include a method for calculating it. Since I only care about the calculations, I don't want the Shape class or any derived class to contain any data. Ins...
I am currently planning to create an application. So far I have always been using the traditional username/password approach. But I would like to get rid of passwords for user authentication. This would avoid to worry about weak, stolen and forgotten passwords. I want to create a passwordless signup and signin with mag...
I would like to have type-safe access to items in a collection with polymorphic items at compile-time. For this, I set up the code below as a proof of concept. Passing the DataItemProps instances to the GetValue, SetValue methods of the Data class, it is possible to resolve the type of an item during compile-time, allo...
If we use both, epics and user stories, should all user stories be linked to an epic, or could some stories stand independently on their own? It's more or less a question of formality in order to keep the process clean: in such a context, can I let a user stories stand on its own without linking it to an epic?
I'm reading a book on design patterns. On proxy pattern the code are following: class SensitiveInfo: def __init__(self): self.users = ['nick', 'tom', 'ben', 'mike'] def read(self): nb = len(self.users) print(f"There are {nb} users: {' '.join(self.users)}") def add(self, user): ...
One of the advantages of feature / release toggles is that you can integrate and deploy code without releasing it. But how does that work with ATDD? If I write some tests that are failing, because I'm not done implementing the features, even if the new implementation code is behind a toggle, I can't very well integrate...
I'm working on an AEP in the IoT space, where we've created a few domain-specific entities to allow users to model their data. Each entity has both a type and instances of that entity. These are: Assets. e.g. an Asset Type could be Truck. Assets are designed to store both attributes (registration, type etc), and metri...
I find it difficult to explain but I'll give it a try. I have a module structure where the modules can fire events and other modules respond to them. As you can see, B & C are listening to events from A, D listens to events from B & C (but doesn't need the event from A) Now the problem is: since the modules are create...
Is it common practice for Software Engineering firms to use drawing numbers and drawing templates when creating software diagrams? For example, I find that UML diagrams or flowcharts are particularly effective when planning out and later describing how a particular piece of software works. However, having come from a c...
Here is the question. On a 2.2 GHz processor with 6 physical threads and 6 hyperthreads, I see performance on the order of 3-10s for a particular job involving OpenCV. I do not specify that the process should use many threads on this local machine, but all threads become active during use. When this task is submitted ...
I understand why Tor needs many nodes in each relay, although in the case of connecting a hidden server, the packet is encrypted end to end. So why then must there be multiple layers of encryption on top of that with nodes decrypting the next layer then passing it, instead of only encrypting one layer that the next nod...
I have two repositories: class RepositoryOne { /** * @param int $id * @return ModelOne */ public function getById($id) { // Search and find a ModelOne model in the db. return new ModelOne(); } } class RepositoryTwo { /** * @param int $id * @return ModelTwo ...
Let's say you're given n points e.g. A(1,2) B(4,2) C(3,1) How could you reach any of the points from the orign while minimising the longest jump from point to point For example: A: OA, B: OACB, C: OAC But this closest point approach won't always work as you risk getting further away from the target Can anyone help me g...
The task is, Given a list of files, for each file do some processing (sub-tasks) like encoding and encrypting. In the following implementation, I used Composition where MultiFileProcessor uses FileEncryptionService and FileEncoderService, The problems I can think of with this design are MultiFileProcessor is dependent...
I have been given the job of a colleague who has resigned and I don't know where to start. I hope you can give me some hints: It is about a CMS made from scratch (Javascript/jQuery/PHP/MySQL) which Lighthouse (Google Devtools) has given a performance score of 43 out of 100. The page after logging into the CMS takes abo...
I'm learning about testing. So far, I kind of get the gist of it but it's still a bit confusing. I thought about an app like Photoshop. Unit testing would be the developer testing the 'cancel' button. Integration testing would be the QA team testing all the buttons that have been combined into a menu and see how the ch...
For a RESTful API, consider a model schema as follows: MyCoolObject { field_a field_b field_c } Is it better to create one update endpoint to update one or many fields on the model? Or create one endpoint per field that would only update that one field?
Let's say I want to add tests to a software that has some flaws/bugs. I want to add the tests before I fix the bugs. And I want to actually merge them in the main branch, not just have them in a feature branch or bugfix branch somewhere. (EDIT: See below as to why I might want to do this.) If this is relevant, I am wor...
I am building a fitness app and I'm trying to figure out the optimal way to store the data is a MySQL database. I would like to have specific programs (for example, 'get jacked'), I would like a users to be able to complete a program as many times as they like and log their personal results. Here our my thoughts on how...
I am working on a booking app where I need to book appointments, I want to return the most appropriate HTTP code that says that the booking slot wanted by the user is not available, that it's not possible to book at that time due to the non availability of the other user ?
I'm trying to create an interaction system for a game I'm developing with Unity and C# and I've been struggling with it for a while now. It consists of interactors and interactables. The idea is that interactors are responsible for initiating and finishing the interaction, and the interactables handle the actual intera...
I'm writing C++ code, where the standard library has an idiomatic type for representing sizes: std::size_t. Now, I'm writing a function which counts certain kinds of objects; and these objects have indices, used as their id's, which start from 0, with some indices in the middle possibly skipped due to device issues - a...
I'm working on a FOSS library whose versions are all 0.x.y . I am wondering when to bump the version up to 1.0. On the one hand, the switch from 0 to 1 suggests a level of maturity, of the software being rounded out. But on the other hand, a major version increase above 1.x is more likely to indicate a fundamental chan...
I have a concept in which a user selects a country, which will either filter or go to that database; I was thinking of alternatives or options that would help in the process. These are my first plans or thoughts for the idea's specific options. And before I go further, I am currently using the MERNG (MongoDB, Express, ...
Why doesn't PHP support function overloading (even though it supports type hinting)? For example why we can't do something like this: function foo(Student &s) { } function foo(Employee &e) { }
Here is a sample method: @ApplicationScoped public class MyClass{ public void getUser(@Min(1) int id){ //get User logic } } I'm in a CDI environment with @ValidateOnExecution(type = ExecutableType.ALL) by default, so I don't have to write any validation logic inside the method body. Here what happens i...
I've been having the problem that at the beginning of a new project, I'm likely to switch frequently between tasks in a way that (to me) doesn't seem very conducive to small single-concern commits. For example, for a full-stack project, I'll be implementing views, components, an api interface, project config files, a r...
How would I create for example a live chat, where you "post" a piece of text and it is displayed to other users in a "chat room", without the need of permanently storing it. My initial idea would be to create an object: chat room where the last couple of messages are stored as attributes in an array or something, but I...
I'm building some software that behind the scenes needs to communicate with hardware via a "message" API, over a named pipe. For example, I can send this message: <?xml version="1.0" encoding="UTF-8" ?> <bts version="1.0"> <cmd>getdevinfo</cmd>//Tells the hardware the message type, or command. </bts> Here comes ...
I work with a specific engineer (let's call them X) that, even though they have many years of experience in the industry, has a lot of trouble to manage the scope of code changes. For example, say that we as a team have estimated that a task will take '5' story points, X will claim that all existing code is 'bad' - and...
So, currently I have two models: Post and Comment. Where a post can have multiple comments. I have an endpoint named Posts and an endpoint named Comments that is called to retrieve comments of a post. currently I can call /posts to retrieve all posts, or call /comments to retrieve all comments. But how do the url's nee...
I used docker to containerize the node.js express app and used GitHub action to add the .env file in the container. I googled this method when I was doing the DEV project. But I think that if someone gets the docker image then they can easily find out the .env file. So I wanted to know what’s the industry standard used...
I have the following UML class diagram in a C++ context. I want to make sure that a Customer can have only one role: Can the Customer now only assume one role, and what does <<abstract>> have to do with this restriction? Do I even need to make customerRole abstract in this case?
I'm facing a scenario where I have a microservice that fetches possible filter values as the user is typing a query. Ex.: As the user type "city:", the possible values that could come is: Rio de Janeiro, New York and etc. And the possible values comes from a variety of databases or even other microservices, each filter...
There is a practice of showing bullets, not characters when a user inputs a password. Is this security through obscurity? My first thought was that it's not, it's not really a system, we know how it works, one bullet = one character. It's just not showing the password so I don't think the definition of security by obsc...
I am rather unclear about how an event gets processed when a state machine has orthogonal regions. I did read that With composite states, that an event should be sent to the innermost state, and if that state doesn't handle the event via a transition or action, than it goes up to the parent. Are ortho regions similar? ...
I generally understand the blockchain framework. I have spent much time learning about how it, potentially alone, is able to provide for a decentralized system. For TRUE/ABSOLUTE decentralization, it is effectively required. This much I understand. What I do not understand is what benefit they provide over conventional...
I need to maintain a queue of resources in a cache such that when multiple clients try to pop elements from the queue concurrently, each element would be uniquely returned to only one of the clients. Is redis list a good option for this? What other options can I consider? Also, what is the property I am looking for? I ...
I am a junior iOS developer and here at work I find huge files with sometimes over 10,000 lines of code. Is it a good practice to put this many lines in a single file? Or is it too much. Is there any rule of thumb which defines the length of file or better readability of code.
Since python 3.7, it is guaranteed that dictionaries maintain insertion order. The linked stackoverflow Q&A states This simply means that you can depend on it. Is it good practise to depend on this fact? On the one hand it is a language feature and can be used. On the other hand, there are probably many python develo...
The problem: I have a application where the data comes from SQL tables. The design of the tables differs a bit from client to client. Example: ClientA sells thermometers and the product has features like measuring range, sensor length and nominal size. Client A has a table 'ArticleFeatures' with the columns range, send...
I have a pretty high level question for you and am looking for some different experiences and input. Does anyone publish their own private or public packages for their own personal convenience? Obviously you encounter many instances of publishing packages in a general sense as a software developer. But I’m wondering if...
I'm in a project that computes a lot of metrics with Python code. We need to document how each metric is computed, inside the code, for readability, and outside, in some Wiki, for non-technical people. These rules can be resumed as: To compute "number_of_sick_days": - Read the attendance file (which is located in mycon...
Can cache be shared among services via Redis/Hazelcast? I have a few microservices A, B, C etc. The Microservice C is mainly for helping other services. Service C periodically updates cache - so that Service A and B can read from the cache - if cache is not present, then they use some default values. I feel like - desi...
I have previously asked a question on this forum linked here. In short, I wanted to not call 3rd party APIs when developing locally. Based on the wonderful answers received I have opted for the following: // /common/infra/emailer/emailer.ts export interface IEmailService {} // /common/infra/emailer/implementations/se...
What do I do in this situation? Do I just initialize dummy functions in place of signup, login, and logout? It seems so unnecessary since they are defined in AuthProvider. type AuthContext = { username: null | string, isAuthenticated: boolean, signup: (newUsername: string, email: string, password: string, ...