instruction
stringlengths
34
36.1k
A fast food restaurant has an existing sql table of transactions: old_transactions: transaction_id item_description quantity price 1 burger patty 1 5 2 bun 1 1 3 ketchup 1 0.25 4 packaging 1 0.50 5 labor to make burger 1 1 We would like to create an abstraction on top of those transactions. For inst...
In https://nvie.com/posts/a-successful-git-branching-model/, Driessen suggests using the --no-ff flag to make the history of commits for the dev branch clear. This is an easy flag for individuals on a multi-person team to forget to add, and it also has the disadvantage of adding extra commits to the history (commits ...
I recently asked a question on CodeReview SE where using a binary search was recommended, and the author of the answer proved that it was faster than my implementation. During my research on the topic, I came across a table that shows the complexities of a binary search: These are the complexities of a binary search −...
I'm fairly new to strongly typed languages, coming from the "jungle" world of JS and PHP. In my current Typescript project(React-Typescript), i'm struggling with a very fundamental question: Should every piece of code expose its own interface, even if that means having duplicate types across my application? Simple exam...
Considering there's a map of string constants, most commonly with a key and a value being equal, e.g. in TypeScript: const itemTypes = { FOO_BAR: 'FOO_BAR', BAZ_QUX: 'BAZ_QUX', } as const; They are supposed to be used with a specified domain (item type) and can benefit from being referred as keys on itemTypes, for...
I am currently a university student working on an extracurricular project where we built a 3D printed SCARA robot that will be remotely controlled. On one end, you have the user that is moving their hand and gathering location based on x,y, and z coordinates. Those coordinates will then be sent to the SCARA robot which...
I am newbie at these stuff and while I was able to distinguish between role-based vs. policy-based authorization models, I can't seem to understand whether there is one between policy-based vs. permission-based. On a conceptual level, what is the difference between them? Can policy and permission terms be used intercha...
I have the following requirement to design behavior of a software component for logging sensor, which writes data to SD card a: Datalogging sensor can write data to a FAT16-formatted SD card that is inserted into the card reader slot. When the board is booted and a valid card is detected, a new file is created and data...
I have a two dimensional data with one dimension is ordered and another one is categorical, for example, country and city_age: country age city Italy 2773 Rome Germany 784 Berlin USA 397 New York Suppose this database is bigdata. Now I want to set age range, for example 500-1500 and then search for coun...
We are building a backoffice web application where people are making changes to an array of nested objects. Because of totally non relevant business reasons there are things that users cannot change but can still send in. It is assumed that some people might not use the frontend but directly call the backend, so we can...
Assuming I’ve a class with three methods, startCollection, add, endCollection. One test case is: if start was not called, add should return an error. I’ve mocked the persistency storing the state with an memory variant, and test it. All fine. Now I’ve yet another class: a RestController. It also has 3 methods that call...
I'm currently working on refactoring a project to use the repository pattern, but I'm currently struggling with how related information should be retrieved. Let's say I have a Hotels and Rooms. I have 3 use-cases that come up: Retrieve a hotel with all of its rooms Retrieve a hotel (without rooms) Retrieve a room Now...
I am wondering if it is an acceptable approach to pass instance variables from one object to an object of another class (saving them as instance variables as well) in order to retain the context that is expressed by those instance variables. In my case I have a ClassB with a method whose return value is needed to creat...
I am working on a project where there will be different kinds of accounts that use Auth0 for auth and authz. I want to have it so that an account will query my backend to get back documents that pertain to that user. The issue is I want to be able to have multiple accounts set to "own" each document where the number of...
When trying to design a factory service in a project where i am using a dependency container i sometime find myself in this situation. I have an interface, in this example ISettingsLoader. ISettingsLoader defines an interface for any class used to represent a page which displays a series of settings. interface ISettin...
Background I work for a company that provides installation instructions for solar panels on roofs. We also provide an API where external parties can provide roof input and preferences, and return an installation summary, instruction guide, bill of materials, etc. The biggest hurdle external parties need to go through i...
In my company, we are using Event Sourcing pattern to implement a storage for all changes to the price of a booking. Across the company, different services might try to append events to a booking identified by a booking code. We use DynamoDB to store the event and it does support consistent read. The thing is in the ca...
I have a similaire scenario: int retrievePrice(string productName) { string id = restApi.get("productid", productName); return restApi.get("productprice", id); } The restApi could also be a third party. In order to make the test self sufficient, I end up mocking the restApi. If I directly test this method, I wil...
I have a class with an attribute that is a dictionary of dataframes, where each dataframe is the input data grouped at different levels of temporal aggregation. I need to add an option to this class so that when the object is instantiated, the dictionary contains a slightly different grouping of dataframes. Would it be...
In my application, I have a class which I call a "Signal" (Think Qt signals if you are familiar with that) that represents a one-to-many connection. Objects can register handlers to the signal which, when "emitted" calls each of the handlers. This is implemented under the hood as a list of function pointers. Making a...
I was thinking that a Functional Configuration Audit (FCA) point to the Functional Requirements while the Physical Configuration Audit (PCA) is more related to the non Functional Requirements is this true? does anybody has experience doing those audits?
C#10 Has extended the property pattern ability, I think it began since #7 EG: { Car: { Interior: pattern } } Meaning you can do some nice pattern matching even in if statements if (car_var is Interior leather) { .. } It's been extended to manage switches etc. In TS: using filters (maybe not), I would like to write a ...
Consider your have an enumeration that looks like this: enum ProcessingType { CONFABULATION, RETICULATION, SPLICING; } And you have a web-service that looks like this: class WebService { Service service; @Mapping("/operation/{processingType}") void process(@RequestBody Data data, @RequestParameter Pr...
Backstory: My new employer has Dynamics CRM on-prem and it is used by all office staff and other colleagues that are consultants. All other employees are a working force out on various construction objects, they do not have access to the CRM. There's a couple of business processes that have to be exposed to that workf...
I'm writing a function that needs to get libraries (files) for a Company from a folder path. Thereafter it needs to install those in a repository. While doing this I need to inform the user what is happening. Below is the code. def run(self): self.__get_libraries(self.__companies) for company in sel...
Im working on an application which essentially fills a giant government/court form. Lets say i have an an Entity Unemployment and Unemployment has a ... thing "Reason why" and there are 6 possible reasons. "quit himself", "terminated by employer", "went to jail" etc. Currently those are modelled as "KeyTexts", which is...
Tests can be very nicely written down using the given-when-then style. Are there similar styles / templates for describing methods and classes in docstrings? To clarify: There are many sites which describe the docstring format and give examples. According to them, functions and classes usually start with a one line su...
I want to implement an authentication system. The purpose of the system is to centralize account management and handle the complexity of account security. Internally, I don't want to implement the actual login by myself. Instead, I want to use Azure AD B2C for user login, forgetting passwords, etc. Our team has other w...
So I've implemented the repository pattern in a lot of projects, but there seems to be a bit of a discussion on what is right with this pattern. Previously, I've always added Update or Create methods in side of a (generic) repository to modify the entities. This would always save changes to the context. Recently I read...
I've noticed that most AST tree implementations use classes for nodes instead of something like a vector. I want to ask, why do most people use classes? Are there issues to using vectors to make AST trees?
I have written some code in Katalon Studio (known as "custom keywords") whose job is to map the rows of a Data File to models for testing. Say goodbye to hardcoded column indices and findTestData("YourDataStoreName") all over test case code! It is defined to be: package com.xxx.builders // imports public abstract clas...
I asked this over at SO and didn't get any responses after a couple weeks, so I figured I'd try SE... TLDR; How do I update nested objects in MongoDB when data referenced in those nested objects changes? What are the pitfalls of simply storing IDs within nested objects and having the client look up the correct value t...
User requirements are considered high-level functional or non-functional requirements have to be understandable by end-users and customers who may not have a technical background. We can use diagrams like use case diagrams to help with illustration of user requirements. System requirements are more detailed requirement...
I'm searching for any formal/generic approach to modeling a process distributed in time with functional programming. Here is an example. Let's implement a very simple notification service. It accepts a "task" that can be unambiguously distinguished to be "done" or "not done". When a "task" is "done", the service notifi...
I'm wondering, although as I think both options are possible. Currently, there are two versions for Blazor projects in visual studio 2019. If you want to connect to a backend DB then there are two project solution options: a "Hosted Blazor WebAssembly app" project. a "Blazer server-side" project. Both can handle conn...
I'm curious about your thoughts on this subject that we have discussed with the people around me. Especially at the architectural stage, in which layer is the most optimal and efficient way to use the messages to be given to the end user (for example, your update was successful, you had an error while adding a file). W...
I wonder if there is a naming convention or a best practice to name Java Classes when building AWS Lambda functions with Java for REST API? For example, if I have a Java project that contains Lambda functions to handle CRUD operations, is it a good practice to name Java classes this way: PostHandler.java - A Java clas...
When building REST API with AWS Lambda + Java, do you define all lambda functions in a single AWS SAM template or create a separate project for each CRUD operation? Given that on AWS, each lambda function runs in its own container, and only one handler class is invoked per HTTP Method. It makes sense to define each Lam...
I'm doing this homework exercise with simple linked lists in C with nodes having the following structure: typedef struct lista { int num; struct lista * next; } nodo; So the exercise asks us to traverse the list and if we find two nodes such that node1->num == P and node2->num == Q, we delete all nodes between...
My idea is that, if an unsigned 32-bit integer is used for representing angles in a way that 0 is 0°, 231 is 180° and 232−1 is just under 360°, all possible values are used and evenly distributed among all angles. Rising large values would naturally overflow to 0, which corresponds to the equivalence of 360° and 0°. (E...
Since I met the out keyword in C#, I'm trying to find an equivalent approach in JS. So, please take a look at the code and leave your opinions of existing cases or suggestions of new ways to implement this. The working version is inside this sandbox: https://stackblitz.com/edit/js-out 1 null on fail const number_1 = tr...
I am using a REST API that is being developed at my workplace. The documentation clearly states the HTTP request type (POST), the URL endpoint, and the "payload" in curly brackets, i.e., various parameters and expected values. At the bottom of each endpoint section, it details response possibilities as response codes -...
In http://pages.cs.wisc.edu/~hasti/cs302/examples/UMLdiagram.html it is written that "parameter names are not included in the UML class diagram" I haven't been able to find any information on this. Most places have the parameter list written like so: functionName(arg1: type, arg2: type, ...) So, is this information jus...
tl;dr An audacious claim by a classmate caused me to question the definition of the word "support" (verb) in the context of computer science. Is it analogous to standard definitions where a degree of intent/competence is required? Or is it a sort of technical jargon acting as a binary inclusive/exclusive descriptor of ...
I am developing an app whose main purpose is to display data in tables, lists and graphs. As such, sometimes I need to rename or restructure some of the data recieved from the backend into a "shape" that the graph library or component can understand. For example: //raw data const data = { dataType: "Precipitation", ...
I have a simple class called Link that contains some properties, and use different classes for creating different types of links. My code looks like this: class Link { String reference, label, target, ... } interface LinkFactory { Link createLink(Person person) } class EditLinkFactory implements LinkFactory { Lin...
I'm currently looking at blue/green deployments and I'm not quite sure if my use case is even applicable. The following simplified scenario of a user management tool: I have 3 services - GUI, BL, Persistence. I have blue and green environment setup. Green is currently idle and users access blue. Now I want to deploy to...
We have to compute a schedule for a set of students and teachers in a school. The program takes a large amount of data. The time it takes to compute a schedule for a given input cannot be determined. It could take 2 seconds or 30 minutes. In some cases it might not be able to compute a schedule because of some conflict...
I have an application that mostly is composed of forms that create, modify, read, and deletes tables and establish relationships. I use SQLAlchemy. If, for example, I need to create an invoice and associate it to a customer and to an agent, from the salespeople of the company I use the following pattern: 1: Load mappin...
I'm looking for some guidance. Is it a bad practice to use transformation functions within DTO objects? I have this example public partial class AgEmpDto { private DateTimeOffset _startDate; private DateTimeOffset? _endDate; public DateTimeOffset? LastUpdateDate { get; set; } public...
I'm responsible for staging some tests, against some members, namely against the rates that are due for them. After talking about it with my peers, I see the members are a function of three other models: member lead discount rate card They were about to create separate spreadsheet just for the members, manually doing...
I am currently facing a few issues when implementing the logic in one of my Aggregates. Imagine an "Account" aggregate, which has email, password, verified and verificationDate fields (basically credentials and verification status). When a new Account is created, it has verified = false, and verificationDate = null. Th...
I do understand the SOLID Principles and LSP, but I want to be able to meausure how well a class diagram obeys to the LSP. Therefor I have found the "Value of LSP" metric, here is a guide how it should be used: Metrics of Liskov Substitution Principles (LSP) The main key to this principle is the management of the in...
I am here to ask question about: is it good practice to insert many records using CQRS and MediatR? how to structure that in terms of names and folders? A have to insert into database over 500 records and now I am doing it like this: foreach (var item in list) { var command = new CreateItemCommand() { ...
I'm working on a .Net eCommerce site that allows users to use vouchers to get free products, discounts etc. The problem I have is that there have been instances of users, who have been issued single use vouchers, using their voucher multiple times across several sessions. They add the voucher to their basket in differe...
Suppose I have an instance attribute that I don't initialize in __init__, but in normal use it should be initialized before any other methods use the value. I want to structure everything so that it all type-checks, and I'd like your opinion on which of these structures is best. My first pass I would write something li...
In our development process, we have documents for each task/feature that describe API changes API logic Data flow (if needed) Database changes How client should interact with new/modified APIs Other information to clarify implementation The target audience of the documents are developers who implement the feature, so...
I have multiple state machines (7) managed by a "main" function. Because of system constraint this will be run on an old qtweb browser with ES5/IE11-like behaviour. So no promises etc. I'm already using Babel to avoid some issues like let/const not accepted etc. My only "reactive" option at the moment is callbacks. At ...
I have been working with many applications and had different approaches to storing application properties (configurations). The problem is were to store different types of configs. Configs which require application restart and being changed rarely (some 3rd-party properties, DB or queue credentials) Configs which can ...
This is a question about terminology, not about method. Our application consists of physical simulations. Results have been validated in various ways, but we have no oracle that guarantees correctness. Nonetheless, to improve and extend our software we need tests that ensure that at least we did not break things that w...
Question as the title says. Of course, I already tried searching online, but did not find a definite answer yet. (The sources I checked imply that the terms are interchangeable, but do not state this explicitly.) Also, if they are not the same, then what is exactly the difference? Some thoughts from me: In theory, we ...
Black hole problem I am working on matching and daily syncing of our internal data records to an external database that behaves like a black hole, meaning, we cannot view nor extract any data from it for verification. Another of its properties is that one can only do inserts and deletes, so no direct updates. How to CR...
The alloca() function allocates memory in the stack frame of the caller. What did alloca originally stand for? Are there any sources regarding the etymology of the name?
The technique involves moving some logic from the caller to the callee. Usually the logic that is moved is a check. Here's an example of the technique applied to code that solves the "Construct BST (Binary Search Tree) from the Preorder Traversal Values" problem leetcode link: INF = float('inf') class Solution: de...
Having read through various microservices literature, I've seen a common recommendation that a microservice should generally be fairly cohesive, owning its own data repository, and serving as the single interface to its data repository. But now with AWS Lambdas, I'm seeing more occurrences of multiple Lambdas reading t...
Below is a little context to the problem I'm trying to solve. There are two separate microservices with separate frontends , APIs and databases. Customer Microservice - Manages customers Orders Microservice - Manages orders Orders table has a dependency on customers and so in Orders Microservice database customer sc...
I am new to Domain-Driven Design. When I was trying to define the bounded contexts of the software, I don't know where to start. After some searching on the Internet, I am totally confused. Some articles recommend defining bounded contexts from the Business Capabilities since it follows the Conway's law. Here is one po...
I am currently working on a side project so I can learn new technologies and understand how the components fit together. For this project, I decided that I wanted to work on Chat Applications in the context of Distributed System and trying to replicate as much as possible to real live systems (i.e. Whatsapp, FB Messeng...
I'm Trying to learn about State Pattern. In most of State Pattern examples that I have seen, methods of class change their behavior based on just one field (I mean before applying State Pattern and I'm not talking about the reference field of the state interface type) and also that field has no other use in that class ...
I want to select between "symbol(s)" and "character(s)" for my variables' names in cases when these terms are synonyms. Please teach me some information which allows to make this choice. Frequent use cases MINIMAL_SYMBOLS_COUNT/MINIMAL_CHARACTERS_COUNT MAXIMAL_SYMBOLS_COUNT/MAXIMAL_CHARACTERS_COUNT EXACT_SYMBOLS_COUNT...
Source-:https://cs.ccsu.edu/~stan/classes/CS410/Notes16/11-ReliabilityEngineering.html This is self monitoring architecture. So here computations carried across 2 channels, if they both provide same result then system is operating correctly else failure has occurred. Hardware and software in each module is different to...
I have been working on a lambda that is triggered by a SQS with a batch (let's say of 5) and has automatic retry enabled. The most common problem with this kind of setup that I have seen is that, if we have 5 events, and event number 1 and 2 are completed successful but event 3 fails then during the retry the 5 events ...
There is a table named is A with 40+ columns, among which around 10 are columns of hierarchical levels, in a data analysis platform maintenance and development ( legacy ) project. Due to development of a new feature, the hierarchical structure would need ten more extra levels, e.g. level11, level12, ..., project manage...
What I try to solve: Given I run a set of microservices, most of which expose a RESTful API and additionally publish or consume events via messaging broker, and I have decided to go "API first" using OpenAPI and AsyncAPI to specify these APIs, when I design my the domain models, then ... should I create separate domai...
I need to create a very small service which will programmatically make a database insertion once a day. As our stack primarily uses Node.js, we’re going to write a JS script responsible just for making the insertion and then ending execution. We will then cron that script for daily execution. However, the script itself...
I am currently developing a service and a client and I use HTTP statuses for communicating certain info. For example, I have a POST /vikings endpoint that starts a long running process to create a viking object and returns a HTTP 201 status and a JSON with the viking id. I also have a GET /vikings/{viking_id} endpoint...
This would be a broad question - but I'm asking specific to the situation around an app that I've developed. In short, I've written an app that allows users to persist their photos and videos to the 'cloud'. In an effort to keep this brief I won't go into too much detail but, essentially, any media captured through the...
The requirement is to trigger certain tasks (API calls) periodically for each user. But the frequency (time between triggers) is not fixed, the user can change it. In my existing solution I maintain a table in the DB with userId, freq(seconds), last_run (timestamp) The service uses a Cron-like library to call a functio...
I know when building an Angular app (or other frontend framework with auto UI update by change detection), using function in a template is not recommended since it will result in the function being called every time when change detection runs. This means if we want to display a value derived from another value, we have...
We had a conversation (with coworkers) about why we needed to use Singleton for Controller, Business Services, and Repositories. The reason for this, they claim, is because singleton ensures that code is thread-safe. According to what I read in The Gang of Four, we should use Singleton when: there must be exactly one ...
In Slack and other apps, a user's email can be tied to multiple workspaces. What’s the best approach to architecting that? Do you list workspace IDs on the user record, or do you maintain a list of user IDs on the workspace level? How do you handle JWT claims?
Implementing the Observer pattern in MVC could mean making Model Observable and View Observers. However, this also means that there will be direct communication between views and models without the involvement of Controller? Does that violate MVC spirit? It seems to. The second option could be making Controller the obs...
I'm wondering if the use of third party software and/or network requests is the motivation for integration testing? For the sake of keeping the code examples minimal, I'll define a unit test as something that tests exactly one function, and an integration test as something that tests two or more functions. I have in mi...
Recently I learned that sequence diagrams can be used at both requirements specification and design level. My search so far shows the boxes on top of the sequence diagrams used for design consist of objects, while the boxes used on top of sequence diagrams for requirement specification contain classes, and other concep...
I am writing tests for an algorithm that is built up of several consecutive stages. Each such stage has its own set of unit tests. I want to check that the whole algorithm performs as expected, but am not sure how to approach end to end testing correctly. Say we have stages a, b, c. Lets say for simplicity's sake each ...
Hypothetical scenario: Let's say I have a Customer service. It has 1 million customers in its database. I then create a new service that depends on a specific projection of the customer entity. I want to avoid coupling and synchronous communication, so the new service should get customer updates through asynchronous me...
I've never implemented an entire specification before and wanted to know what a workflow may look like to do so. I have worked on code that was backed by such a specification, but only in maintenance have I had to refer to the spec, and only very small portions of it. This would probably be an awful first thing to impl...
I am reading about the SOLID principles, but it seems like the Liskov-Substitution Principle primarily refers to programs that use inheritance. From my understanding people are shifting more towards composition over inheritance. If that is the case, does the "L" in SOLID still apply? If so what would be an example of i...
Sometimes there are elaborate discussions about a subject, and while finally developing the program, you want to refer to a mail ... but then people still continue mailing about the subject, so the mail chain continues. How do you refer to a particular mail in the comment of the source code? There are two obvious ways:...
I'm developing a module, which is very complicated. I'm trying to draw a state machine but I don't know if a state machine can present multiple threading cases. Basically, the module processes the multi-threading inputs. For example, if input a and input b are coming together, the state would change from stateA to stat...
I'm looking for a more efficient algorithm for the following problem: The input of the algorithm is a text file and two non-negative integer numbers - the number of headers and the number of tails. Execution of the algorithm should provide two output files. Output file 1 should have all the header lines followed by the...
A colleague of mine recently pushed a change to the development config for our nginx. He changed the port from 8080 to 80. It's a rather lazy fix for a development-only issue. I reviewed the change and challenged it, calling it not idiomatic for development. Now he's pushing me for more reasons why it's not ok. I think...
Most software creates a directory (usually in ~/Library or ~/Library/Application Support in MacOS) to store user preferences, browser history, etc. Most software attempts to create their data directory immediately upon launch and will either crash or refuse to continue if the directory cannot be created. For example, i...
I am working with a large dataset (~5GB) stored in a Google BigQuery database. My goal is to create a web app which works a little bit like an Excel spreadsheet where users start off by seeing the full dataset (or at least they think they do - the first 10,000 rows should suffice). They then would go on to apply a numb...
I'm looking for a system to be able to configure my C++ project to compile some sections of codes and not others depending on what target hardware I'm compiling for. The area of development is software for computers onboard unmanned vehicles (e.g. drones, small fixed-wings, rovers). So, for example, if I'm building for...
I'm trying to figure out the best practice for querying databases or other services. If I can make one large query to a database once and sort the data in the backend should I do that over making many small queries and let (for example) an SQL database to do filtering for me. Example Lets say DeviceData carries lots o...
Currently I have a system where I have installed HAProxy on one machine and my other 3 machines serves the webapps and the fourth machine for the database. Now I need to add another load balancer in my system so that any one of the load balancer could pick the request and process it. But I don't understand how exactly ...
I face this problem with software development quite often, but I don't really know the name of this issue. It sounds quite common, though. Two nodes (a computer and a mobile phone, for example) share a common sqlite database (as a file). At minute 00:00, both had the same entries and life was perfect. At minute 01:00,...
How do you know what to memoize in top-down Dynamic Programming problems? I understand it is to do with capturing the permutations of state. E.g. in the Fibonacci numbers question, it’s memoizing the Fibonacci sequence fib(8) = 21. I understand that; it’s a pure function and input results to output. However, with more ...
I'm trying to understand why it is appropriate to have a method prefaced by __ underscores when no subclasses are present. There are thus technically no naming conflicts that could arise. I'm specifically referring to the __series_type method in this pvcaptest Github repo. Other methods in the class in this format __g...