instruction
stringlengths
34
36.1k
I'd like to build a client/server application that doesn't require the client to open a port in its firewall for incoming connection requests. In other words, the clients will be able to communicate with each other over the outgoing connections that they initiate with the server. This will be very similar to, for examp...
I am trying to abstract some functionality from my desktop application (JavaFX) for changing views. So, what I am thinking is: Navigator interface with methods like goToAccountsOverview(), goToAccountDetails(Account account) etc. The implementation will depend on a ViewFactory to create the Views and a DisplayingViewCh...
Typically the way to communicate between parent <-> child component in Vue.js is to send the child a prop and emit an event from the child, which is listened to on the parent. However, if you pass in an object to a child prop, updating the object in the child will update the object in the parent as objects are passed b...
In DDD, creating smaller aggregates is encouraged where possible, but in a system we are designing we are running into an issue regarding the identity of aggregates. The system evolves around phyisical events, like music festivals or sports events, and within these events there are separated bounded contexts representi...
As I understand the "Same Origin Policy" is a browser security feature that aims to protect the user. It prevents scripts to load data from another webserver (typicall with ajax). So esentially there are 3 actors: The User in the Browser The Original Website The "other origin" Web Resource Does it protect the user ? ...
Let's say I am designing a TODO application and therefore have an aggregate root called Task. The business requires to keep a list of TaskLogEvent that provides them with a history of how the task changed over time. As the Task may have hundreds of these events, I will model this TaskLogEvent as a separate aggregate ro...
This is a theoretical problem that bothers me. Let's say we have following, simplified structure: interface ParagraphInterface {} interface ParagraphGroupInterface { public function getParagraphs(): array; } interface ParagraphRendererInterface { public function render(ParagraphInterface $paragraph): string; ...
I have a resource file called AppSecrets.resx, and the bit of code below to check the login credentials of the "super duper admin user". This admin user is distinct from normal admin users, as it is hard coded into the app. It works, but could someone sniff out the contents of the .resx-file on a live website? Or is it...
I am considering a new scheme for order numbers for our ERP system. For reasons I'd like not to get into, the number must be fairly easy to remember and must say something about the time (or at least sequential order) the order was placed. This eliminates things like UUIDs as an option, since those are both very hard t...
Since entering software engineering, I picked up the habit of saying "machine" when talking about a computer. Most of my colleagues seem to do the same. However, when I use this idiom in everyday conversation, people get a bit confused. Obviously, a computer is a machine. However, most machines are not computers. So it...
I have two async streams suppose- Trip : {tripId, date, city} Bill : {billId, tripId, date, amount}. I need to design a system to get real time aggregated view of following nature: City, TripCount, TotalAmount. Events in both streams can be out of sync or duplicate. But result needs to be accurate and realtime. My Solu...
My layers are like: Controller (Http) -> Use Case -> Domain Services Imagine that I have a PurchaseController which is just getting the parameters from the Http Request and calling the PurchaseUseCase. This PurchaseUseCase is using some domain services (like an OrderRepository, etc) But, it needs also to get informatio...
I have a project coming up where I'm supposed to upgrade an existing access app to a .net architecture. I'm wondering how to design object-oriented models from the giant tables and multiple relationships between them in an ERP like system. For example, if I have an Order object, the orders table alone has 20+ columns w...
I'm working through a book on writing Single Page Applications in Vanilla Javascript. (I'm working on a project where I'm not allowed to use React or any other frameworks, so I'm trying to get better at structuring vanilla SPAs.) The book is fairly old, so I'm trying to rework some of the examples using more modern Jav...
I am fairly new to web development, and I am learning to build web applications. I am facing a problem figuring out how to set up authentication mechanisms for a multi-user application. Let me provide some details about the architecture: Here I have two web servers - Front-end application (written in Angular) and a ba...
In typical online review system if any user give review on specific post or others thing, then when that user view that post his review show first. The perfect example of this is Google Play Store. If i give review to any app, than when i go to that app my review show first. Now i want to implement review system in my ...
I am currently in the process of creating a Django REST framework project for a client server web app. I would like to ask the following: Should I write a custom admin if I want my app to be production ready, or is the DRF admin sufficient? If I were to write a custom admin page, should I separate admin endpoints from...
Given this generic class and constructor, class A<E extends Number> { A(E number, Comparable<E> comparable) { //... } } it is ensured that a call to the generic constructor will check the arguments' types at compile time: new A<>(Integer.valueOf(4), Integer.valueOf(4)); // ok new A<>(Integer.valueOf(4...
Which algorithm would be best for deciding which seedbox each torrent should go on? It must be able to fit the torrents in the minimum number of seedboxes, but also maximize the free space on each seedbox and equalize the number of torrents per seedbox. There may be other requirements for this application that I have...
I'm writing a hardware driver for the raspberry pi 2 with C++. The driver uses the SPI bus to talk to a radio chip. I made a class Radio and put all those functions that talks to the chip into that class. Some of those functions are writeToRegister, readFromRegister, setRadioPower, enterSleepMode readTxBuffer, readRxBu...
I am designing a CI system where I need to leverage a database as part of the software build process for integration tests. Different developers on different branches of the same repo will want to run a build on their code. I am struggling a bit on how to design the the database integration. As part of the process the ...
We currently have an application that is nominally written in Java/Spring boot, but all of the control flow is in NiFi. For example, there are the following layers in the java application: Controllers take an object and return a service call (literally 2 lines) Services pass data to a transformer Transformers pass dat...
There are X Million Shipments per day. Each shipment has about 50 metrics to be calculated. Each metric is calculated based on a type of the event(Let's say event_1 has the required information to calculate metric_1, event_2 .. metric_2 and so on). All the events are independent of each other apart from one dependency,...
While working on a refactoring task of a legacy app, I came across a scenario where a series of cause->effect type events are happening and currently everything is being handled inline. To give you an idea, a user uploads a file, then it is converted into a number of format, and on completion/failure of each format con...
I'm having some problems with deciding where to set the content-type header in a vanilla mvc framework. Should i add it inside the controllers method: class ApiController extends Controller{ public static function v1(){ header('Content-Type: application/json'); //some logic to output some json ...
I have a small system written in Go with aprox 10 services, and 3 DB (InfluxDB, Postgres, Blockchain) Each service use InfluxDB (some service read, other write), and postgres ( Readonly). I see 2 options: In all my services, I use a client to connect directly to DB Pros: I already have it this way. It is easier t...
I’m trying to write a parser in JavaScript that is able to be interrupted by the fact that the entire input source is not available during the parse. When subsequent chunks of the input become available, the parser should be able to pick up where it left off. Tokens in the grammar being parsed includes multi-character...
I'm implementing a simple command line game using TDD principles and Unit Testing. My goal is to implement the whole game using Test-First Programming, so every behaviour/class is created from a test. I've already implemented things like a Player (the game needs a player), the Enemy (the player fights the enemy) and ot...
Say multiple branches are being developed, A and B, as well as a incremental "bug fix" branch C. Now C is already "finished" and merged into master. A and B are still in development and will not be fixed before (maybe) another bug fix branch is merged into master. Is it a good idea to merge C as soon as possible in the...
I would like to introduce permissions based access control in my Single Page Application (SPA) front-end which authenticates the user with token based authentication (JWT). Permission Requirement: In my SPA, each required (html) element is mapped to a permission and depending on the availability of the user permission,...
Background: I'm trying to separate my concerns in the application architecture the best possible way. In a nutshell: The requests are parsed and go to an Action Action decides which service(s) to call Services have the business logic inside The service returns the data to the action The action returns a response Que...
I have a vanilla php api(on a vds) and I want to make data coming from that api available to a few clients that are using a python app that's also written by me. That python app is running on my client/s pc. But now i'm facing a problem: that app can be "pirated". How do I make sure that the access is limited to only m...
I work for a company in which the majority of our overall platform consists of a massive, monolithic web application. Nearly all of the application's functionality resides on 2 servers. Our main, external application, and our secondary internal application. The main application does a majority of the major lifting. Mos...
We have started trying to move toward CI and automation. There's not a lot of cross-talk between teams, and I've discovered that many have developed simple or sophisticated build & test scripts, all in the same language (Python). None of them have any mutual Git history or significant amount of copied code, but all i...
I am currently trying my hand at a microservices architecture for the first time, and I am looking to put together a multi-tenant application built on a this architecture. Tenants are created with their own subdomain, and the tenant owner can create further user accounts linked to that tenant I currently have the ident...
When you use the constructor of Lazy<T> requesting the valueFactory and mode parameters (I mean this one) you can specify LazyThreadSafetyMode.PublicationOnly. This way you can prevent the Lazy instance of caching any exception thrown by valueFactory, but at the same time you lose the ability of guarantee that the fact...
For a CI system and the developers in our team, I'd like to be able to use a specific version of a MSVC toolchain for native Windows builds. The goal is to have a well-defined consistent build-environment for all developers and for the the CI system, so that we know what toolchain was used to build a SW. Afaik, the MSV...
Let us say we have: a web app with a Postgres DB that produces data over time, another DB optimized for analytics that we would like to populate over time. My goal is to build and monitor an ETL pipeline that will transform the data and write it to the analytics DB. (Preferably using a streaming approach.) My idea wa...
Suppose I'm writing a calculator engine with a class as follows... public class ArithmeticExpression { ArithmeticExpression Add(double operand) { /* ... */ } ArithmeticExpression Subtract(double operand) { /* ... */ } // ... other useful operations like division, multiplication, etc. double ProduceResul...
What are the pros and cons to each of the following ways of logging a function call? This code is written in Ruby but I feel the question applies to programming in general. Responsibility belongs to the callee class Foo def do_cool_stuff # Do some cool stuff Logger.info("I did some cool stuff.") end end cl...
I have many dataservices/classes injected into a constructor. public MyClassConstructor (IAclass A, IBclass B, .... , IZclass Z){ ... } The number I have to pass down goes well beyond 100. To solve this I created a Injected class that contains all the DataServices. Making it more streamlined: public MyClassConstru...
I can see that integer or pointer are non-composite data types whereas record and objects are composite data type. Similarly i guessed enumeration is composite because integers or string values can be used like in an array. Turns out it isn't.
I have a Helper class and a Service class currently and I read this other question about the difference between a service class and a helper class and got confused. A method to get all products in my situation is just a convenience thing for me from a developer point of view as it is used to get all products for a spec...
I'm pretty new to Micro services architecture and trying to learn my way through them and we have a big monolithic application and as a company we want to move towards Micro Services Architecture for easier maintenance and deployments. In the process of that, we are doing a POC for the same. I have a couple of queries ...
I have worked with public API's in only one small project, but I recently learned that if one were to distribute a project with API keys inside this is a security risk. So I have two questions: What does an API key contain that would pose a security risk? How does one create an application that makes use of public API...
I am moving in the direction from database-centric design to entity-centric design (say, starting with class definitions instead of starting with a ERD), and am questioning things: Often in a database design I'll have tables that are nothing more than value/name pairs. The classic example is "type" or "genre", that sor...
Currently I am modifying an application which has a datasource and multiple configuration based on the server configuration (Staging, production etc). Each of the environment has different configuration such as the cron time and other values related to the application. Now we have a specific operation conducted by ops...
For instance, insteead of if (MyFancyObject is null) throw new InvalidOperationException(); I could simply say Assert.IsNotNull(MyFancyObject); But I hardly ever see this done - is there a good reason not to?
I want to design a Crate object. A crate is a wooden box that stores things. I need to be able to keep track of of the following things in regards to this crate: length in inches width in inches height in inches weight in pounds price of crate in dollars My question can I store all of the above in the same class? D...
My only skepticism about using microservices over REST /HTTP is that there could be a performance drop. Using too many microservices over REST, with a REST connection, the data would always first need to pass through an HTTP server and things like latency would be an issue. Imagine a data process which needs to pass-th...
I have an architecture based on a domain with multiple object types. These objects (many and of disparate types) must reside together with each other because they make up a use-case. The types are not more than 20-30, but might be added along the way, and I do not know if type-safety is worth the maintenance. Let me ma...
I have thinking about this idea for over 5 years and i don't have the complete technical knowledge to fully grasp the idea I'm having. The premise of the idea is to have an extremely high base number system like base 85 / Ascii85. Then use that high base number to express an extremely verbose seed for a pseudo random d...
I'm thinking about a structure like this. cardGame: players: - john: hand: - card: id: 1 suit: diamond number: 7 deck: - id: 32 suit: spade number: 3 And then, to draw a card there would ...
I have a webapp using ReactJS as the frontend and Rails as the backend service. I have an account manager, where a user can choose multiple avatars from a default library. This library contains around 250/300 images, and uses 20Mb of disk space. I was wondering whether it is a good thing or not to have them stored on t...
Assuming IO is not an issue, is saving intermediate results considered a best practice? What are the pros and cons, and situations that warrant doing so or not? Say I have two components along a long pipeline, others--> Component_1 --> Component_2 --> others. I can either save the output from Component_1, pass the pa...
I want to develop a new product on top of an existing public API. This will require functionality to be added to that API. How do I develop and API for both public use (by other organisations) and internal use (by my product)? I'm asking this because I think there may be conflict of approaches here. Why is there a co...
I was looking into the Enum design recommended by Microsoft (see here), and I found a statement that made me stop to think for a while: X DO NOT use an enum for open sets (such as the operating system version, names of your friends, etc.). It says that OS versions are considered as open set, therefore it should not b...
I am very much an amateur developer. I have written a web app which uses parse-server as a backend. My question revolves around how agnostic the frontend should be to the backend (parse server)? For example, on the client side (browser), I query the parse-server for data - let's say using function GetData(). My web app...
I have a question regarding scrum events that are all held in one day? For example: In the morning (review + retrospective) and in the afternoon another one (planning). Currently, I am working in a two days split scrum events and downside of that is that team is complaining that they are 'losing' their time and they ar...
Context I am having an argument with my friend on how to start implementing a Genetic Algorithm called NEAT (NeuroEvolution of Augmenting Topologies). Method 1 I am arguing in favor of having two classes, one for Genome and one for Mutation. This Mutation class will provide methods for mutating genomes by taking a gen...
We are developing a benchmarking framework in C++, with Make and CMake as build tools. The aim of the framework is to allow others who build algorithms to perform head-to-head comparison against prior work. As such, we have integrated a number of state-of-the-art algorithms which users can clone and test within the fra...
Imagine a large node.js app with a multi-purpose api for mobile and frontend with a serving static files, with a websocket server, lot of cron jobs and workers. Basically I can horizontally or vertically scale a whole app, use a load balancer and so on. But from a perspective of a business logic, whole app is one big ...
I understand that if I sell things online, I need to calculate Taxes based on customer location. Can I use IP to locate customer or should I ask them explicitly? If it is fine to use IP to identify customer's Country, is it fine to locate customer State/Province. I need it because Canada has different taxes in differe...
I recently read an interesting Article that, due to a memory Overflow error Power system of Boeing will collapse and turns the Flight into a Flying Brick. This is a low level memory Handling bug. Can this bug can be eliminated if use Programming Language like Rust. Since Rust Handles memory by Itself and It is close ...
We have several endpoints which were authenticated using a bearer access-token. There was another endpoint which will renew/generate a new bearer access-token on passing valid secret_id and client_id. Now a client is asking for a new endpoint which will give them their already generated bearer access-token as a respon...
I have to upload a TSV file to an S3 bucket, the content is form submission data. Another service will consume and do things with this data as soon as possible. The service would like one large file that is appended with each new form submission. My simple approach is submit --> download data --> append --> upload. The...
Consider these two approaches: Configuration dictionary within class DEFAULT_PARAMETERS = { "name": "Generic Room", "description": "This is a sample description." } class Room: """Base class for a room""" def __init__(self, parameters=DEFAULT_PARAMETERS): for key, value in parameters.items(): ...
We just migrated to git from svn and are trying to define a process that would help us achieve the following: Deployment to dev env without requiring code review. Have a pull request / code review process when merging into the release branch. Environment: We have a team of 3 developers. There are 3 envs - Dev, Te...
How possible is it for a non-dev, Qa person, to on board themselves to learn how to unit test production code? SI have an understanding of how code is written and understand basic logic but what do you consider the learning curve would be for me if I wanted to learn how to write unit tests for my team? Not overnight o...
At this link (https://blog.heroku.com/timeout-quickly#how-webservers-work), I read: All webservers will work in a similar way. Any new request will go to a queue, and the server will process them one after the other. This means if you have 30 requests in your queue, each taking 1 second to be processed, that will...
I need a data structure d with somewhat conflicting requirements. What are the different tradeoffs I could pick? The same algorithm will be repeatedly done on each time step: push one new element to the right (so all elements remain naturally ordered by the date they came into the data structure). update all elements....
I'm trying to practice TDD, by using it to develop a simple like Bit Vector. I happen to be using Swift, but this is a language-agnostic question. My BitVector is a struct that stores a single UInt64, and presents an API over it that lets you treat it like a collection. The details don't matter much, but it's pretty si...
I am currently working on an internal storehouse management system for a certain company. They wanted it to be a web app so that they can use it without installation on any devices. We decided to develop the system with .net core REST API as back-end and Angular web app as a front, since we are familiar with both. The...
I have one interface (let's say in C++) that has been implemented by some derived classes. Let's suppose that the interface is like this: class IBase { virtual bool method_1() = 0; virtual long method_2(const std::string str) = 0; // other methods virtual long method_10(int value) = 0; }; and up to now 6 diffe...
I want to create an endpoint for "logging out". Logging out in my case is basically removing an access token from the database. Therefore DELETE verb makes sense here, something like this: DELETE URL/tokens. Now in terms of rest it makes sense to have URL/tokens/, however it is generally not acceptable to put an access...
Say you have an interface with a function List<A> doSomething(Collection<B> bs). Looking at Java's List interface and its JavaDoc I could return an immutable List which doesn't support addition, it could also be mutable but not allow null values (which some implementations actually don't allow). Random access could be ...
The built-in logging module of python 3.x allows for 3 ways to define a custom logger: INI-formatted file dict, json, yaml python (directly in code) In my opinion, it is easier to define a custom logger's config directly in the code, because this does not require anyone to understand other formats (it is not obvious ...
Let us consider a complex form of registering a driver and owner. The driver will have all these fields: driver = { firstName: "xyz", lastName: "abc", phone: "1234", email: "m@g.com, licence: "xy1234" } And owner has the following fields: owner = { firstName: "xyz", lastName: "abc", phone: "1234", email: "m@g.com, ve...
I'm designing an API and have reached the topic of logging. I'm going to store my logs in Elasticsearch. I'm certainly going to do some logging at the time the HTTP response is sent back to the client, with info such as processing time, response code, user id, URL. Is it best practice to also send a record to the loggi...
This author writes about alternatives to docker, such as Podman, Buildah and Skopeo. In addition you can run docker images without the Docker Daemon using nspawn. But I want to run docker-compose and link my containers. I want to give a declarative description of my system to Rancher or Kubernetes and have it spin up...
I'm trying to design a theoretical programming language and I'm facing a problem with high order functions. The language is strong-typed, so the way to define a standard function is like so : function name ( type1 arg1 , type2, arg2, ... ) : return_type There's also a way to define data structures like classes (that a...
We have a large number of classes that is generated by JAXB. There are a couple that have identical fields and I want to see if there is a clean way to map class A to class B. Example: public static class ParentA implements ... { public static class A implements ... { protected String name; } } public s...
I'm trying to implement CQRS for a queue system where user can join a queue by clicking a button. The system will tell the user if queue is full. When the user click the button, it raised the command and triggered event like "user queued at 07:00 AM". The handler for this event then (asynchronously) add a new partici...
I am planning to develop an Event Planning Application. Currently I'm in the stage of planning the app structure, for example database schemas. Basically there will be two kinds of users: The event planner: Has access to a dashboard, list of guests, etc. The event guest: One guest is assigned to one event. Can...
I am planning on creating a wrapper class in c# which will call cryptographic functions provided by .Net Framework, just to make sure I am clear, I am not writing any cryptographic algorithm, just writing a wrapper to facilitate requests coming from other modules of Applications. I have seen a lot of examples in whic...
I would like to create a dll library that will be loading in runtime. The library'll be using internally COM objects with MTA flag. The library will be created in main thread. So I have question: Where there is best place where can I call 'CoInitializeEx' and 'CoUninitialize' functions. In the my dll(init/deinit functi...
This is the first time I tried TDD. At the first time, my controller tests looks like this use RefreshDatabase; class ControllerCustomerIndustryTest extends TestCase { use RefreshDatabase; public function testIndex() { // } public function testStore() { // } public f...
I want to ask: Whether the Role class violates Single Responsibility Principle in SOLID ? I think deleteAccount() is not belong to Role class but Role class is way to extend code in the future There are deleteAccount() in Role and Account. That is ok ? Admin and Moderate violates DRY principle ? Because the deleteAc...
My question is based on a few assumptions so please correct me on any of them below I know that TCP has always been socket based In order for a server to maintain that socket, a thread has to block and wait for IO on the server side A modern web server has to handle at least hundreds if not thousands of requests per s...
Right now we have a highly analytical system which collects tons of various metrics. We need to display this data in a web ui for users to consume. Since we are in early stages of development we are throwing all data into google bigquery, when a users visits the app we run a cloud function to request the data from bigq...
In my application I have entities like employee, client etc. Each of these have methods AddEmployee, RemoveEmployee, AddClient, RemoveClient. I don't want to keep fields like EmployeeName, EmployeeAddress in the same class with AddClient. It doesn't make sense to me to call something like this Client.AddClient(). What ...
I work with some not-monolithic applications, meaning that at some level, it depends on other applications to do the work. At the moment, each application on our stack, when there is an API change, generates a new API SDK, that can be used by other applications that rely on it. The issue is that this adds an explicit d...
Consider class Crate that is a value object. Crate represents a valid 3-dimensional box. In constructor I validate the given parameters, and I throw an exception, if supplied dimension parameters are invalid: class Crate { protected $length, $width, $height; function __construct(float $length, float $width, f...
I'm trying to document some of my JavaScript according to this JavaScript Documentation guide and came across member access (private, public, protected). I was wondering what the classification would be of a member/function that was defined in the child class but only available in the child class's and it's parent's sc...
The Single responsibility principle is defined on wikipedia as The single responsibility principle is a computer programming principle that states that every module, class, or function should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirel...
I am reading and hearing that people (also on this site) routinely praise the functional programming paradigm, emphasising how good it is to have everything immutable. Notably, people propose this approach even in traditionally imperative OO languages, like C#, Java or C++, not only in purely functional languages like ...
As part of a larger project, my team is building a microservices API layer. We do not have experience with building microservices so we have been trying to figure out how to go about the project. The first decision we are working on is if we should use a mono-repository or split each microservice into a separate reposi...
I read theory but I need practical architectural advice on the actual implementation in java language for microservices. In the context of the attached screenshot. Here is my setup. Order Project consisting of the following 4 Modules. Order History (Jar file, Docker Container) Order Placement (Jar file, Docker Contai...
We've been having some debate in the office as to the names used to describe C++ .lib and .dlls When creating a statically linked library, you end up with a .lib file. When creating a dynamically linked library, you end up with a .lib and a .dll Two questions: Is the .lib file that's generated the same in both cases? ...
I have a class with a (simplified) method which returns a string like this : private String doStuff(String currencyCode, BigDecimal amount){ StringBuilder sb= new StringBuilder(); NumberFormat format = NumberFormat.getInstance(Locale.FRANCE); Currency currency = Currency.getInstance(currencyCode); try{...