instruction
stringlengths
34
36.1k
I'm currently developing a project which has multiple c++ programs communicating over IPC to each other. Each of these programs will rely on some parameters to run and these may be common to several programs, e.g.parameters for camera calibration, minNeighbours, scaling factor, etc. I am wondering what the best practic...
I'm making from scratch the website of my agency, an online food order and delivery service. I'm trying to improve at best the promotion system: every restaurant has its own promotions, and some of them has a certain priority above others. For example, if the client orders three pizzas and for every ordered pizza ther...
Note that my question is not platform specific so that's why I don't add the [kotlin] tag (the code is in Kotlin). If there is a Kotlin-specific answer I'd like to hear about it though I am working on a simple component (GUI) library and I have the following interfaces: interface Component : Drawable, Positionable, Ide...
For example I have entities: Client, Report. Client may have many Reports and I think the endpoint for a single Report management should be nested like this: /clients/{client_id}/reports/{report_id} As for all the reports of one client the enpoint is expected: /clients/{client_id}/reports But how should look an endpo...
Should a resource be available through more than one URL endpoint? For instance, I have exam resources which contain multiple question resources which in turn contain multiple answer resources. The endpoints to list questions and view a single question are as follows: /api/exams/{exam_id}/questions /api/exams/{exam_id}...
Background I joined a company as a solutions architect less than a year ago, with a main task of consolidating, and modernizing legacy code resulting from 90+ company acquisitions over the past 20+ years. One of those legacy applications, is a desktop application written in VB 6.0 that accesses a SQL Server database a...
In RDBMS, goals of Normalization: Free the database of modification anomalies Minimize re-design when extending Avoid bias toward any particular access pattern First step involves avoiding redundancy etc... As data is normalised and divided in multiple tables, join operations are required to satisfy queries placed by...
My data: Size - 15+ Terabytes of text. Data: Maximum of 1300 rows (always same row headers) , Maximum of 6 columns The column headers will be different but the value are all percent values that will be between 0 - 100. The total of the columns in one row will add up to 100% always. So we can get rid of one column rig...
Each data type must be aligned to a multiple of some number of bytes, for example a short int must be aligned to a multiple of 2 bytes, and an int must be aligned to a multiple of 4 bytes. But why data alignment is used exactly, is it because the CPU can only read from memory in multiple of some number, so for example ...
I read few sentences of this. I understand that simply put, the persistence layer (with its repository objects) deals with basic data access CRUD. The service layer on contains business logic. In my view, a service object contains multiples CRUD operation from one or more repository objects. Now I was reading in a boo...
I've seen the terms brittle and fragile used to describe poorly written unit tests. But I haven't been able to find a clear definition for what brittle or fragile actually mean in this context. Is it unit tests that break for more than one reason? Is it when a test fails because something in the code base is changed t...
As I know, on one hand, the main stream opinion about global variable is, it is eval because it may make the program unpredictable : some unknown class or functions can change the value of the global variable even if they don't need to do so, so it is bad to see this: public class User{ public String name; pub...
I m currently working on a React Native application which aims to provide à huge list of items, using infinite scroll and a local state (no matter the technology / plaform, it's stored in RAM) of the app. I've currently implemented it the following way : 30 items are rendered first Scroll to the bottom of the list Tri...
I am writing a small-ish console application. I took care to be able to test the important business parts of it in Unit Tests. But having most of it finished I realized I could just test the application as a whole. Basically, I could just test Main with the proper arguments so the application will "run through" all the...
I have written a simple class hierarchy to represent terms in Scala. Terms are recursive data types, e.g., a Sum and a Multiplication consist of the left-hand-side (lhs), which is a Term, and the right-hand-side (rhs), which is also a Term. Scala's pattern matching makes it easy to check if a Term has a given structure...
I am developing an application where part of the supported features may become optional in the future, so the user can enable/disable them. However I am not aware of an approach in handling such optional features in the code. Is it just like putting checks to see if the feature is enabled by the user or not, before e...
Let's say I've got a test builder, so that teachers can create a bunch of questions for a test. However, not all questions are the same: You have multiple choice, text box, matching, and so on. Each of these question types need to store different types of data, and need a different GUI for both the creator and for th...
I'm building an application which uses SQLite, and now want to add settings that are stored between sessions I'm considering if I'm going to store the settings in a config file or if I'm going to use a table in the database for this (Please note that I'm using SQLite which stores data locally and doesn't have a user ac...
I'm developing a photo sharing website. Currently, the way I wrote it, a user uploads a photo (jpeg), which is read in as a Base64URL (using FileReader). The backend (Django) uploads this file to Google Cloud Storage (using django-storages). The view renders (serializes) the images as signed urls which are then easily ...
I had a question regarding the performance of having a class implement multiple interfaces. Is there any degradation in having a class implement 2 interfaces vs 10 interfaces? Background This question comes from investigating Microsoft's Identity2. I noticed that there were ~6 replicated DB calls during the ClaimsId...
I'm having difficulty understanding why you should develop internal libraries to be used exclusively for developing internal applications. I appreciate that if I want to use software that someone outside the organisation has written then they can send me their header files and .a or .so files and I can just link it to ...
Is there any way to safely include libraries (either internal or external) in the directory of a project (say in a lib/ folder) when you ship or release code? As far as I can see it would be a lot easier if the library files the application depended on were placed there; that way, other people wanting to use the code w...
My class pseudo code is in the following format: public class Config { final private Map<String, TableSchema> schemas; public Config() { schemas = parseSchemas(); } public TableSchema getSchema(String tableName) { TableSchema tableSchema = schemas.get(tableName); if(/*Based on c...
Consider a common tutorial for object-oriented programming languages like C++ or Java: create a simple order processing system with objects representing accounts, orders, items etc (or something more or less equivalent). Makes perfect intuitive sense, but the elephant at the dining table is that it's not real because t...
I was wondering if what I have in mind already exists in any known compression programs/algorithms or not. We know that Seed gives us constant sequence of random numbers. so if we be able to find seed that say generate those bytes then we can compress files into just 1 magical seed that reproduces our data bytes! In o...
The main advantage of serverless architecture is said to be that such programs do not need a dedicated server to run continuously. Then are invoked on a request and stop on exiting the function. This means that a serverless program will have to be quick to start, for being responsive. How does then it handles time con...
Recently I started working on creating a client library. One problem which I am facing now is that I have to move the below interface Attributes to client library but the concrete classes (business logic) should remain in the original library. The problem here is that the method signatures of the below interface are Co...
I thinked at two techniques for my #define : Technique 1 SomeClass.h: #define SOME_BUFFER_LENGTH 256 class SomeClass { /* ... */ }; Technique 2 Config.h: #define SOME_BUFFER_LENGTH 256 #define SOME_OTHER_THING_USED_ELSEWHERE 23 SomeClass.h: #include "Config.h" #ifndef SOME_BUFFER_LENGTH #define SOME_BUFFER_LEN...
I'm working on a non-generic server-client-architecture in Java. Currently, I face the issue of how to tackle Event-types since each event has different attributes, which don't overlap neccessarily. For now this is what I tried: public interface Event { public void send(ServerConnection connection); } public static...
I have got a native image processing application that can enhance photos(peApp). Now, I want to serve this functionality to the world by having a server application that supports REST. Now while taking the scalability into account, I think I better seperate this project into 3 components: peApp : does only his comput...
Sounds pretty basic, I know, but I recently had a colleague tell me that a method called startHttpServer is too complicated to understand because it only starts the server if it's not already running. I find I get into trouble when I respond with, "Seriously? I've been doing this for decades - it's a common pattern in ...
Description: Given a parking lot containing multiple levels and each level containing multiple rows and each row in turn containing multiple spots. The questions is to determine if there are enough spots to check if a vehicle can be parked. Which object is responsible to determine if there is enough spots, I mean its t...
I've been reading about semantic versioning. Software using Semantic Versioning MUST declare a public API. This API could be declared in the code itself or exist strictly in documentation. So, does doccomments above the public methods of my library counts as declaring a public API? class FooBar { /** ...
Background In a software ecosystem where different packages depend on different versions of other packages, sometimes dependency resolution ends in a version conflict. Example: Root package A depends on B 1.* and C 1.*. Package B depends on E 1.*. Package C depends on E 2.*. -> conflict. Maybe the developers of libra...
Context: I wanted to change a setting inside Xfce and found that the way to do it is via xfconf. My first thought was to install the development files for libxfconf (libxfconf-0-dev) and look into the API. I searched to see if there's an example in some open source project and found a library which, instead of using th...
I'm just designing the exception handling for the REST interface on our Spring server. As we will have multiple REST controllers, a central exception handling is desired. Spring offers the solution via @ControllerAdvice. This works well, except that I need to add a dependency to the MVC part of Spring, which I don't us...
I'm writing a interpreter/compiler I have encountered a problem which I have solved before, but not optimally perhaps. The problem goes like this, expressions can express a lot of things like scopes, variable assignments and declarations. When an expression is simple, for example: a = 4 + 3 turning it into a Reverse P...
I have a couple of derived classes that are generally similar, but don't have a directly shared base class. All these classes implement a common interface. I noticed when I added another (new) derived class, that I copy a couple of private methods from the other classes which have similar content, but the actual implem...
I have the following situation: ASP.NET Core WebAPI solution which uses Swagger Automatically generated client for WebAPI using Autorest, extended with custom authorization. This client also will be packed into NuGet to be used by other services. Question: should I place the client into the same solution(and thus in ...
I've been tasked with studying a Python code, which runs on an orchestrator, which schedule the launch of the code in correspondence of some events. The code imports some modules, and it's basically written as an extension of a method of a certain class, defined in the orchestrator module (is extension the correct term...
I want to develop a robust system written in C# (WPF and WCF) for importing .csv files (and/or some others e.g. Word files) as a input into my system and then to generate PDF/Word report. I would have database, and application will be a desktop app. I am just wondering is there any approach for multiple customers apart...
Background I am trying to write a simulator where multiple AI agents are competing and/or collaborating to achieve the goal of maximizing some utility function. Each agent has the ability to interact with the world where it might alter the state of the environment, based on some actions it does. And as a result of such...
I'm attempting to design a class that is to be instantiated through the use of a static method, something like newInstance(param1, param2). The reason behind this is that 2 of the 4 parameters it takes are from the same package, but I want to hide them from the public. In order to achieve this, I made the constructor p...
I have a project that depends on external libraries that can be installed through a package manager (pip in this case). But I do not expect my users to have knowledge of installing these dependencies or even have the package manager installed on their system. I will be using a different mode of distribution for this pi...
If I'm creating a Java class for something that has a sequence of numbers in its name, e.g. “ISO 8859-1”, how should I name my class? Iso88591 seems wrong, since there's no boundary between the numbers. Iso8859_1 seems better to me, but according to Effective Java “… Constant fields constitute the only recommended u...
Kotlin is known primarily as a drop-in replacement for Java, but it gets rid of a well-known Java construct: the static keyword. Instead, that class-level functionality is offered mainly by companion objects. What is wrong with static methods and fields that companion objects provide a better alternative to? I'm confu...
I have a telegram bot that alerts whenever a price of certain asset reach a certain price. I have the following table in a DB: AlertId ChatId Price Asset So each Asset will have several ChatId (users) and each of them can have several AlertId, and AlertID is a unique autonumeric value. As this data is constantly rea...
When reading grammars defined using Backus–Naur form (BNF), I've noticed that the grammars never seem to use an explicit repetition symbol, such as * or +. This is opposed to Extend Backus–Naur form however, which does seem to have explicit repetition symbols. The Wikipeida article on EBNF mentions this, specifically u...
Let's say I have an interface A. Instances of classes implementing this interface will be passed on to an algorithm that relies on these instances being immutable. For instance, it'll be invoking A.execute(command) in a recursive manner, a number of times that depends on the given parameters. If execute() changes the i...
I'm a hobbyist coder; never worked professionally. I am not looking for anyone to write code for me, but I need to know how to approach this problem and, perhaps, ideas for further research. This problem is an outgrowth of my kid's science project that I wanted to toy with. Bottom line is: I have a sensor that feeds da...
It's very common to specify the version of REST APIs in the URL, specifically at the beginning of path, i.e. something like: POST /api/v1/accounts GET /api/v1/accounts/details However, I haven't seen any design where the version is associated with each API. In other words, we maintain the version of each API separatel...
Imagine you have 2 use case A and B. To execute case B, A has to be already done ( A is precondition of B), but when you execute A you dont need to execute B Like this? User -> A User -> B -> include A
In my current project I have a situation where I would need to use an edge collection as vertex collection. I would like to find a way to avoid it. This is the (reduced) scenario. These are the vertexes: Pupil, School, Holiday These are the edges: visitsSchool Pupil | {from} +-------------> Holiday | {to} +...
I have a method which is a part of the interface I am implementing. This method calls another private method which uses a random number generator to produce output and returns it to the calling method. I want to test the calling method. How can I do that? This is the method under test: @Override public String generat...
What would be a clean design for an app that is to store transactions and return a overview of the ones received in the last 60 seconds, operating in constant time and memory (O(1))? The app should expose two endpoints, one of them to POST a new transaction, and the other one to GET the statistics based of the transact...
If a software/library has some support for the Windows platform they almost always name their directories and variables as win32. This is most prevalent in C/C++ projects. Even the MinGW project's target triple uses win32. Is there a reason for this? Why not use a proper name like Windows or Microsoft Windows? Is there...
I am wanting to develop a C# application that would allow me to right click on a file and choose an option within the context menu to perform a save as with a date time stamp and then open the newly created file. The process flow would look something like this: User right clicks on a file opening the context menu User...
If I have some code which assigns a value to a variable, and that value then does not change, is it considered good practice to use const during the assignment? e.g. void foo() { int n = some_function_which_computes_n(); // <-- this could (should?) be const // imagine some code here which uses n, but doesn't cha...
I'm building an application with a database where I'd like to populate the DB with some data at first start up (so that the user has a few examples of how the application can be used) To achieve this I'd like to detect if the application is started the first time and if that's the case add these initial rows to the dat...
I have to design a system where an API has to be hit to get the meta info about some data. We have multiple workers, that take jobs from multiple queues. Now the API has a rate limit of say 500 per minute. Since we are using python, so getting the interpreter lock and wait for the time interval won't work as workers h...
Let's say I have an abstract Node class and BinaryOperation class derived from Node and three classes IntegerConstant, RealConstant and CharacterConstant also derived from Node. The general design for the BinaryOperation class would look like this: public class BinaryOperation : Node { public Node Operand1 { get; p...
I understand React and Redux (at least think that I do). But the combination using the react-redux Binding package is a bit confusing to me. https://github.com/reactjs/react-redux The first thing that disturb me is the motivation to use connect. Why not just use store.subscribe(()=>{this.setState({})}) from the root C...
Let's say I am writing a simple library in JavaScript, with only a few functions: Calculate the factorial of a positive natural number Find the least common multiple from an array of integers And so on... In each of these functions, I will check if the given parameter is acceptable before performing any operations, a...
What I Want to do I'm in a process of sketching, prototyping and brainstorming to know the possibilities the code will deal with and what kind of problems I could face while writing the code. And decide how the code must behave to face the problem that solves, evaluating pros and cons of possible behaviours. What I Kno...
I have domain object User which contains simple value object 'Contact'. Contact contains only getters without setters. public class User { private Contact contact; // other methods and fields } public class Contact { private String phone; private String email; private String fax; // and geters } I nee...
I use Xcode to edit my source files, and typically a file will look like this // // Queue.swift // SomeCompany // // Created by Someone (Job Title) on 26/06/2017. // Copyright © 2017 SomeCompany. All rights reserved. // /// A queue is a list where you can only insert new items at the back and remove items from the...
Background During web development, especially on the front-end, developers must test their code to see how it looks (pretty self-explanatory right?). When doing this, the developer will examine the website not just from their browser of choice, but from a multitude of browsers. This: Tests to see if all features are i...
Consider a website like: Confused.com, which is a price comparison website that has millions of registered users who use it for price comparison purposes. These users register their details for price comparison purposes? How do you deal with administration i.e. people who work for the company in question? For example,...
My question is a little bit about branching, versioning and agile development in general, but the heart of all three is the version number I think. Currently, I'm using internal version numbers (e.g. 1.0.4). This is also what the QA gets. But what if we would need a hotfix? I can't use the third number anymore, because...
I am planning creating a small personal blog application that handles only one user - the content author, let's call that user admin. There would not be any registration option, only a hidden login page that only the admin is aware of. There would not be any options that requires registration (no commenting, no posting...
I'm a summer intern at a small company tasked with developing a prototype for a (contact) record linking microservice. After some googling I understand that the first step should be cleanup / normalisation of my input data before I can effectively start linking contacts. (I'm thinking of mapping Ben to Benedict, etc) ...
I have to create two different projects with the Entity Framework: Web API Services UI and Business Logic (MVC). Both the projects have to work with same POCO entities. I see two alternatives and would like to know the pros and cons of each, and if one of the two to be recommended as best option: Make a different ...
Disclaimer I hope I am not stepping on anyone's toes or offending either concepts' enthusiasts Background I have been looking for real differences between Service Oriented Architecture and Microservices, without finding any clear answer. I read things like: the side effects of SOA SOA being anti-pattern Microservice...
I have an application that will allow the user to enter and store (in a DB) a website URL for a company. The only requirement (as of now) beyond entry of the website URL is to validate that the URL is valid and display the URL with other company information. The application consists of a client UI that will pass JSON o...
First SE stack, I am working on a large chunk of old Java code and am finding tons of duplication and inconsistently configured/created objects because of different authors, skill levels, etc. I have implemented a few static factory patterns and am having a debate as how to make the factory configurable. EDIT: per comm...
I have refactored some code at work lately, and I thought I did a good job. I dropped 980 lines of code to 450 and halved the number of classes. When showing this to my colleagues some did not agree that this was an improvement. They said - "fewer lines of code is not necessarily better" I can see that there could be e...
I am trying to setup consul for service discovery. We have hosted our infrastructure on AWS Mumbai region (We use only one region). I was going through the consul documentation where it is mentioned that when we run consul as a cluster a minimum of (n+1)/2 nodes are required to be running. The issue is that the Mumbai ...
I have a interface DataStore, which provides access to a generic data store, e.g. a local database, webserver, etc. I want to provide a way to filter results directly in the query. How should i pass filters for the query? I thought of a map which gets passed with the name of the field as the key and the desired value a...
The following is an example using https://github.com/GoogleChrome/puppeteer 'use strict'; const puppeteer = require('puppeteer'); (async() => { // const browser = await puppeteer.launch(); // const page = await browser.newPage(); const browser = await puppeteer.launch({ headless: true }); const page = await bro...
I have used java reflection with a static map to map actions(removeElements, getLatest ...) from the front end to the corresponding database methods by name in multiple web applications now. I was wondering if this use for reflection is considered bad practice ? (I read that reflection causes hard to find bugs) If it i...
I created a generic class MyClass<T: Numeric> {...} and got errors in my functions that tried to use > and <, along the lines of "Binary operator '>' cannot be applied to two 'T' operands." I spent quite a while thinking that the problem was some syntax error I had made in the declaration. But sure enough, Numeric does...
I work on a software platform that is homegrown and, for the most part, used internally in the company but it is deployed in facilities across the globe. This system runs on a specific set of hardware, and have many dependencies, they mostly fall into the following categories: OEM hardware drivers and libraries. Custo...
If I need to write a program that Reads a json file Converts its data to yaml Writes it to yaml file and adhering to the single responsibility principle I create classes like FileReader JsonToYamlConverter FileWriter everything looks good, but then I need to create some class to invoke all these classes, wouldn't...
I'm currently developing a quite large ASP.NET application which uses SQLExpress as the underlying database. The project is currently under heavy development and is covered with unit tests and regression tests. Subversion (SVN) is used as a version control system. Those tests are very important, we need to make sure th...
I've just read the Scrum Guide as I have no experience with scrum and my team is starting to use the methodology. We use JIRA to record/track our issues, but a common process is that we get operational questions/requests through email or in person. We add those to JIRA as operational tasks (we don't have a development ...
Role based security is a very common model for software nowadays. It is very powerful but requires careful configuration to leverage the benefits of shared roles. It is easy for a mess to be made for example when the admin user simply creates a role every time a change is needed (instead of leveraging existing roles). ...
To create a method that takes an array as an argument, you would do this: public static void printAges(int[] age) { // prints ages to screen for (int x = 0; x < age.length; x++) { System.out.println("Age: " + age[x]); } } How would you create a method like this one with one exception, that it takes an ...
I'm building a small game similar to chess. I'd like to be able to reuse the structure for another version of checkers too. I'm modeling the games with interfaces (showing only relevant ones): RuleOrchestrator.class public interface RuleOrchestrator { Collection<Move> allowedMoves(Player player, Move move); } Play...
Is it good practice to express the state of an HTML element--such as whether an input's value is valid--using a CSS class? Would it be better practice to use data attributes, the properties of a JavaScript object representing the element, or some other method? Example: CSS: .error { box-shadow: 0 0 8px .1em #b94a48...
I've started working on my web application and I'm stuck at the design stage. I cannot decide which web technologies would be the most suited to this project. Let me explain what I want to achieve: 1) I need to web scrape data from a website which provides live scores for sport games (e.g. flashscore) 2) I would like t...
In my current Java EE project I've got a quite common task: Load objects from database using Hibernate, transfer them in another object structure (based on a XSD) and serialize it using JAXB. To simplify the scenario imagine the XML I want so serialize is a file with information records to requests we get. In theory th...
We are dealing with a lot of null values, now and we are wondering if there are any standards for avoiding it at some places in the code. For example I have this PHP code: class X { function setName(string $name) { $this->name = $name; } } $x = new X; //Will throw exceptio...
I sometimes read about "hiding the framework/technologies used in a web application for security reasons"... But why? Is it a real issue to publicly expose which tools I'm using to create a project? Large public web application like LinkedIn, Facebook and many others don't hide tecnologies used for their platforms, so ...
I am new to Spring as well as layered architecture. So am a bit confused as how data flows among the different layers. What so far I have understood is: Layers: Controller (which accepts requests) Model (simple POJO with dependencies, which depicts database table) DTO (expansion of Model objects i.e. flattening; with...
In programming language theory semantics, semantic is the field concerned with the rigorous mathematical study of the meaning of programming languages. It does so by evaluating the meaning of syntactically legal strings defined by a specific programming language, showing the computation involved. According to...
According to compiler definition, the compiler is a program that translates a program written in a programming language P (source code) into a program written in a machine language M (machine code). And also "the compiler is self-compiling if it is written in P". now the question is what is the meaning of the line- "t...
As per the "Software Architecture" explained by Uncle Bob, your architecture should be able to defer the framework and DB related decisions as much as possible. Consider an example of a Payroll system to be developed in Java. I assume that the core application will be a standalone jar file. The "delivery mechanism" wil...
I'm developing an app which will cater for in-app purchases but not in the traditional sense of addons for games, upgrades, etc. The app will connect to the user's profile on our API and see if they have any Payment Profiles, which we would use to pay for an item (in this case a ticket) on the website. It is my underst...
I am looking for the name(s) of a concept I heard of. I know that it does not exist in many programming languages, but I think it exists at least in C++. Let me try to explain the concept. Assume I want to define a generic collection in some programming language, and I want this collection to contain elements of type A...
Example: I'm in a coffee shop in Maine, using a VPN whose physical location is in Berlin. I know that my packets between Maine and Berlin are encrypted, so someone snooping on that coffee shop's wifi can't see what my packets say, or where the packets will go after Berlin. But can they see that the packets are going to...