instruction
stringlengths
34
36.1k
I have a tree-like structure as shown in below picture (as one small example). The tree consists of two different node types, that are: Data Nodes: These nodes that are colored in yellow contain about ten attributes. They always appear in the leaves of the tree. Collection Nodes: That are shown in blue. They are shari...
I am writing an application for different geometrical types of fuel tanks. I have a design problem that only at runtime I will receive the exact type of tank from the end user; and I don't know how to create/handle a dynamic object on the server side. For example, a tank can have 3 geometrical types of head: conical, d...
Given a software component diagram, a sprint could be represented as a delta of that diagram. That delta would reflect how the sprint affect the components. Each component could for example have a colour reflecting the change in state: New component, or progress on a partially complete component: green Component to ch...
I'm starting a brand new project implementing microservices with domain driven design. We will have microservices written in different languages like C#, Python, and Node. I'm thinking about hosting these microservices as AWS lambda functions and using SNS and/or SQS for event pub/sub. My first attempt at hosting C#...
There is a number of questions about the differences between UML Association, Aggregation and Composition out there and many many answers, some practical and some phylosofical. Here I'm asking we talk about practical differences! In some answers I found: Reference languages like Java can't really implement Composition...
I've recently started reading about CQRS, DDD and EventSourcing. From what I've read one of the best ways to do ES is to have an event store and then a regular DB or cache for easier querying. However, something that confuses me is that in some examples I've seen both of these scenarios: Store in event log first and t...
That is, let's say I have a model that's used in several views. Should I create a single view model to represent it across all those views, or should I create a separate view model for each view that uses the model?
I've got to build some somewhat complicated WHERE clauses in SQL for a project I'm working on, and the clauses feel very hierarchical with their combination of ANDs and ORs. Instead of: WHERE ([userId] NOT IN @excludeUsers) AND ((([firstname] LIKE @nameFilter) OR ([surname] LIKE @nameFilter)) AND (([jobTitle] LIKE @in...
I have an Acconeer XB112 breakout board and an XM112 radar module. It all works just fine per the Acconeer documentation and tutorials. Now I want to modify some of the code to output to a GPIO. My problem is that there are six different header options: two micro USB (J1 & J2), two 2x5 headers (J5 & J6), a 2x30 boar...
Suppose that I have a Value Object representing an Image URL of a Cake. To check that it really is a cake, I make an asynchronous API call to a server that checks whether the image really represents a cake. Would it be ok to put this kind of validation inside the constructor of the Value Object? After all, I can't iden...
This is for C#. Ok so I'm coding a very basic money-managing program. You have an account with money in it and you deposit funds into it or you withdraw funds from it. Obviously you don't want to accidentally perform the same transaction twice, so I'm trying to throw an InvalidOperationException when a transaction has ...
I am trying to understand processes and their use in software engineering. Not processes in general but rather creating a process from within a program. It seems a really powerfull tool and i have a feeling that it is used in some very important areas of software engineering. Why would someone create a child process? W...
I'm currently writing unit tests for ASP.NET Core Controllers. Some controllers inject UserManager<T> which seems to be a really hard type to mock. After some attempts to mock or even fake it, I eventually had the idea to create a facade to wrap the UserManager<T> and inject the facade interface into the controllers in...
I have implemented pagination using SQL and stored that result of search into temporary table. Temporary table is named after unique tab id. So that other tab can have seperate result sets. That table can be deleted using unload event of browser. Now issue I am getting is, sometimes browser crash or system restart, unl...
I have a class which has one method that is called from another class. This method internally calls several other methods to do its work. Those other methods are all public and can be called by the other class but I don't use them that way because I'm trying to follow the "Tell-Don't-Ask" principle. All these methods r...
I have this class diagram exercise in UML. The main problem was the permissions are the works, which I did not know very well how to model it. The specification says: Users can publish their work on a website for external users. In this process the work will be equipped with a Web service interface. The environment ...
The question/title might be ambiguous, so please feel free to improve (or even migrate if necessary) it. My primary concern is what are the innovations of relational model/theory/databases? (In particular, so groundbreaking that it deserves a Turing Award?) It feels to me that regardless of the mathematically notation ...
Suppose I'm in some function of class A, in this function I define an object of class B, say b, and call some function using b.func() which updates some values and arrays, say x and A. Then, I create an object of another class C, say c, and call one of its function using c.func(). This function is supposed to use x and...
There is a number of books written about OOAD (object-oriented analysis and design). A few of them can probably be considered good books, written by people with a lot of experience in the field. One could say there is reasonable agreement on what OOAD is, to the point he/she could read a few books and not find (very) d...
In one of his books, Robert Martin provides an example of test-driven pair programming conversation while developing a Bowling Game Scorer in which one asks about user stories' inputs and outputs. The inputs are throws and the outputs are scores. So I realized I had never thought about a requirement's inputs and output...
TLDR: In a Headless CMS (or a Decoupled CMS), the content retrieved by the front-end needs to be identifiable (somehow). This is where I'm stuck. I can describe my guesses of how platform-agnostic content might be made identifiable (see my attempt at a guess below). But I can't find real-world confirmation of tried and...
I am currently in the process of creating a use case digram for a new system that we are building and have stumbled upon an interesting scenario. The system has a number of primary actors which include Corporate and Non-Corporate users. Each of these users can “do something” within the system from a variety of differe...
I would like to generate analytics on a per-user basis on how many times they've viewed a particular page for 7 days, and how many times they've viewed a page during their lifetime as a user. This will be tracked in 1d, 7d, 14d, 30d, and lifetime intervals. If a user visits the page today, they will appear to have 1 vi...
The current workflow we have in place at my company with regards to git is: Develop on a branch Push every so often When done developing, open a pull request in Github We have a reviewers on that pull request where they comment suggestions for improvement. However a lot of the changes they are requesting can be made ...
I am trying to design a Rest API backend based on Loopback. Since I heard nodejs is not very good in computing since it will block the thread, can I make a async call just for using java to calculate them, but also host them on same server where the nodejs application is running.? This way it willbecome non blocking. I...
I have the following setup: different teams shared eslint config (that imports airbnb rules as a basis). Whenever a developer decides to update libraries, if eslint/prettier have updates, it's a pain. The main reason is becuase normally eslint or prettier are introducing new rules. If we update these libraries, they ...
Abstract: I'm attempting to create a "data interoperability API" or in other terms "high-level query interface API" that will be consumed by (data scientists, web apps, any who wants to query multiple datasets). Assumptions: The underlying data will usually be in these formats: 1) Best case scenario - XML (with prope...
In the book UML 2 and the Unified Process from Arlow and Neustadt has been told: Analysis classes should have 3 to 5 responsibilities But as you know we have the SRP that tells us something else!! why so happend? I'm confused Which of the following deductions is correct? Case 1- The different definitition of responsib...
I'm trying to understand why sizeof(a)/sizeof(t) is inferior for getting the length of an array to sizeof(a)/sizeof(a[0]) if just as it's possible to have different types, my elements could also be of different lengths. so what makes dividing by the element size uniform?
Background Building a mobile App for product X which is currently hosted as a SaaS solution. The product X does not support OAuth currently, implements basic authentication and generates Session token after authentication. Product X also implements SSO supporting native SAML 2.0. Use Case Mobile App also implements SSO...
A relation R(A,B,C,D) is given. C and D are equivalent (C is the course ID and D is the course name, one implies the other). C and D are prime attributes. Does that violate the requirement of 1NF or any other NF?
Writing automated unit tests is followed as a part of our development process. We also do have an established code review process for the development code that is written. Should the test code be reviewed? If yes how to make it less time-consuming for both the author and the reviewer?
I understand an interface is a contract and if a class implements that interface, it must define those abstract methods from the interface. What I don't understand is, how is data passed between two classes that use an interface? So for example: In Android, a Fragment has an interface, say OnFragmentInteractionListener...
I'm writing my first Redux app. In my store, I have ~300-500 Island objects that I retriev from an API and index by an id string in an object (being treated like a map). When I'm editing one of these Islands by setting editId in the store, the buttons for the other Islands need to be disabled. I can think of three w...
I have been trying to use Node.js since it was first released, and in all of the intervening years, not once have I encountered a single Node.js project that worked as described when using the directions for initial setup, testing, and/or deployment in that project's official documentation. Is this due to immature pack...
I'm trying to find a good way to manage permissions for a high number of mongo documents. What I want to do: Apply group/user/and or application permissions to mongo documents. Idea 1: Use mysql to control the relationship (con's duplication of data, 2 diff systems) Idea 2: Add metadata to each document (con's: would ...
I'm struggling to find how to correctly design a database in order to store and retrieve data for my software. Basically, I'm designing an application for a gym (C++, MySQL with PhpMyAdmin): each user (unique ID, name, surname) can have one or more training routines a training routine is divided in training schedules ...
Currently I'm developing a movie reservation system for diving into Spring Framework. I'm using Spring Data JPA for database modeling. I have several model classes but I am stuck with time-based logic in my application and can't finish modelling phase. Here's the general design of my classes. every CinemaHall has one ...
I am developing an app and splitting this into microservices. The app is a booking system. There are two microservices - 1), bookings and 2) company details. For the bookings microservice, this contains entities such as customers, bookings, services, etc etc. All these entities are related to each other @ the database ...
On Android, do people create separate apps accessing the same database? For example an app that has users, producers and a customer support. How can one decide if it makes more sense to have a single app for this case, or multiple apps accessing a shared database?. For example having a single app and classifying each...
Please help me to understand what is event based data integration in simple layman term with some examples? How it is different from other form of data integration. Some sample use cases will be additional help. Thanks, Rajneesh
I'm not sure if this is the adequate site (maybe CodeReview?) but it's the only one here in StackExchange that have got a "clean code" tag ... There is no need for downvotes if this is not the correct place just inform me in the comments and I will move it. I've got this piece of java code private void executeCommand(...
I would like to use UML diagrams to show some processes I am designing and would like to implement. The processes involve using a queue, and adding and taking out elements from it. In one of this process the adding and taking out elements are done by two different threads. In the other, both operations are done by ...
In order to build a messaging app, I have followed this example : https://github.com/gorilla/websocket/tree/master/examples/chat This consists of a Hub, running in a single goroutine in the program, which binds together the Clients (the intermediary between the socket and the Hub). In this example, each Client (connect...
I wrote this class: using System; using System.Threading; using System.Threading.Tasks; public interface IJobScheduler { void RunDaily(Task task, int hour, int minutes ); } public class JobScheduler : IJobScheduler, IDisposable { Timer timer; /// <summary> /// Run the ...
Don't be afraid to make a name long. A long descriptive name is better than a short enigmatic name. A long descriptive name is better than a long descriptive comment. Robert C. Martin Did I understand Clean Code right? You put the whole information that you would put into a comment into the class/method/... name....
One common issue with secure passwords is that users tend to "cheat", one common cheating pattern we meet recently is the "password swap" antipattern where the user basically keeps using the same two passwords forever. e.g.: Password1! Secret2$ Password3! Secret4$ This antipattern works because: any new passwords is...
In the project I am working on we are building a feature where you have a file with 2 buttons. Button 1 opens the file in your browser, button 2 starts downloading the file. I see these as 2 distinct interactions. We are using Angular 8 in the front-end and ASP.NET 3.0 in the back-end, but I think the front-end stack ...
I am trying to build a system that tells the user on which platforms (like Netflix, prime, etc.) a movie or series is available. What is the best way to go about it? I have considered the following: Scraping the web to collate this information (it seems too unwieldy) Manual entry in DB (along with scraping to adjust ...
Last time I used I created a REST API client in .NET I used exceptions to represent status codes which don't indicate success. (404 was returning null). It's been quite some time since then and my ideas have evolved a bit. Now I am using Blazor for part of my project and I am faced with the problem of API client design...
Let's get to an example. Suppose, I have a Course object with the following properties: (course' code, course's title, credit of course etc.). When expressing this as a JS object, I can do it in the following ways: 1. const course = { course_code: 'CSE123', course_title: 'An example title', course_credit: 4...
I have used Utf8Json a lot (it is very good) but have since adapted some lower level code and started using Utf8JsonReader directly. Looking into the code of the Utf8Json library, I see JsonSerializer.DeserializeAsync as ultimately it is using the System.IO Stream class which itself has Stream.ReadAsync functions. Look...
I had begun scouring my code for optimization opportunities (execution speed, data parallelism, workload parallelism) yesterday when I noticed that there are very few opportunities for speeding up integer divisions. Integer division is heavily used in a hot spot area. Not only is it slow relative to the bit shifts, it’...
I want to write a program that performs heavy computations and I want it to be as fast as possible, so I choose C to be the language. Nevertheless, I was told that in spite of its simplicity and high efficiency one can easily make things slow instead of fast AND get himself absolutely nailed into his feet. Okay, so if ...
Often, when any low-cost computer peripheral device is sold, it is sold with a CD containing the device's controlling firmware. Why can't it simply be sold with the firmware pre-installed by the manufacturer so that it does not rely on the host system itself to do this task? Does this have to do with price/memory const...
I am looking at all the green and red boxes here, and am wondering what it would look like if one were to "implement TLS" today? What should you implement if you were to implement TLS today? Do you need to implement all of the previous versions? (SSL 1-3, TLS 1.0-1.3) Do you need to implement all the cryptography algo...
I have two approaches to solving a problem but I don't know which one is better. I will give a simplified example. First approach The database will look like this: color | -------- FFFFFF | 0000FF | The code would have to deal with the specific values and do something like: If (color == 0000FF) displayBlue() If (c...
The rule I was taught: "the method should be in the Object that it is invoked on" a student joins a course => the join method should be in the Course class a player drives a car => car.drive(..) but another possibility is: the join method is in student. the course has an addStudent Method. the reasoning is "I tell ...
I am going to use the FreeRTOS on my hardware platform. My plan is to model individual tasks as C structs containing task execution period, task priority, task stack size, task name and maybe another atributes. Then I am going to define public “constructor” function called task accepting values of individual task attri...
I have a function whose job is to look through a string that is a post's content and find certain pieces: public static function findInsidePostContent( $post = Null ) { //post_content comes from a WP_Post object. $post_blocks = \parse_blocks( $post->post_content ); //Look inside, do some things. } The fu...
Context: I am a new hire out of university at a large software company tasked with either refactoring or re-writing a large legacy method (~500 lines, ~2000 lines expanded with private method calls) that performs a complex workflow with many responsibilities. You can imagine it applying a complex series of interdepende...
I have X number of servers in NLB listening to an event that gets published by a backend system. I am planning to develop a windows service that listens to the event and then calls an internal API. Here, each server in the NLB is subscribing to the event. Is there a way that I can make sure that my API is called only...
Say I have 100 users, each with varying strength, and each with a top 5 set of "preferred teammates" and a top 5 set of "preferred enemies". I want to sort the users into two teams. User { int Id; int strength; List<int> PreferredTeammatesIds; // arbitrary limit of 5 List<int> PreferredEnemiesIds; // arb...
I designed a rest api software with 2 simple layers: Controller and Service. The controller handles the coming http request and redirect to a service method. In the beginning of development every was going well with the standards CRUDs. The problems now is the complex reporting query. For each persistence entity I crea...
I've a JSON file which I'm trying to de-serialize into POJOs. public abstract BaseClass { private String baseClassField; abstract String execute(); } ClassA extends BaseClass public ClassA extends BaseClass { private String classA; private SomeInterface interface; @Override public String execute(...
Problem description Publisher-Subscriber architecture with a central registry where agents can either promote their capabilities or search for a given capability. The project must be developed with C/C++. A GUI used to compose a chain of agents is a nice-to-have (not necessarily C or C++). Current state of my thinking ...
I've really been struggling with this concept a lot in my head, and I was hoping I could get a poke in the right direction here... I have a process that is supposed to take a certain number of phone numbers and send them all text messages (through Twilio). That's all fine and working...my problem is, I don't know how t...
How would you architect a simple cascading stylesheet like inheritance object? For example, I have Apple that extends Fruit. class Fruit { constructor() { this.total = 10; } } class Apple extends Fruit { constructor() { } } On Fruit there is a property named total with a value of 10. The a...
To make a long story short, I needed a property of a button to act as a "secondary text property" and retain the original .Text value of a button, and the only String property that wasn't ReadOnly was the .Name property. I was sure it was going to break on runtime (as tons of code references the name of the control) bu...
I am in a situation right now where a solution has been proposed that uses a csv file. The proposed file structure essentially contains three atomic values; ID Thing 1 Thing 2 Fine. As we were discussing this solution, someone mentioned that some customers might use our ID while other customers might use their own, d...
I know that: Computer keyboards have an Escape Key The symbol for the Escape Key is U+238B Broken Circle with Northwest Arrow (⎋) and I also know that: HTML5 & CSS3 both have escape characters Javascript has the backslash escape character (\) etc. But are we using the same word "escape" in these two distinct contex...
Some background: We have similar entity stored in different databases because historically the entity used to come from different vendors(and it still does) and we stored it in three different databases. All the DBs have SP written over them which returns the entities based on few filter.Table schema of result set retu...
I want to add some custom retry logic to the AWS sdk (but this isn't specifically about that). So whenever it throws a specific network exception it waits and tries again and whenever it throws a specific auth related exception it calls a function that tries to update it's credentials and tries again. I want to avoid a...
I have a build pipeline that builds my C++ project on Windows, macOS and Linux. The build process generates 100 libraries and files on each OS. So I have a directory with these files, and I want to package them proberly. File foo.dylib goes into osx.zip. File bar.dll goes into win.zip Is there a standard format for thi...
I'm trying to engineer this: 200 subclasses [ Derived Classes ] After a subclass is defined, I wont need to edit any other file. [ Decoupled ] Subclass Definition registers itself. [ Definition is Registration ] What I could do instead: Create a class [ One big one ] Create an enum value (or similar) for every func...
I work for a small-medium sized startup with a development team of 20 people and a very strong engineering culture. Engineering itself is split into smaller sub-teams and I am the only person responsible for a particular component (which is quite critical to the whole organisation). We have now finally managed to hire ...
I have a multi-language web site. On the web site, users can search products and services by geographic areas. I am asking which is best approach to performs search of geographic areas. In this moment I am using geographic coordinates. I stored in my database the boundaries of different areas, then when user input a c...
I want to clear my application cache after updating an element of my domain. In that case I raise an event NodeEndPointReferenceChangedEvent from my Domain Layer. The cache in managed in Services Layer. I'm not sure where I place the NodeEndPointReferenceChangedHandler who will be responsible for catching the event and...
I wanted to ask about your ideas on how to solve the problem that I have to solve in my application (App1). This is the classic Fronted + Backend (Angular + Java EE) application to which I am currently adding authentication and authorization. However, the matter does not seem to be simple for several reasons. First, th...
I'm learning about Software Architecture and especially about scaffolding large-scale architecture and patterns for modern web applications. I've noticed that I don't have a pattern for data validation or rules, sometimes I add validations or checks () in client-side layer and others in the server-side or by adding req...
I'm new to API design. I've been reading numerous threads RESTful vs RPC patterns for API design, but I feel like none directly addressed my exact use case, so I just wanted to get a second opinion. Let's say I want to build a web app which recommends neighbourhoods to live based on two criteria: Your income (i.e. wha...
I am building a system composed of a few micro-services over AWS. I encountered the need of a certain MS to do the same logical work but of a big range of work load. for example, the same logical work could need 2vcpu and 4GB ram and another will need 4vcpu and 16GB ram. What is the best practice here? have all the ins...
Let's say we have a situation in which we have a particular entity, for example an User which has a set of related entities e.g Book. At some point in time, a group of users phisically receives a new Book. That means that each user in that particular group has now a new Book. At this point someone has to connect to a p...
We have built an iOS/MacOS library, that is being used by several iOS & Mac Apps of a very big company. The library is being distributed through Cocoapods and Carthage, the package managers for iOS and MacOS libraries. We have pipelines set-up to build on every commit. The test suite of Unit Tests, UI Tests and Integra...
I have had hard times naming boolean fields. On the one hand, i've read that it is good to name them as affirmative statements, like hasAge, or canDance. It's not a problem when naming local variables, for example boolean itemIsActive; boolean everyItemHasName; But i don't see how these rules could apply this to field...
I'm at the stage where I'm taking my MVP app and trying to refactor and structure it in a way that it is maintainable and extendible. I'm new to software architecture or design so I'm having early struggles deciding what pattern would suit best my application. How do I go about and investigate if Domain Driven Design ...
I am building a SDK that will simplify the use of my API. The problem is if when I have to return property of type enum. For example, I use strings instead of int for displaying enum such as { "type": "CAR" } instead of { "type": 1 } Now, my question regarding SDK design/development is should I parse this "type" pr...
I created a forum where I want to display notifications and messages as soon the user gets them. I don't want them to need to refresh to page to see if any notification/message been sent, but I also don't really want to implement 3rd party (like Pusher), that's why I thought I would go with polling. Basically, if a use...
I know difference between waterfall and incremental strategies. But I'm somewhat confused because I see that there are methodologies which use incremental or iterative approach but I cannot see any examples for waterfall strategy. For example Scrum is a methodology that uses incremental or iterative strategy but is the...
I don't think any of them are good practice. In addition to that they make the code longer. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for Optional initialization var i = 0; for (; i < 9; i++) { console.log(i); // more statements } Disadvantages: Can have side effects Option...
I have come across a small issue with the git work flow in the team. When starting to work on a user story, we create a feature branch from the develop branch. Once the user story is finished, a pull request is created and another developer completes the code review. Then the QA tests the feature on the feature branch...
I am working on an API that allows a client document to updated under the endpoint of PUT /client/{documentId}. As part of this document, I need to include an extra field 'ReplicateInManager' that notifies the server as to if the document needs to replicated in an external system, alongside the database for this API. I...
I am in the process of refactoring a large C++ code (~2300 files, ~600K lines, mostly older C/C++98 style code) and there are definitely memory leaks that could be shored up using C++ smart pointers. Is there an incremental path towards migrating towards smart pointers or is this an "all or nothing" proposition? For ex...
After reading/watching a lot about Event Sourcing, there is one thing I don't fully understand: Events that lead to triggering of other events. Let's take StackExchange's "close question" feature as an example. The feature requires commands like VoteToCloseQuestion, and CloseQuestion (direct close for moderators), an...
I am trying to learn DDD. I am modeling a property management domain and I think I have two contexts (subdomains?): a property management context and a resident context. Let's say I have an aggregate root Apartment, that holds Floorplans and Units. Each Apartment can have many Floorplans, and each Floorplan can have ma...
I'm working on a Python application in which there are two Singleton classes: App and Configuration. The former seems straight forward, only ever instantiate one App instance; the latter seems controversial. From the searches I've done, I need Configuration to be accessible from other modules that update the applicatio...
Let me start by saying that I'm not questioning the utility of encrypting EBS volumes, nor asking how it works. I'm just wondering what specifically encrypting EBS volumes is protecting against? For my personal laptop, the reason to encrypt the hard drive is if it ever gets stolen, while the thief could create a copy o...
I was reading about the clean architecture, and I don't get this part: Don't use your Entity objects as data structures to pass around in the outer layers. Make separate data model objects for that. As long as I don't let the entities leak out through an API - that's why I create Presenters -, what's wrong with letti...
Im looking for a good way to find a value from the given list based on a text. Example: This computer has 16GB ram and with the best processor in it. Case is made from aluminium. And I have criterion like amount of RAM with possible values: 4GB 6GB 8GB 16GB I can't do search for value in text because it can find e....
I've got an Algorithm class whose responsibility is to find if a given word is in a list of words. As part of doing that, the algorithm first has to lowercase the words, remove punctuation, and remove any stopwords. Then, finally, the algorithm tries to find the given word in the cleaned list via the find_word method....