instruction stringlengths 34 36.1k |
|---|
I read/watch about Uncle Bob's clean code and when he talks about exceptions he suggested to have a well named exception over a description which make perfect sense for the programmer, for decoupling the main application form the business logic and for the tests.
But what about the user? I have an application that take... |
Our business domain is complex. Currently, our business is written using ASP.NET WEB API HTTP services. So, applications including web, mobile and desktop are talking with these HTTP apis. Now, one of our Manager informed us that the big enterprise are not using any programming language/framework to write there busines... |
I have a Website which has a BFF (back end for front end).
It consumes data from a service (a CMS) and its own configuration data.
The CMS data and the apps config data are in separate schemas (so could be in different physical databases)
I need the BFF to decorate config data with cms data
So the options are:
Queryin... |
I am debating two strategies for setting up a linter for my team's github repository. Is strategy #1 standard practice, or not?
#1 - Set up a pre-commit hook that runs the linter
#2 - My team will manually run the linter on external Pull Requests
#1 puts more responsibility on the contributor because they need to ins... |
I'm learning about writing WebApi design patterns.
I am trying to create a simple CRUD web app with ReactJS UI and C# .NET CORE webapi with sql backend.
Articles show that specific Repositories are a direct reflection of the tables inside the DAL. And the services layer handles the domain objects and draws entities fr... |
Assuming we have polymorphic entities such as the following, with constructors enforcing invariants (assume there could be lots of sub-classes). What would be an effective/elegant approach to construct each concrete instance type while avoiding excessive code duplication?
abstract class Something {
Data fieldA;
D... |
My applications uses error reporting to track exceptions.
My application uses SQL transactions to make sure that operations are completed completely or not at all.
My application is multi-threaded.
Exceptions will occur when more than 1 transaction attempts to do the same thing. This is good because only 1 of them sho... |
I am having a hard time trying to wrap my head around the relationship between Controllers and Presenters in Uncle Bob's Clean Architecture.
In most of his videos, he talks too little about controllers, and a fair amount about presenters. The knowledge available online isn't helping me much either, because there are to... |
I have trouble reconciling "best practices" and real-world approaches to handling exceptions. In my day to day routine, I find myself running into the following examples:
try:
do_something()
except Exception:
log_error()
and even
try:
do_one_thing()
try:
do_another_thing()
except Exception:... |
I work on a C++ project where I am not really happy with the data structures. The question isn't that specific to C++, I think that I would face a similar issue in say Java or Python.
There are data structures that have no direct relation in the code, although they have a 1-to-N relationship.
struct Element {
int i... |
I'm new to the microservices field.
I'm looking for the right approaches regarding how to deal with the challenge of redundancy of a pus-sub application.
Assume my application has has the below constrains:
Real time (very critical)
Heavy load time
Lots of events
Events are metrics (like temperature, stock prices, etc.... |
Is there an accepted way of documenting logic when writing requirements?
I'm trying to document some logic in a requirements document. Currently I just put in a snippet of code, but I know this is wrong. It seems there should be (at least one) standard for documenting logic without being language-specific.
A simplified... |
Brief overview of general data flow
The general goal of my system is to allow users to upload many different types of files containing data (PDF, CSV, ZIP, etc.), then index it and perform some basic analysis to make it searchable and to be able to draw links between the files.
The general flow goes like this:
User up... |
In Programming Distributed Computing Systems:
7.3.4 Distribution
Distributed computing is inherently concurrent. However, distribution
aspects go far beyond concurrency. Of particular importance from a
modeling perspective is the capability to reason about the location
(and potential co-location) of concurrent com- pu... |
Scenario is simple, a password field with few validation rules.
The states I came up with are
default ( when the form loads or reset button is pressed)
filled ( should this even be a state ?)
valid ( date is present with all rules satisfied)
invalid (data is there but not satisfying the rule set )
Error message is di... |
I have a class that wraps a map UI element: Map.
The map can have overlays that appear on top of it, in both side panels and modal windows. When these UI elements appear, I want to temporarily disable map interaction and prevent multiple overlays appearing on top of each other.
Therefore, I inject an interface, IMap, o... |
I am in the process of designing a database organizing real world items in different storage locations.
One main principle is that items can contain other items.
So the relevant table is:
An "items" table in which one column "insideOf" has a FOREIGN KEY restraint to the id of the item containing it.
Setup
the table c... |
Currently working on a legacy app. One section deals with generating "reports", each which share some common subsections, that are based on strongly-typed razor partial views. The largest report has something like 20 "partial views" for various subsections, most that occur in some other reports as well. Some of the par... |
https://en.wikipedia.org/wiki/Execution_model says
A programming language consists of a grammar/syntax plus an execution
model. The execution model specifies the behavior of elements of the
language. By applying the execution model, one can derive the behavior
of a program that was written in terms of that programming... |
I've been learning about Progressive Web Apps and how they can provide more offline functionality within a native app-like feel. I want to give users the option to download a whole site (all pages/resources/assets) but still have that native-app like feel. Is this possible?
From my current understanding through reading... |
I have a reinforcement learning project.
For this I created a vectorized environment in C++, which is a handler for multiple instances of a simple game.
It is highly parallelizable. Each worker can work on their own batch of instances, there is no information exchange between them. (For the most part.)
My current appro... |
Cross-posting from SO.
Is there a name for the patterns used send messages/errors and results through an application's layers from business logic/database to the UI? What is the modern way?
For example:
The application layers are setup as follows:
UI <-> ViewModel <-> Business Logic <-> Database/Repository
A user wants... |
I am doing a lot of sequence diagrams. We decided to start at a subsystem level of abstraction because we do not have all the details yet. In my diagrams I was using this definition of Actor:
In UML, an Actor is always something (a system or person) that is outside the scope of the system/software that you are building... |
My Proposed Monorepo Architecture
This layout is what I've come up with from reading through tons of articles and being convinced that Nx suits many of our needs where I work. The layout works fine for a company of this size because we need opinionated architecture to keep things running smoothly.
Goal
I want to achie... |
In the past few months that I've been learning Javascript, I've wondered which is the better usage of functions:
Functions that perform actions based on their arguments with no return value:
const someName = 'John';
function sayHello(name) {
console.log(`Hello, my name is ${name}!`);
}
sayHello(someName);
Or funct... |
I am developing a visual editor for an entity component system. The editor must be able to modify the members of differents components subtypes, so we have a specific window for each component subtype.
The problem is we can't modify the components to implement a polymorphic method to display the correct window since it... |
I'm wondering how to effectively test a lexer (tokenizer).
The number of combinations of tokens in a source file can be huge, and the only way I've found is to make a batch of representative source files and expect an specific sequence of tokens for each of them.
|
I plan to have a cloud web application(CWA) and several local web application(LWA), let's assume 3 LWAs and 1 CWA. CWA === LWA.
This web application would consist of a database server, file storage server, An Application server.
I have two options for synchronisation:
Option 1:
A record saved in LWA-1 would reflect in ... |
I am drafting architecture for 1:1 video calling mobile app with face filters (face recognition).
I could use p2p e.g. WebRTC because more savings less complexity. However, continuous face rec during a video call on cheap phones becomes more expensive for the device.
Is this cost increase generally significant enough t... |
I'm working my way through Refactoring: Improving the Design of Existing Code by Martin Fowler and I came across the following passage (2nd ed, p. 55, emphasis mine):
To a manager who is genuinely savvy about technology ... refactoring isn't hard to justify. Such managers should be encouraging refactoring on a regular... |
I have several drawings from SVG files which basically contain basic outlines of figures. They are constructed in segments of various shapes (lines, ellipse arcs, Bezier curves ect.) Something like this (maybe not the best example):
I want to create an algorithm that traces (draws over) the countour of all shapes once... |
Suppose we have the following C snippet, implementing a tree data structure:
typedef struct node {
char* data;
struct node** children;
unsigned int num_children;
} node;
Then we could create a leaf constructor that looks like the below,
node* make_leaf(char* data) {
node* res = malloc(sizeof(*res));
... |
I want to know if there is a best practice around packaging the Resource classes of micro-services. By Resource classes I mean the contracts (like request, responses and error objects of the service)
Package inside the micro-service
Package as separate jar etc and version control it separately and include dependency i... |
How can I model a supporting recurring activity for a process?
A more general example is how to model waiting for customer actions while performing follow-up actions.
We have a process where we send a message to the customer and once they respond, we go to the next activity or stop there depending on the answer.
We wan... |
All the books which talk about test-driven development (TDD) illustrate it with only very basic examples, less than 100 LOC.
The algorithms I wrote using TDD were larger, but still relatively small in size and complexity.
I'm pretty sure I know a few developers who successfully used TDD on algorithms of a few thousands... |
As far as I know the big argument for C#, Java and other high level languages having to be memory managed by a runtime environment is that the programmer does not take care of garbage collection or destruction of objects (if she does not want to). But is that really something a compiler could not do? It should be fairl... |
I've a Python project with ~30 SQLAlchemy models and I'm not sure where they belong. All models belong to the DB but also to a module, so I'm not sure about the right namespace.
Here are some ideas:
import db.models.MyModelA
import my.module.MyModelA
import my.module.db.MyModelA
Is there any best practice that I didn... |
Suppose I have a function to log error messages printError(). Suppose I have another function which might throw an error, doSomething(). Should doSomething() implement its own error logging or depend on the existing printError()?
Generalizing the question, should new code depend on existing code? In the given example, ... |
So this is in regards to scraping yes; no language in particular. Some sites allow you to see a JSON modal if you pull it directly from a web browser. But, at any notion a program is used, immediately declines the request and asks for an API? How does the site know the difference between user request and say a request ... |
I have two types of input data which will go through a number of steps for processing. The processing differs only in one of those steps, e.g.:
TypeX: A() -> B() -> Cx() -> D()
TypeY: A() -> B() -> Cy() -> D()
What's a good way to approach structuring this type of code? For example, I could branch right at the start:
d... |
I have an iOS/macOS tennis app that now lets the user import video, and I would like to add the ability to automatically edit out the significant amount of downtime where players are not in a rally or point. To start I considered filtering the video down to segments where tennis ball trajectories are detected, however ... |
I'm trying to implement an Event Store, to be used with Aggregate+Event Sourcing (A+ES), and I've run into I think a gap in understanding.
I'm reading Implementing Domain Driven Design, using both the Domain Event/Event Store and Appendix A: A+ES sections as a template/guide.
In the book, there are two types used, the ... |
Recently I was going through an article (link at the end) on AWS for DynamoDB NoSQL and got to know that they are suggesting to only have a single table with certain access patterns in your NoSQL database.
But previously in all of my projects I generally followed the Domain model pattern and in that what I did was to f... |
We have prepared a Git flow with teammates, and I wonder if it is sustainable. We want to keep committing on both dev and feature branches. Also, we we want to avoid facing with conflicts during merging. Do you think if there is better way to manage the commits?
Currently, we are using SVN, but we want to move Git. Thi... |
We have a relatively big class. One of my colleagues thinks we must split this class into a base & child class to make it smaller and cleaner.
On the other hand, I believe when we know this parent will always have only just this one child, inheritance isn't an appropriate solution.
So imagine these classes:
public clas... |
I'm a developer for a retail enterprise IT department, and am currently stuck on the following scenario:
Department A is responsible for a CRUD service that's used for handling stores - so when our company wants to open a new physical location, it goes through there.
I'm in department B, which amongst other things is r... |
https://en.wikipedia.org/wiki/Memory_coherence says:
Memory coherence is an issue that affects the design of computer
systems in which two or more processors or cores share a common area
of memory.[1][2][3][4]
In a uniprocessor system (whereby, in today's terms, there exists only
one core), there is only one processin... |
I have an array of events where events[i] = [startDay_i, endDay_i, value_i]. The ith event starts at startDay_i and ends at endDay_i, Attending the ith event, I will receive value_i. Also given an integer k which represents the maximum number of events I can attend.
It's required to attend the event only once at a time... |
After so many years I started to study again and finally I arrived at the fateful thesis for the three-year degree.
I've been working for 20 years as a systems engineer and I haven't studied programming since I was a young student. As luck would have it, I was assigned a compendium thesis on object-oriented programming... |
I'm interested in becoming more familiar with functional programming as a paradigm, so I'm trying to introduce a more functional style to some of my projects. I'm struggling to understand how to handle side effects with a database.
I have some functions that kind of look like this:
db query
... |
About coherence vs consistency, https://en.wikipedia.org/wiki/Consistency_model says
Coherence deals with maintaining a global order in which writes to a
single location or single variable are seen by all processors.
Consistency deals with the ordering of operations to multiple
locations with respect to all processo... |
I know this is a very basic topic, but I'm curious why an abstraction in programming is always defined as a simplification/hiding of some functionality. Let's say I wrote a set of functions that let me use some functionality in some more convenient way, but I didn't exactly simplify anything, just transformed it. Would... |
I have a program that calculates N digits of Pi.
I have measured that it takes 10x time to calculate 3n numbers, compared with the time for calculating n numbers. The source code also gives an indication for this running times.
For example, if 1000 digits take 0.011 seconds, 3000 digits take 0.11 seconds, and 9000 digi... |
So I am an independent software developer and I'm building up my portfolio in the hopes of helping with job applications. I have a broad design for a web based "app" (not really like a phone app, more like a web platform) that in reality would only "scale" if it used microservices. (It's a recommendation-based content ... |
My question is, knowing everything there is to know about several systems(CPU and GPU stats, OS), is it possible to approximate when each system will finish a specific processing operation?
And if it is, could you please share some resources as to how one could do that?
For example is it possible to know approximately ... |
I'm developing an UI application where I ran into an issue with a cyclic dependency. Here is the simplified code, to explain the problem.
#include <list>
class UiStyle;
UiStyle* CreateStyle();
class UiWindow {
public:
virtual void Draw() = 0;
};
class UiMenu : public UiWindow {
public:
void Draw() override {... |
I'm building the order endpoint for an ecommerce rest api so that clients can place orders. I'm trying to determine the advantages or disadvantages of two approaches:
Approach 1
Payload:
{
'total',
'customer': {'firstName', etc.},
'shipping_address':{'address1', etc.}
'items': [{'nameOfItem', 'sku', 'price', e... |
Currently I am designing a cross-platform mobile app using Ionic and vue.js.
That app enables users to create a game, add players and play rounds. When the game is played, a score for each player will be kept.
Now I want to enable the functionality to show this score via a web-application, so it can be shown on a proje... |
Pretend I have entities A, B, C, D. They each have a structure as follows
public class A{
public IEnumerable<B> Bs {get;}
public IEnumerable<C> Cs {get;}
public IEnumerable<D> Ds {get;}
}
public class B{
public IEnumerable<B> Bs {get;}
public IEnumerable<D> Ds {get;}
}
public class C{
public IEnu... |
I'm new to PHP and JS and I'm currently working on a gym management web app for our project in school. I'm adding a bit of QR functionality that sees if the user is eligible to enter the gym or not by checking if the user has paid. I want to know if it is good to escape PHP code in inline JS, or would it be better to g... |
I have an infrastructure package that multiple projects depend upon. This package is supposed to be a stable API shared by those projects.
I want to know if a change made in the package has broken older functionality and changed api.
In more detail, I want to automate the test on the CI that makes sure that if a user h... |
We have been relying on our database to generate IDs for our entities and guarantee uniqueness.
Recently, and because of GDPR, we are obliged to redeploy the whole system (EC2s, DBs, microservices, etc.. ) in Europe for EU clients, opening the possibility to id collision.
Team members have suggested the following so fa... |
In my model a user entity has three attributes : ID, name, hasBoyfriend.
I want now to change hasBoyfriend to boyFriendsNames which is an array of names .
The user entity is used by many services.
The question is:
Should I keep the deprecated hasBoyfriend attribute and gradually remove it Or should I remove it complete... |
I have an old windows forms gui used to control a custom measurement system. Originally, it handled acquisition, calculating, database handling and presentation of measurements.
Now, because of some hardware changes, the system got its own arm based microcontroller running a linux os.
So I re-implemented most control f... |
I have a WPF application used to execute logic that tests hardware (i.e. reads sensors, amps, voltages, etc.)
Each individual test runs when a "Test Device" method is called. I need to be able to exit the method when one of the tests fails so that no further tests are run.
However, using an if statement results in a bu... |
Given an application having:
Configuration Files (xml or json)
An Automated Deployment Process
After the deployment the configuration files can be modified by users.
When deploying a new version of the application, the new version can include new configuration properties, one would like to add the new configuration p... |
I have a couple of doubts regarding the quality of my code. I'm working on a helper function (for KoaJS) where I'm validating a Firebase ID token. If it is valid, I return the decoded token; otherwise I return an authorization error.
Also, if the function is initialized to request email to be verified, it will check if... |
I have a complex Angular app which has a large number of UI components. I have a central NgRX store. I have a 'pure' data model in the store which gets updated via the backend and via user input. Whenever the central store is updated I build several view models which I'm storing in the central NgRX store. My UI compone... |
I'm struggling on a design question for my Ruby on Rails website. I'm working on an estimation tool for construction companies for renovation projects.
It orders items this way by default:
Room (ex: Kitchen)
Section (ex: Painting)
Item (ex: Painting the ceiling)
But sometimes companies prefer to order items thi... |
Am going to handle a CRON job module which will be a generic module, on the job execution time shall I push the events to a queue so let the respective module will pick and do the respective operation. My question is that whether different modules can listen to the same queue? Is the below approach is correct? else can... |
Simply put, I have date and time attributes on an Orders table. The data types for these attributes are MySQL's DATE attribute. But everytime I echo the date and time in PHP it just gives me a string, not a date object. I don't understand as to why the DATE data type exists if you can casually store date objects as VAR... |
In the book Clean Code, Robert C. Martin says that we should avoid polyadic functions (functions that contain four or more arguments).
One of the solutions presented by him is the use of objects as parameters.
In some cases it is easy to identify arguments that can become or be grouped into an object. However, in other... |
I am currently trying to name a method that prepares/alters some input data, then passes it on, and I'm wondering if there is a naming scheme for such methods.
Concretely, I have a reusable UI component that will copy its contents on user interaction. Users of the component should have the ability to pass a method to t... |
In Fundamentals of Parallel Multicore Architecture, by Yan Solihin, p304 defines sequential consistency memory model:
Overall, we can express programmers’ implicit expectation of memory
access ordering as: memory accesses coming out of a processor should
be performed in program order, and each of them should be perf... |
I was creating a class model using inheritance, and have a situation I don't know how to represent.
For this question I built an example diagram in which I have a class Person with some attributes.
I also have a class Class1 that needs to use objects of a new class with Person's attributes plus sex and birthDate attrib... |
I'm manufacturing a product that I will be selling to retailers throughout the United States. I want to be able to track the products manufacturing date, who we sold that batch of production too, and some other data in the QR code so if I ever get a product warranty claim I'll be able to pull up all that data. I also w... |
Background
I do programming with Python and now and then i run into a situation where i have to use regex
Typically i try to learn a bit about it and look at examples of doing things similar to what i'm trying to achieve
Problem
The problems i have with regex:
Difficult (for me) to learn and get used to. Honestly i'm ... |
Note: I'm using Dear IMGUI, OpenGL and C++.
I have a UI, it has two "modes" one where it records and displays images and information about a recording device (IE camera) and another where it can read images and display them in from a certain format. The two "modes" share post processing functionality, in the sense ther... |
I am calling a payments API to send a payment.
At the same time, I need to mark the payment as sent in my database.
If I call the API first, then the database crashes, the payment will be sent twice.
If I save to the database first and the API request fails, the payment won't be sent.
What's a good solution to this? Is... |
Please note: although this question mentions Angular and Spring Boot (Java), and it would be great to get an answer from someone with experience in that stack, I think this is more of an architectural question at heart and certainly doesn't require Angular or Java/Spring experience to answer it.
So, I am designing out... |
I am wondering what are the best practices to build multi-tenant applications, specifically ways to obtain tenant identifier or detect tenant. I am aware of domain based tenancy where domain tells you who is the tenant. In one of my applications where domain based approach is not an option, i am storing tenant id alon... |
I am reading about scaling of database and came to know about sharding technique. But I also read about consistent hashing technique. So how practically sharding is implemented? Do we arrange nodes in ring like consistent hashing and then assign servers to rings and then data to servers? Because as I see if my number o... |
Since Google controls both the sender and receiver in the case of a Gmail-to-Gmail conversation, couldn't they skip actually sending the email and route it internally? Why is there a need to invoke SMTP and everything? There is no cross-server communication that is needed.
|
I'm trying to understand what general mechanisms and/or concepts are available in SQL database last to synchronize local. Here are my inputs and requirements.
Multiple clients have a full copy of the database on their machine(SQLite). Typically at the end of every day, each user would synchronize with the remote databa... |
A question that I have been wondering for quite some time now, is how do two devices send encrypted data over the internet know the encryption keys to encrypt and decrypt the data, or more importantly how do these services automate the encryption?
Do these services have non changing encryption keys that all their users... |
I am working on an application where user can send in an absolute path of an image or URL as string in API endpoint. My code is able to handle that.
Now I have been asked to add the code which can handle byte stream in string format. How can I do this and is it advisable to make this type of end point? Shouldn't it pos... |
In machine learning we have modules that perform operations on data in a sequencial manner. Modules are generally the following:
Data Collection Module: Takes raw data from a resource
(filesystem,database,...) and ensures the data in the pipeline. We
can assume that the result of this module is an object of type
"Data... |
This may be a basic question, but I'm having some difficulty finding an answer online.
My project is a MERN application that draws from an existing open-source API. This API utilizes a database that I've already integrated with my own, which I plan to make changes to. So, we can't just use the existing hosting the API ... |
I've always developed my own applications and use certain criteria to evaluate if the code is acceptable from a quality perspective. Now I've switched jobs and have to among other things maintain existing software.
Here they put most of their business logic in stored procedures. This in itself I see as a bad practice, ... |
I am working on a feature with a system that I am unfamiliar with. The feature is not ready, but I want to show the code to my team (who is familiar with the system) so they can give me early feedback. We are a fully remote team.
Making a pull request on GitHub so they can see the differences seems like the easiest w... |
I have 2 classes that independently operate on specific file formats: class FileWriterA and class FileWriterB.
Each class has some shared methods (e.g., __enter__, __exit__, __str__, closed, is_closed, etc.) that when used independently are of no concern. There is, however, a relationship between the two. When used tog... |
In my company's code base there are examples of methods which receive some protobuf messages and use them in this fashion:
void doSomething(const A& a) {
// Only data from a.info() is used in this function. Roughly 4,5 times.
}
Where A is a message type with several (>20) fields and Info also is a message type with ... |
I have a device that has a NXP MK66FN1M arm core processor with a black and white display. This device is running FreeRTOS with serial, usb, keypad, display, external FeRAM, wifi, and ethernet.
What methods are available so that from a remote PC I can see just the same as what is on the screen of the device. We would l... |
Firstly, I want to state that this is my first time trying to build an app. I am doing this for fun, mostly as an exercise to learn system design/architecture. The goal is to build an app that would be scalable to millions of users (not that this app will actually have millions of users-- its just to build my own under... |
I've been a solo developer using git for years and haven't yet used the tagging feature. Typically I'll create a "new_feature" branch, make several commits, then merge back to my master branch. However, these are individual commits, and don't map to the feature all at once. I do like keeping them separate in case I ... |
In a fairly complex system with a dozen or more git repositories, most of them are done in a cookie-cutter fashion.
What is or would be your best approach to deal with duplication?
In my opinion the project creation could become a template so that you can easily scaffold another project. (so not centralized but copypas... |
I've an Excel file (offline, on my computer) that elaborates medium-large amount of data using VBA Macros. Basically, this Excel macro-powered file works with a person that adds the data to an Excel sheet, then clicks a button and finally gets a new sheet with the elaborated data.
I would like to provide the elaboratio... |
We currently have an application with various frontends, a backend with a python tornado server, MongoDB and a "REST" API (that isn't very RESTful) so are looking to update to a version 2.
A new start is suggesting GraphQL over REST. I am a little sceptical.
GraphQL does appear more flexible than REST, but that would a... |
I am trying to implement Clean Architecture on my Android App with standard MVVM components.
Almost every example I have found deals with simple business logic, i.e. simple CRUD operations over data fetched from either backend or local database.
For those examples, it's pretty clear that Use Cases use Repositories, and... |
I am planning on creating a network security testing tool with python that carries out a variety of attacks and tests other vulnerability issues on a host (Such as: Ping of death, slow loris, teardrop and so on) so security teams can quickly PoC different vendor appliances.
Since this is my first real "own" project...I... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.