instruction
stringlengths
34
36.1k
I find myself working with documents that need to be displayed to a user and at the same time, I need the information that they bear. For example, you have a generated PDF document (or other "visible" format) that represents an invoice. I need to have the document to display it to the user and its information it contai...
Context There is a back end and a front end team. Back end exposes an endpoint to the front end app: PATCH car/{carID}/tire Problem I want to update the aforementioned PATCH request functionality which will change the request's body . Solution There are two options: Change the current endpoint and ask the front end t...
When we show a table with many thousands of records, we only show a small part of the total result set so as not to send too much data to the client at once. Clients can request more parts of the result set through pagination. This is how a typical query for such a table looks: SELECT `expression1`, `expression2` FROM ...
A book called 'Applying uml and patterns by craig larm' emphasized the use of Description classes in software designing. For example, the book pointed out why putting attributes such as description, price etc in a separate class ProductDescription and associating it with Item class which only have a serialNumber attrib...
I want to get help from you all about building an android app that is capable of logging daily journal type data. I want to have these feature primarily in the app: Capable of logging the daily logs. Some way to save data to some cloud storage app like, Google drive Login with eMail feature for password recovery In bu...
I'm writing a small utility class to create an abstraction for addEventListener (JavaScript/DOM) Let's say I have to test for these features: Single event target with a single event Multiple events Multiple event targets Delegated events Once Now if I understand unit testing properly, I should create a test for each ...
I am developing a multi-tenant project that will be a kind of micro "ecommerce" and therefore customers will be able to create their own stores and will be able to choose between creating a subdomain or using their own domain. This whole process needs to be "whitelabel". I will only use AWS. It will be a kind of shopif...
The project (Java/Spring) I currently work on has a rather large unit-test class for one of its services : more than 1000 lines, several Nested class (one per big functionality), some tests without a Nested class, ... Finding this file rather difficult to read, and to manage (a modification in the service, and you have...
I've written an embedded app in Javascript/HTML/CSS that allows people to schedule services. Here is an example installation in production right now: https://azureautodetailing.com/schedule-online.php I've clearly made some bad architectural decisions. I designed it to install itself directly onto a website. Each websi...
I have a maven module which will handle DB interactions for various scenarios. I want this module to use spring framework so we can leverage the standard DI and integration test capabilities. This module will never run as it own application. Lets call this the DB module. This module will be included as a dependency in...
I have a website for international users. Let's say the website supports English users only ( All texts on the website are English words ). The website has a submit form that the end-users of the website need to enter Dates, Integers, and Decimals. At server side, I will convert all the text-based fields: Date, Integer...
If a base class Logger has a method reportError that takes an Error object and formats it as a string. If a subclass implements that method but outputs the string in a different format, yet a string format nonetheless, does it violate the LSP? I know that adding methods to the subclass doesn’t violate the LSP, it just ...
Hi guys I'm trying to create Form builder in my app for different Events that have happened and publish them, so the users can fill them out. Little About Logic: Forms are created per different Event that has happened, and then users can popuplate and view them As for the database I'm using Postgres. Here is how my cur...
A while ago, I tried to help a fella to develop a mentorship matchmaking program given the answers of a questionnaire to match mentors and mentees according to their respective skills and available time slots: A mentor is defined with: Identifier (email, full name) X Time slots (UTC) How many mentees the mentor can ta...
I develop for a company an Ionic cross-platform mobile app that will be published on Apple's App Store and Google's Play Store. I read Apple's Review Guidelines and Google's Developer Program Policy but couldn't find, even after searching over the internet, answers to some specific questions. Some important things to ...
This is a more architectural question and I am hoping to get more ideas out of this thread. I have a computer vision model detecting daily life activities and sending data to the server every second. I want to show that data on the frontend but only after interpreting it in a comprehensible way. So the process currentl...
We've been battling over where certain methods should live within our domain model, so looking for some adice and reasoning as to where they should go. Say we have a Project object now that Project can have a Budget (which is essentially made up of a number of hours against certain job roles and these have a cost to th...
I’m currently developing a web application and am struggling to think of a design for the front-end. In the front-end the user can input 1-n values and it will be split up into 1-n API calls. The api does some processing for 2-10 seconds and stores it in the database if it is successful. Right now I just have it so tha...
I have a parameter object that represents a single match in a competition, and one of its properties needs to contain that match's game scores for both players. For example, in a match determined by a best of three games, the scores are 3 to 1, 1 to 2, and 10 to 0. I'm tempted to use tuples: public class MatchParameter...
I am trying to find the best practice for importing modules dynamically. I have multiple files in a specific folder called providers which contain a class Updater and all of them have the same objects. This is the structure I have: main.py |-providers: --__init__.py --plex.py --pihole.py Each provider has 3 clas...
In Computer Systems: a Programmer's Perspective, Unfortunately, a number of commonly used library functions, including strcpy, strcat, and sprintf, have the property that they can generate a byte sequence without being given any indication of the size of the destination buffer [97]. Such conditions can lead to vulnera...
I have a git repository with a long history. Releases were tagged along the master branch over time. If a user wants to go back and check out an old tagged release, they do not have the advantage of using an up-to-date build system or updated references to external data sources, licensing, etc. The ideal end-goal is f...
Say that I have two functions that are essentially identical, where one validates its arguments while the other doesn't. The rationale: sometimes you want to be safe and sometimes you want to go fast. What's your preferred naming convention to distinguish the two? For example: list_err_t list_push_a(list_t *ref, list...
This is the mess of imports currently at the top of my file: import argparse from copy import deepcopy from functools import cmp_to_key, partial from itertools import chain import math from multiprocessing import Pool import os import re from typing import Dict, List, Set, Tuple import xml.etree.ElementTree as ET from...
so, I'm currently developing a feature for a website of mine, which aims to gather a set of financial data from the user so the user can start and take care of a budget, as well as the website offering some budgeting advice and offer some finance charts. The data is supposed to be used like this: Users have to enter a...
I'm working on a desktop application in C# that reads a directory and displays in a DataGridView the directory entries of the PDFs found in that directory, like a File Explorer that only shows PDFs. The user will need to be able to rearrange the order of the files in the DataGridView by dragging and dropping (single ro...
I have a raspberry pi that is sending an https request to my Django application every 2 seconds. The request is essentially asking the application 'Has a user requested data from me?' My Django application then responds to the request with either a 'yes' or a 'no'. If it is a 'yes', the raspberry pi will send the packe...
I'm trying to get into Microservices by creating a project, so far I've stumbled upon authentication mechanisms, in a monolithic architecture, the client (web app) would send a request with the user credentials to receive a JWT and send it in every upcoming request. However, when it comes to Microservices I found out t...
We recently embraced Clean Architecture and CQRS, by way of Mediatr, in several of our new applications. A similar (SPA-based) demo can be seen here. For many of our WebApi-based projects, this worked wonderfully. The presence of pipeline behaviors made it incredibly easy to centralize our validation, logging, authenti...
I have an AspNet application which I'm authenticating using a separate AspNet Core application. It returns a JWT token which is then carried in a Http Cookie. The AspNet application validates each request has a valid JWT Token. The immediate issue I face is the 4kb limit of HTTP Cookies. I need to carry permission info...
I'm new to JPA and Hibernate. I just saw an annotation called @Transient, which can mark a field to be non-persistent in the database. However, for the sake of "separation of concerns" described in the answer of What is the use of DTO instead of Entity?, we should remove non-persistent fields from entities. Assuming we...
I am writing a REST API for use by the front-end web and mobile frameworks. Naturally, I write unit tests for each endpoint, which makes developing, evolving, and maintaining the API easier. However, currently, my unit tests are not atomic since they save and load certain variables into a persistent file. For example, ...
Annotations/Decorators/Attributes are a language feature found in multiple languages, such as JavaScript/TypeScript, Java and C# to name a few. I've been trying to find some information about how people/projects go about deciding how to name their annotations. I've found a mix of both using nouns, adjectives and verbs....
Ok, so my scenario goes like this: I am building an API of financial transactions. Backend does not matter for this problem, the only thing is that the API has a route /users/:userid/transactions/:transactionid. On the frontend (PHP and pure JavaScript, no NodeJS BFF or anyhing like that, just plain old client side JS ...
I'm implementing Gitflow at the company I currently work for and everything is going pretty well. I'm just not completely sure if I'm dealing with more than one release on the pipeline at the same time in the best way Our systems have 5 environments as follows: Develop: deployed whenever there is a merge into develop....
I am a bit torn about the database design for a solution. I have the following structure: (only the relevant fields are marked with #) +------------------+ | activities | |------------------| | #connection_id | | #updated_at | | #activity_type | | #status | +------------------+ | +----...
For learning purposes, I'm trying to build a compiler in JavaScript for a tiny custom language and turn it into WASM. So far, I've got a lexer and parser, that turn my code into an AST, my question is about the next step: compiling/emitting WASM instructions from the AST. I'm wondering, given I'm doing this in a dynami...
I am not clear on what advantage does strategy pattern offers over simple if-else. Example of poor code //poor code that we all can agree is not the way to go ----- main class ----- String strategyname; //lets assume at this point variable strategyname has a value assigned somehow at runtime if(strategyname == 'algorit...
We have a Web server (which also does authentication and authorization) that manages, via an API, one or more servers that contain highly sensitive data. In the below architecture diagram, we manage everything except the end user: We are looking at using JWTs for token based authentication/authorization. This token is...
"Emergency fix" is a fairly commonly used term. I've seen this used as an excuse to skip important development or testing steps though, because it's an "emergency". The word "emergency" seems to convey some degree of panic and thoughtlessness that isn't good. Is there another term that people use to describe a change t...
I was reading a blog of how a problem was solved on the Lyft blog here: https://eng.lyft.com/applying-gevent-learnings-to-deliver-value-to-users-part-4-of-4-36ad932deea8 This made me go to their main page: https://eng.lyft.com/ which is a Medium site and I saw a lot of such blogs. I was wondering why would a tech for-p...
When working on a monolith application in a "waterfall" process, a "Fix Version" field makes a lot of sense. Say you have the "November 2020" planned release, you can add/plan dozens of relevant bugs and features to that release. Other bugs and features may be planned for the next release of "December 2020" and so on. ...
I have a rather basic application hosted on Kubernetes, which connects to a Mongo database. The app has a wallet feature. A user can put money in their wallet using real-world payments (e.g. via PayPal). Each payment is registered as a transaction for that user. The money in the wallet is then used to pay for orders, w...
Say there is some view that displays user details like name, age, email, etc. That view could maybe be constructed with the following pseudocode: UserView(User user); And that view would be able to pull all needed info from the user object. But maybe the User class has a property ID, and we have some type of service th...
Let's say you have a database-credential resource that stores a few things: whitelist of IPs that can connect connection password for the user When GETting / POSTing these, should they be under one API /database-credential or under two separate ones? The reason I'm hesitating is because the whitelist of IPs will be ...
I've inherited some legacy code which has some ostensibly strange views in an SQL Server database. They are basically complete passthroughs for a table. No column differences - a comparison of the columns using INFORMATION_SCHEMA.COLUMNS yields identical results. There is no limiting with WHERE clauses. There are n...
I've read a lot about dependency inversion principle but still, I can't apply it to my case. I just don't know when I should apply it and when not. I write a simple application in Java to generate invoices. For now, I have basic classes: Client, Product, InvoiceLine and Invoice. Should these classes communicate through...
This problem statement is around one UI component, 3 service components. The current design of the application is like: UI makes request to Service-A to get data Service-A first makes a call to Service-B to get list of items. There can be multiple calls between Service-A and Service-B if there are huge number of recor...
I am trying to create an object model for a user and a chatroom. I'm stuck on where to place certain functionality when the objects collaborate. At the moment all the functionality for the User is inside the User class, a snippet of its methods are: User.JoinChatRoom() User.WriteChatRoomMessage() User.Authenticate() U...
I recently started learning about REST APIs and I am trying to understand how they work and what they are used for. From what I have read so far and from what I understand, a REST API can be used as a back-end for multiple different applications at the same time, android applications, web applications etc. Is that the ...
This is my first time I am using repository pattern and applying a layered architecture in a project. I have followed the article found here. The complete code found on the article can also be found on the writer's github. I read the whole article beginning to end before getting my hands on the keyboard to start coding...
I recently posted this question: Rest API for multiple applications? After searching a bit more and reading this question https://stackoverflow.com/questions/41189842/what-is-difference-between-rest-and-api, I want to ask how I should choose between a REST API and a non-REST API? Why should I prefer one style over the ...
I am working on a project that uses Entity Framework Core. I have a class which represents an entity on which I'm trying to perform validation. Is it considered a bad practice to include a Validate method to the class itself (note that the Validate method would not be the only method included)? Is it better to create a...
For my use case I need to create a microservice that receives log messages through HTTP. I'm wondering about the reasons to pick either of these: Method: POST URI: /{logLevel}/ Body: { "message": "..." } Method: POST URI: / Body: { "level": {either string or enum}, "message": "..." } I feel like with the first met...
In Computer Systems: a Programmer's Perspective, 12.7.1 Thread Safety When we program with threads, we must be careful to write functions that have a property called thread safety. A function is said to be thread-safe if and only if it will always produce correct results when called repeatedly from multiple concurrent...
Imagine a production line - say, building a car. Starting from the beginning, a long, defined sequence of operations takes place, and at the end a car comes out. At various points along the way, production stops and waits for input from a human being; other parts of the process can be carried out automatically. Taking ...
I have a table-like feature set in a game. What it means is I have 10 types of battle, and 10 types of features related to battles, like hints, start/end logic, rewarding/spending resources, statistic etcetera. For every type of battle each feature has it's own unique conditions and outcomes, resulting in total of 100 ...
We are consolidating a number of disparate monoliths, redesigning and implementing a greenfield suite of microservices and micro-frontends. The stack is all new, the design is all new - it couldn't be more different to the legacy systems. Things are going fine because we have focussed our efforts on internal efficienc...
I am building an API in expressjs and, currently, mongo/mongoose. I currently have some model methods that return true or false, some that return a value or false, and some that return a value or throw an error. This is making my handlers a bit cumbersome / complex so before the project gets any larger I'd like to stan...
In Smalltalk we say "send a message to an object", but is it also correct to say "send a message to an object" in Java, or is it only correct in Java to say "call a method of an object"?
Here's my problem. I want to make fast, subsequent requests to a REST API endpoint (/todos/:id/position) that have side effects on other resources. As an example of 5 fast subsequent requests: PATCH /todos/2/position {"position": 2} PATCH /todos/2/position {"position": 3} PATCH /todos/2/position {"position": 4} PATCH /...
Should the exception blocks in a try-except sequence be specific only to those exceptions which may originate from the try? Or can they be inclusive of exceptions that may arise from handling the original exception caught? I currently have a function that has a try-except block to write some data to file. When a specif...
I am building an open source task management and note taking service that runs on AWS. I'm building it mostly as a hobby in my spare time and will eventually ship a mobile app that consume it into an App Store. Because this is being built nights/weekends as I have time I am trying to use managed services as much as pos...
I have a problem statement that describes an online E-commerce system: An E-commerce software system is going to be developed. This system allows customers to browse the store catalog, pick the items, and put them in an e-cart. Customer can place an order and enter his shipping details, credit card information. It pro...
I am comparing C++ with Python. It is clear that C++ is much more efficient and that the C++ code compiles directly to machine code whereas in Python it is interpreted. I do understand that Python is a higher-level language. But what difference does it make? I intuitively understand that C++ offers more "control", but ...
I am working as part of the team on the web api application. The Entity Framework used as ORM, I have the idea to keep all selectors in services. E.g. we have Cat table, then would be CatSelectorsService. class CatSelectorsService { public Expressions<Func<Cat, bool>> NeedToPlay() { var date = DateTime.Now....
Computer Systems: a Programmer's Perspective says The readers-writers problem has several variations, each based on the priorities of readers and writers. The first readers-writers problem, which favors readers, requires that no reader be kept waiting unless a writer has already been granted permission to use the obje...
it might be too opinionated, but I've been struggling in this for far too long and cant seem to make up my mind. I am trying to compare two approaches to designing a system: Lets assume You want to crawl a site periodically, if some condition is met, you want to take a snapshot of the webpage. all that should be record...
I'm reading about Toyota Kata and am impressed with the approach of continuous improvement of the process through constant experimentation toward a target condition. What I haven't yet found anything about is how to handle this from a scheduling perspective. The Toyota Kata approach is, of course, useful also for regul...
As part of our project (web application), we have to design REST API to manage the users of our application. Our API will be based on a company user management product (I will call it: C.U.M.) that manages all users of all company applications (for each application we have a specific group). So by definition: a user of...
We know there are services in windows but I am reading a book by Ed Snider and he uses the term “service” whenever his program requires a certain feature/functionality. Like he creates a navigation service which allows page to navigate to another page. The service is essentially an interface in C# which is then impleme...
I have some code similar to shared below, which returns different kinds of response messages to the caller. If the return value is empty string, the process is continued. If a message is returned it will show the message to user. (Please consider this is demonstration code, not really used so I might have some syntax p...
Operating System Concepts says 7.4.4 Circular Wait The fourth and final condition for deadlocks is the circular-wait condition. One way to ensure that this condition never holds is to impose a total ordering of all resource types and to require that each process requests resources in an increasing order of enumeration....
A company makes their website client side open source and claim that it is exactly equal to a certain version that can be found in a github repo. I want to verify their production website (client side) exactly matches the source code. If I can access their github repo and also the production website via my browser, how...
I'm using C# but the problem could also be with Java. I have an object in the flow that is muted for setting up some properties during the flow of the program. Let say public class Person { public string name {get; set;} public string surname {get; set;} } public class Citizen { public string name {get; set;} ...
How would you define the system architecture (mostly in terms of database structure) for a system which needs to have data available both at tenant level and organization level. An example of this is the following: A business is a client (let's say OAuth2 client) in the system. The business can have multiple subsidiari...
Generally, if two semaphores are acquired one after the other, is there difference between releasing them in the same order or the reverse order as they are acquired? In the following solution to the third readers-writers problem from http://en.wikipedia.org/wiki/Readers%E2%80%93writers_problem#Third_readers%E2%80%93w...
For systems that are built on top of diverse tech stacks, including both static and dynamic types languages, what is in practice some ways to have the API contracts published and enforced? Some wiki documentation would just stale over time so I was wondering what are various approaches used in industry for this?
I am building a REST API which would power a front end as well as other 3rd party apps and hence I want it to be as "standard" as possible. Right now, I am trying to stick to HATEOAS. The only place I am struggling is pagination. The authorization layer of our application is centralised. Multiple other apps use the cen...
According to Wikipedia: Semaphores are a useful tool in the prevention of race conditions; however, their use is by no means a guarantee that a program is free from these problems. Semaphores which allow an arbitrary resource count are called counting semaphores, while semaphores which are restricted to the values 0 a...
What is best practice to define a main function and entry point for a script/module that may be used started as main, but not always? Here's how I've been doing it in the past, similar to realpython: def main(): result = do_stuff() return result if __name__ == "__main__": main() This is fine for most purp...
Good afternoon, I'm getting into microservices - in fact, I've managed to make few full projects based on that architecture - but they weren't really robust, so I couldn't get the full scope of using microservices. I'm struggling with 2 concepts related to scalability and reliability, and I would appreciate a simple ex...
I have a Spring Boot application to implement a RESTful API. One of the GET requests have two query parameters: from and until (of type date). Those parameters are optional, so user-agents can send both, none or just one of them. The query parameters are then used ("down") in the flow to filter data sets by (a typical)...
First off please note, I’m fully aware that Git has historically been terrible at dealing with large binary files and very large repos; there are at least a dozen questions on SO that deal with large dataset performance, but as far as I’ve found, they’re all years old and the answers all more or less predate a number o...
In Little Book of Semaphores: 4.1.6 Finite buffer producer-consumer solution Finite buffer consumer solution 1 items.wait () 2 mutex.wait () 3 event = buffer .get () 4 mutex. signal () 5 spaces . signal () 6 7 event. process () Finite buffer producer solution 1 event = waitForEvent () 2 3 spaces .wait () 4 mutex.wait ()...
From what I understand, an abstract data type is basically some data and what we are allowed to do with that data (ex. a list with a set of data and an attribute size and the functions get(), set(), sort(), insert() and remove(). It's an abstract data type because we do not know what the data inside is going to be or h...
So... Le's say I have 3 tables named: Member Bus AutorizeMember ID Member is referenced to Bus and ID Bus is referenced to AutorizeMember which is also referenced to Member 3 times. Thats is because there are some cases that a member in the Bus (which is the Bus' Owner) can select or not 3 others members who can driv...
I want to build an achievement system that awards certain badges based on conditions, I wonder how to tackle this, if for example, the user has ran 9999 kilometers, if I want to award him a badge when he reaches that 10.0000km, that would mean after each activity, loop all previous activities and take the sum of the di...
We're currently using the Apache Camel Java DSL to structure our application, but I guess this question can mostly apply to any DSL in general. Now, amongst our developers, we are divided on two polar opinions as to how to structure our codebase: Approach 1: Use the DSL as rarely as possible, and stick to using plain J...
I have a function that repeatedly encodes Foos to string. I'm currently deciding between two ways to implement this: Return by value: std::string encode(const Foo& foo); void important_function() { while (1) { Foo foo = get_foo(); std::string encoded = encode(foo); save_to_file(encoded); } } Use outpu...
Suppose I have the following entities in a commerce data model: BaseProduct (PK id, price, name) LineItem (PK id, FK product_id, price, name) Order (PK id, line_items) An Order includes one or many LineItems. A LineItem includes a reference to a BaseProduct, but, and here lies the crux of the question, we don't use ...
I have a configuration problem, from this code, https://github.com/plum-umd/java-sketch. Here, I must set $JAVA_HOME, because: "One possible issue you may encounter while building sketch-frontend is the inconsistent Java version in Maven, e.g., Maven refers to Java 1.6 while the main Java you're using is 1.7 or higher....
We are building a software, which we have companies registering their products. We (the administrator) will have the help desk team that'll be able to help our users (companies) in case of problems. Our platform performs transactions, and with such, we expect user support. What controls should my help desk team have ov...
We have a managers api (/api/managers/-/staff), which will get a list of staff that the currently logged in manager has been granted access to. It is the Managers service. We also have a staff api (api/staff/[StaffGUID]/obs/sessions) that will get staff data. You have to be an authenticated manager to make a call to th...
I've been working on feature_A while another dev works on feature_B. Now, the other dev needs a small functionallity that's implemented in my feature_A, but I've not finished the whole feature itself. How should I share the code to the other dev? Is it against git-flow branching model? Can I simply merge feature_A into...
When there are two feature branches that has some dependencies, and they are work in progress, but some piece of code want to be shared, why shouldn't I merge a feature into another?
We have the following use case to be developing: A web application that shows a data table / data grid with up to 100000 rows and 30-50 columns. Each column is filterable and sortable. The web application is based on Angular and PrimeNG (with PrimeNG Table) and the backend is based on ASP.Net Core WebApi, but i think t...
I'm looking for ways how to accept arguments in the domain model when you want to add items in it. Let's take a look at this example: public class Order { public ICollection<OrderItem> Items { get; set; } // Way 1 public void AddItem(OrderItem item) { // Add } // Way 2 public void A...
I would like to get some help or ideas regarding the usage of JIRA and getting insights from it. I just joined a small company as a junior project manager. In the last several sprints, Developer "X" burned significantly more points than any other team member. Which parameters I can use use to identify the reason for t...
I would like to get some help or ideas to solve my problems, I just join a small company as junior project manager and I faced with 2 challenges sorry for my ignorance but I am new into the agile world. QA has many tickets in each sprint that appear as “Ready for testing”. Some of them are indeed ready, while others -...