instruction stringlengths 34 36.1k |
|---|
Context: I am working on a project in which people use tags on commits yet in branches waiting on the Pull Requests queue of GitHub. This means they are non-merged to the main branch yet.
The problem from my standpoint of view is that Pull Requests are unstable.
Still as a PR, after some changes, interactive rebase, an... |
I spend a lot of time lately talking about Microservices architecture and I have a really hard time buying all the benefits that are sold to me. For most arguments I hear I come to the conclusion that Clean Architecture can do just the same, especially when combined with strict implementation of architectural fitness f... |
I need to design an application which makes requests to an external API. External API has a hierarchy of entities: User which contains ListOfItemss which contain Items. I need to get data on all Items for all Users. Within a ListOfItems requests per Item can be concurrent/parallel but only one ListOfItems can be reques... |
From my understanding, a constant is a value which is assigned only once and cannot change at runtime, whereas variables have mutable values which are unpredictable by nature.
My question is, to what extent can it be said that a value is known? Can values which are only assigned once but have some intrinsic "randomness... |
I want to save an order with order items with prices in my write database. But firstly I need to fetch products with their prices because I don't trust a user - he could pass a lower price, that's why I don't want to add a Price property to CreateOrderDTO.
Where should I fetch product prices? In a command handler - if ... |
So I've been looking around to find a suitable hash function for a hashmap. Currently the best one I've found was from xxhash and maybe murmur after that, but they excluded CRC32C which can be optimized greatly by using 3 64 bit parallel crc32c instructions on SSE4.2 capable CPUs. CRC32 by itself seems to be quite outd... |
I've got experience with WPF, but I have always been creating standard UI's. I want to build a drawing application for electrical wiring diagrams (single-wire diagrams).
Example of the kind of drawings you should be able to draw:
I want to start simple. But I don't know how to handle the drawing in WPF. I know, drawin... |
I have an aggregate User and the user has a Score. The Score of a user is calculated by queriying a bunch of different tables and running through (often very large) result sets applying some business logic. Now from a business perspective in 95% of all cases only the Score of a given User is relevant and not the data t... |
Let’s imagine system like Garmin connect, you run, record your workout and then once you finish workout is uploaded to the system and being analyzed. Based on analysis you can receive badge: for 5 km run, for 10 km run, for 3 runs in a row (3 days), for run in the morning etc. I assume that it is possible to enter new ... |
Java is often (rightly IMHO criticized) for overusing the class keyword, as it can denote:
a factory to instantiate objects (traditional classes)
a collection of global methods (when all methods are static and there is a private constructor...the so-called "utility class" pattern)
an application (when it holds a publi... |
This is in context of a distributed computing. There is a Service A which owns a database and hosts APIs for updating an entities in this database.
As time went by, the service has evolved and we are about to add a complex capability to this service. This capability can be separated out to a service of it's own. But it... |
I was submitting this code in Java to an AI tool that checks for OOPS modeling and it says that this class is breaking encapsulation, although it did not gave any reason why.
The objective is to store the three types of subscription for a user (music, video or podcast) and add a topup only if atleast one type of subscr... |
I'm trying to understand the CQRS design.
As far as I know now, every time a change to a model is saved, the (state) change is stored as a separate record.
When reading a model, the model is constructed of the changes that are stored.
Like:
Model User
- username : "JohnDoe"
- email : "hello@example.com"
- job : "Window... |
I am building a simple web app where one set of users have varying admin privileges who can write to database and the other set can only view data.
I am used to securing APIs with JWT or session tokens, but my boss is 50-year-old DBA who thinks it's not secure. He is saying I should implement security within database i... |
I'm trying to create repositories in my app. The problem is mainly with 2 entities:
Workspace
Member
a Workspace has many members, while a Member is only related to one Workspace (so a member exists only within a workspace).
Workspace has the functionality to add members and check if members exist:
class Workspace(pr... |
I have a mysql database in which I have drafts, each of which contains exactly 24 players the order of which matters. I am conflicted between having a drafts table with 24 extra columns for each player or creating a new table for a one-to-many relation between drafts and players.
Drafts
ID
Arbitrary info
Player1_ID... |
According to Should I use a layer between service and repository for a clean architecture - Spring the Peristance layer is deprecated because the Repository is already an abstraction.
UML solution of the previous question
Product and ProductEntityJPA
But, in reality we have to use two entity :
One for the domain entit... |
I am currently working on a Raspberry Pi based robotics project that I would like to connect to a realtime customized control panel/dashboard, mostly for debugging purposes. I created a test setup where each instance of the robot "operating system" can be seen as a separate device in the dashboard, with a unique sessio... |
Default interface methods of C# 8 and extension methods have in common that you can "add" a method with implementation to an interface.
"Add" being in quotes here because for extension methods that's not quite precise.
Extension methods only associate a method with a type, which makes autocomplete suggest it when you a... |
I have a 3 layer architecture application with presentation layer, business layer and data access layer. UI -> BLL -> DAL UI Layer has reference to only BLL and BLL refer only to DAL.
My BLL has DTOs used by view and use service class that inject repository class from DAL and map DTOs to specific DAL entities for sendi... |
I am trying to create a duration matrix, that is, time spent in each status based on the status transition event logs.
I have the following event log where status transition time along with old and new status is being captured.
| Event Time | Old Status | | New Status |
| 2022-10-21T21:22:34.419+0530 | NONE | -----> ... |
Which paradigm(between OOP and Functional) should be chosen for a given task ? What are the tradeoffs between these two styles ? In which case using Functional makes sense and vice versa,in which case OOP should be used ?
we all know,
OOP:
As the name suggests, when designing a system with object-oriented programming,... |
This question is similar to Permissive vs. Strict API Message validation. One difference is that we're using Protobuf.
A colleague and I are discussing standard message types for names.
One possibility is:
message Name {
string first_name = 1;
string middle_name = 2;
string last_name = 3;
}
Another possibility i... |
I am reading through "Clean Architecture: A Craftsman's Guide to Software Structure and Design" and it says that:
All race conditions, deadlock conditions, and concurrent update problems are due to mutable variables.
Functional programming languages do not allow variables to be mutable. I can see why race conditions an... |
I am creating SCSS for the large project, I decided to use BEM methodology. I will have a lot of containers. I have question about BEM and about best practices.
My current code:
.footer {
&__intro {
margin-bottom: 5em;
}
&__menu {
display: flex;
flex-wrap: wrap;
align-items: ... |
I am dev manager, managing 8 developers. I am facing a problem that the code review becomes more and more a formality even though we all know the code review is important. We do have code review process but when people don't want to do it they can find the way to circumvent it.
I hate to be bossy around, telling my guy... |
I'm trying to add specialized functionality to concrete types without adding the functionality directly to the interface of those concrete types.
Given a vehicle interface with 3 concrete types.
interface Vehicle {}
class Car implements Vehicle {}
class Motorcycle implements Vehicle {}
class Truck implements Vehicle {}... |
I have two different connection strings for two different databases.
My first database has 2 relational tables:
-First table has some default fields,among which average on UI, and some additional fields based on second database that are even displayed in UI and that change based on second database.
-Second table has al... |
This question has always bothered me I am finally ready to ask it out here.
I am creating a hotel reservation app, and I am in the phase of deciding what classes I will have. Among classes such as User, Hotel, and Ticket, I also think whether I should have a HotelList class as well, which would be responsible for holdi... |
I have created a small ERP application and the architecture I chose included the Repository pattern and the anemic Domain model and Business logic layer.
I was reading Microsoft's guide about microservices here:
https://learn.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/net-core... |
When batch deleting a resource. e.g. deleting all Orders that belong to Customer 99:
DELETE /customer/99/order
If there are defined business rules1 that prevent Orders that meet specific criteria from being deleted. Such as:
Orders that were made in the last 7 days can't be deleted.
Given customer 99 has orders tha... |
Consider unit testing for a program written in procedural style. Each unit test tests a single function.
Consider the following example, in which I use C_i(x) for a condition depending on the argument x and S_i for a statement.
def foo(x):
if C_1(x): S_1
if C_2(x): S_2
if C_3(x): S_3
if C_4(x): S_4
Ass... |
There is a blog post by Eric Lippert where he describes how to define variance. In a general sense, covariance is achieved when the direction of assignment compatibility is preserved. Contravariance is achieved when the direction of assignment compatibility is reversed.
Now let's use a C# generic interface as an exampl... |
From Wikipedia:
Attribute-driven design (also called ADD or Attribute-driven design
method) is a methodology to create software architectures that takes
into account the quality attributes of the software.
Why is Attribute driven design, as described in books such as "Designing Software Architectures: A Practical App... |
I need to implement a set of algorithms for data processing. Algorithms do not directly access data, but use a set of basic operations that are placed in a separate class. The following code can be considered as an MWE:
class Data { .. }
class BasicOperations {
void f(Data d) { .. }
void g(Data a, Data b) { .. ... |
Assume I have a simple system with two (simplified) domains in the backend where the Root aggregates are the following, simplified ones:
Product with product_id and description
Warehouse with a warehouse_id, warehouse_name and Map<product_id, amount>
The system is a modular monolith where each domain is a separate, i... |
I am trying to decide on which approach to follow for long running tasks.
Web Client (user) story
Web client connects to the server (REST API + WebSocket for real-time notifications)
Web client POSTs a new resource intensive job request
Server publishes the job on a queue
Task worker consumes the job and processes it.... |
I have found myself in the habit of using code like this.
class glb:
"just for holding globals"
args = None # from argparse
conf = None # from configparser
def main():
...
glb.args = parser.parse_args()
glb.conf = loadconf(fn)
Assuming there is a case for using globals, I feel that this is a... |
I thought I understood Liskov Substitution Principle but then I thought of a case and I wanted to ask the community here if I get it right.
So I read somewhere to check if we have violated Liskov or not, amongst other things, we also need to inspect the client code which is using the classes in question.
So I have an e... |
I have an Entity type, let's say Car for example. There is a Value Object type Tire for it. Each car has a set of tires with certain properties. Sometimes tires are replaced, which is communicated by a Bounded Context via Domain Events. There are some other BCs that record a Read Model of the cars and tires.
Now there ... |
I found the short article Align the happy path to the left edge quite helpful in improving readability of functions. Briefly, reading down the left edge of the function should step you through the logic of the happy path scenario. Errors and special cases are nested in conditionals, or decanted into separate functions.... |
I am currently building a sequence diagram for a website to allow customers to make online bookings for a travel agency. If a customer books a flight, he/she can use an online payment method to pay for the ticket. Here the bank is an external party. So can I use bank as an object?
|
I have an update API (PUT/PATCH) entity/{id} to update a certain entity in my DB. Let's say:
entity {
id: number, // Primary key, unique, not null
content: text,
parentId: number // Foreign key, nullable, points to another entity's Id from the same table
}
When I call this API, if the id doesn't exist in the DB,... |
I'm using flask with SQLAlchemy on a postgresql database for a mobile app I'm building. My application allows a single user to save lets say up to 5 different locations which are saved in the database.
For each of these locations, I'm serving data from a different API and each of these API calls depend on the specific ... |
I see a pattern where the get method from a repository returns an Iterable, even if the list is composed already:
def get() -> Iterable[type]:
my_list = [list]
for x in my_list:
yield x
I'm wondering what are the benefits of this pattern?
|
This is something I have been thinking about a lot recently - why do we still authenticate / connect to databases with usernames and passwords?
Hear me out.
Lets talk about production databases. I think it is a safe assumption to make, that when it comes to production databases, there should never be a situation where ... |
I have a little bit of experience with Go, that I have been trying to use as a reference point to wrap my mind around Rust via a cards game I wrote in Go that I would like to now write in Rust.
I know how I would approach this project with a language like Python or Ruby and of course Go, but I am unclear how I would ap... |
In contrast to bitcoin:
How is double-spending technically prevented in traditional banking? Do database transactions have to conform to the ACID property in order to prevent double-spending?
|
I'm an applied physics student and currently working on a simulation of the magnetic interactions of multiple protons within a protein.
Me having only little experience with programming and almost none with OOP, there is a lot of information for me to process. Especially in terms on how to design my model in a way that... |
I am implementing clean architecture in my new back-end project and getting stuck with a particular use case.
I have a CreatePhysicianUseCase what is responsible for creating a new physician user in my system. I inject my repository into it which has the following methods:
export interface CreatePhysicianRepository {
... |
I'm working on a project that has microservice based architecture.
Recently we started facing problems where a single user requests requires updating multiple microservices each having it's own dedicated database and the response needs be sent to the user only after all the microservices have updates their databases.
I... |
Problem
We have multiple microservices, like Home, Menu & Cart, exposed via Gateway. Each one has API exposed to the app. Now, each API has certain information that is needed by the successive API. Wanted to know the best way to persist this information.
Possible Solution 1
One solution that comes to mind is to give th... |
I built an asset management system (a web application) using C# ASP.NET in MVC structure. My project is built upon the ASP.NET Boilerplate template, which includes 5 layers by default. These layers are:
Core (Data) layer: Entity classes, domain services and some core helper classes.
EntityFramework (ORM) layer: Databa... |
I have the following entity relationship.
A {state: ON | OFF} => B {state: ON | OFF} => C {state: ON | OFF}
So, in this case, B is a child of A, and C is a child of B. Moreover, they all share a property called state that can be either ON or OFF and defaults to OFF.
Domain rules
A child must inherit the state of the p... |
All the examples of Clean Architecture that I see have very simple use cases, such as:
OpenAccountUseCase
DepositMoneyUseCase
However, real world applications have much more complex logic.
Let's say I have a use case which gets the youngest Student on a Course for a given year. I could have:
GetYoungestStudentOnCour... |
For this MS sample code, I have checked Program.cs, Startup.cs, and other config files, don't see how the two parameters sqlQueryService and sqlCommandService are populated. Appreciate if someone can explain.
namespace ProductCatalog.Controllers
{
[Route("api/[controller]")]
public class ProductController : Con... |
I had a debate with a work mate regarding the following code as to which one of it would be the better practice:
My code (in pseudo):
var A = <precondition either TRUE or FALSE>;
var B;
if(A)
{
// some other multi-line, complex computation based on A=TRUE
B = <value fetched from JsonElement .GetProperty("C");>
... |
What does it mean this fish object on the architecture diagram?
|
I am currently implementing a Trunk Based Development workflow utilizing Short Lived Feature Branches in a project I am working on. Recently I have realized my release strategy is less than optimal, and I'm working to move to a Branch For Release, strategy for creating new releases.
Given I am implementing Branch For R... |
I'm trying to learn to create use case diagrams and would appreciate some pointers. The sample problem is to create a use case diagram for a seller in an online magazine selling site, I only have to worry about the 1 actor. Actions include selling a magazine, viewing listed magazines, a secure login, etc. Do the action... |
C# is considered a statically-typed language. However, it contains keywords such as:
var, which infers the type at compile time, and
dynamic, which determines the type at runtime.
Is this a contradiction?
|
I have written a class that implements some BLE scanning functionality. I have also written some test code that helped me to manually verify my scanner works as intended.
Now I want to somehow preserve that test code for future use. But I find myself stumped - how would I do this? I am currently using a unit test metho... |
For my job, I work on multiple different scientific software projects, as well as general administrative tasks that go hand-in-hand with any 'office' job. Thus, any given working week could involve progressing none, or all, of those software projects.
Put simply, my problem is that I waste a lot of time (sometimes days... |
Umbrella Question
In an onion architecture, where do all the components needed to consume an external API fit in?
The following is the architecture I have so far, based off an example found here: https://github.com/CodeMazeBlog/onion-architecture-aspnetcore/
Requirements
I'm now trying to test out this architecture by... |
I'm writing a ray-tracer in C++, and while writing a constructor for the Ray class:
class Ray {
public:
Ray(const glm::vec3& origin, const glm::vec3& direction) : o{origin}, d{direction} {}
private:
...
}
my IDE helpfully put a zigzag line, saying:
This got me thinking, and I decided I wanted to be a little stricter... |
Say I have a feature in a web app where users can create a post and like it. In the frontend the user should see the number of likes a post has.
I could store the data two ways:
1. Option 1: A small table where # of likes is determined from a query
(content: text, liked_by: string[])
2. Option 2: a larger table where... |
I've been working on a personal project for some time, and I believe that I'm at that point where, if I don't embrace unit tests (and ideally TDD) now, it may be too late, so I want to make the right call. I'll try to keep things generic, so that this answer can be useful to as many people as possible.
Something releva... |
I am trying to design my database, where i have to save some response data given from an external api as a webhook.
This api will return me as well “referenceId” as an identifier, which i will use afterwards to relate with already existing record in database.
So, the question is, is it fine to design databased columns ... |
I often write front end apps with a generic MVC pattern. I use javascript but this questions is language independent and relates to OOP as a whole. I struggle to understand the SRP principle and I read many inconsistent content about it.
I am looking for a definitive answer by providing a written example of a problem I... |
So nowadays, creating js & css that works the same across different browsers is less of an issue as to what it was a few years back.
So let's say I have this Vue app that -
Has CSS reset
Include @babel/polyfil
Doesn't care if it works on Internet Explorer or not
Not using any special CSS properties
Edit -
Has browse... |
I've heard people say things like "B can't inherit from A because A is immutable and B is mutable".
My understanding of inheritance in Object-Oriented Programming is that you use it to add behaviors/methods, such as set methods.
interface A {
getX(): X
}
interface B extends A {
setX()
}
You can't remove methods... |
I'm building a web application using Laravel. I use the repository pattern as my data layer.
Imagine there's some entity like Product and a product can be assigned to a ProductCategory.
The Product has a field named category_id and that field either contains the id of a product category, or null if the product doesn't ... |
What is correct in your opinion regarding the creation and handling of models in an application let's say using MVVM, or even an MVC design pattern?
I will try to illustrate the situation I see at my company in an iOS Application,
We have a couple of tabs in our application and for each tab we create the models needed... |
I have a project in which I'm the sole contributor, there isn't a stable API yet and I'm constantly refactoring code, but I still try to denote breaking changes whenever they do happen. Recently however, the repository for this project has attracted some interest and I decided to establish some conventions to make it e... |
Long story short: I would like to create a plugin system for my microservice architectured app. so we can allow our customers to install their plugins. (something like a plugin system on wordpress|...)
Each plugin:
Receives pre/post hooks for every operation from our microservices (e.g., productWillBeCreated(),product... |
I read some very interesting discussions about decoupling microservices on this forum. One of the approaches is to ensure each service holds (parts of) the data of another context to allow it to operate without having a dependency on other services (e.g. REST call to other services).
Where does one draw the line while ... |
The following figure comes from https://spring.io/guides/topicals/spring-security-architecture
I refer to it as a "figure" rather than a "diagram" as I'm not sure if it is.
the doc/guide says
Often, each of those is a ProviderManager, and they share a parent.
which seems to indicate the 3 blue rectangles labeled Pro... |
I have an Micro-services where we get the event messages from a Kafka messaging system. The event message contains the orders information, quantity, the mode of package and delivery location. At a predetermined time, these events are pushed to the Kafka stream. A special event full delivery event is issued to signify ... |
For a frontend web app version 3.9, we have a visual change that I would constitute as a backwards compatible (as far as the API) new feature. Therefor, my SemVer instinct is to bump the minor version number.
But how do I do that when we're at 3.9?
|
I wrote a java call graph generator with tree sitter (the 3rd-party library in question)'s python binding. I am doing a thought experiment on how I might model the same application in Haskell. I am asking for help on designing the architecutre in Haskell. I have put forth a hypothesis, but if there's a better way in a ... |
I'm writing a code that extracts information about functions (prototype) and types (enum, struct, typedef) from a C source file.
This is to augment the type information about a particular function or type in my documentation.
Basically, I don't want to manually specify type information because that information can alre... |
There are many questions and responses on database triggers, however I have not found any that touch on network performance specifically, in the matter of benefits (or otherwise) of triggers.
I have this case:
Table A has rows that are data heavy (1-2 KB of JSON data). When one of the fields (status) is updated, the en... |
At my company we are revising some backend architecture. I think I have identified a use case where event streaming (for example with Apache Kafka or RabbitMQ) makes sense.
Because me (and everyone else- at my company) are pretty much noobs in that space, I'd like to validate my idea.
Business flow and prerequisites
We... |
In my company we hire engineers for various "disciplines"—iOS, Android, Web, Backend, Data, etc. Engineers follow an onboarding workbook to install what they need for their discipline. iOS engineers need to install Xcode, backend engineers need to install IntelliJ IDEA, etc. And some things are common to all discipline... |
Question inspired by a similar question in Academia.SE: Is it OK to generate parts of a research paper using a large language model such as ChatGPT?
I've always been very sceptical about AI code generation tools. My thinking is as follows:
Such tools are known to sometimes output incorrect code. Sometimes the flaws ar... |
We have a system built on microservices with 50-100 different services. Previously most servcie-to-service communication was done with direct REST API calls, but we are shifting to a event based architecture (for this question I have simplified the setup a bit)
My question is related to how to model the events between ... |
I have read many articles about repository pattern and service layer but I have still some doubts in certain arguments:
Repository should return only aggregates and I should have repositories only for aggregates and not entities, for example Product and not ProductDetails. If I would to retrieve only some properties f... |
I'm trying to make a simple Blog-application, but I'm a bit stuck on the architecture of the application.
I'd like to create a details-page with the content of the blog-post and a form for adding comment to the post.
My code looks like the following:
ViewModel
public class PostDetailsViewModel
{
[ValidateNever]
... |
I'm a huge believer in the value of Intellisense for showing you what syntax is expected and allowed (and also saving typing, though this is a secondary consideration).
When you build a web component (or use JSX or tagged templates or the like), you have code like this:
class MyElement extends HTMLElement
{
constru... |
I'm new to DDD and I trying to create an API using DDD concepts for study purposes. Today, I faced a scenario where I've to create an Application Service to expose a functionality to be cosumed from the external world. The scenario that I came across is to consult in the repository some Domain Entity informations by it... |
I am making a game of monopoly. Inside my game I have a Board class. The Board class has an array which contains 40 squares. Each square is a different class e.g. ChanceSquare, PropertySquare FineSquare.
Now inside the board class I want to do various things. Check three separate squares to see if they have the same ow... |
I'm looking for the optimised approach of designing MongoDB database collections where there are three stakeholders-
A User (who accesses a portal).
An Organization (which can have multiple Projects).
A Project (which will be inside a single Organization).
A user can be added either to an Organization, which will giv... |
The traditional (Scheme, Pascal) way to structure code is this:
declare outer function
declare inner function
body of inner function
body of outer function
The where clause in Haskell moves the inner function from the beginning to the end.
declare outer function
body outer function
where
declare inner ... |
I like programming in such a way that every component/injectable of the applications I build, has a clearly defined scope, and it's easily tested.
With years working as a Developer I've come to ensure every component I declare and implement fits one of the following categories:
Technical components: those behind the s... |
This question has probably been discussed to death, but I don't feel like I have a good answer. I work at a company where customers are on different versions of our product. When a bug is found, we determine what was the oldest release of the system that was impacted. Developers then checkout the appropriate branch for... |
We develop a SaaS solution that processes customer ERP data and provides analyses from it in a front-end. The software is a standard solution and should require as little customization as possible for the respective customer. Unfortunately, the ERP data is business-critical data (not legal protected data e.g. personal ... |
I own a laptop and a desktop. The desktop better for training neural networks, but I don't have physical access to it. The laptop is better for day-to-day work on the neural networks. Right now, my workflow is:
Make an edit on my laptop (for example, changing the value of one parameter)
Commit changes
Push to github
S... |
At some organizations I'm seeing a trend where if a bug is reported, engineers will directly rewrite the offending code without knowing the root cause. In general this will fix the bug, but in my opinion it also introduces the risk of new bugs - and it doesn't allow a team to learn collectively from the mistake that ca... |
For one of my current projects, written in Python, we would like to have two different versions: One for internal use, with all features enabled, and one for external use, with limited features. The current external and internal deployment method is to directly pull from git master whenever there are updates.
My initia... |
I have a simple 2D game which has squares, player (teal) and enemies (red).
class Game {
List<List<Square>> map;
Player player;
List<Enemy> enemies; ...
My problem is that I don't know what would be the best way to store the coordinates (int x, int y) of the enemies. Currently each enemy contains their coordina... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.