instruction stringlengths 34 36.1k |
|---|
I am currently building a C# application that gets JSON data then it calculates something then stores the results in a database, what is the proper way to design the application.
This is how it's now
I have a static class that gets and parses the JSON, then stores it in an object and all objects are then stored in an ... |
I need to rewrite my project due to many underlying issues causing errors and I started following clean architecture by Uncle Bob (I read the book).
I created my domain, infrastructure, application and interface-adapters. In my domain directory I have an entity called TreatmentPlan containing all the business logic. I ... |
I have this:
Class Order
{
long ID;
...
}
Class Item
{
long Id;
IdProduct;
decimal Amount;
...
}
Perhaps I misunderstood what means bidirectional relation in DDD, because I have read that if it is possible, it is better to have only navigation from parent to child, and not from child to parent... |
I developed a big(ger) project, which is in use already and grows, gets altered, fixed, etc. every week.
Until now I am the only developer. Since the team has to grow, also we will be more developers on that project.
The code is mostly self-speaking or commented on the darker places ...
But I guess an experienced devel... |
Suppose you have a ERM containing about 40 Classes / Entities. Most of them in quantified relations to others, some of them as standing there alone.
How to deal with a very often used relation/attribute called image of type Image?
I am afraid, because I have so many entities that own an Image the diagram will be clutte... |
From the answer to Must the use cases extend the entities in Clean Architecture? I have known that the use cases must NOT extend the entities. It's fine, but what do I have to do with the properties of entities which are depending on the application?
Very strictly speaking, these rules (note: the enterprise business r... |
I'm trying to make sense of how to handle events in my server in a neat way.
I'm creating a Whatsapp chatbot that receives messages via webhooks at a certain endpoint on my server. It doesn't seem right to me to handle all logic at that endpoint, so what I'm thinking of doing is passing the data to another endpoint (so... |
I understand that credential leakage occurs reasonably often due to people forgetting to .gitignore a .env file
I'm building an application in VueJS and right now I'm storing some S3 credentials as environment variables in order to retrieve and access some data in the site.
Is there any way that this can expose credent... |
I'm looking for specific software design patterns that can help me understand how versioning of the same entity where the domain logic has changed between the versions, can be solved. The following example illustrates a use case for this problem.
Let's say we have the first version of a form that users are required to ... |
I'm currently developing a chatbot that will be used for booking trips. The particular party I'm interested in for now is the rider. I'm using AWS's DynamoDB, because it seemed to be the most flexible and fast for a system like this that is likely to get lots of concurrent traffic, and in which records won't have well-... |
As implied by the title of the Q, I have a few entities and need to keep them as constant objects in a C++ project. Each entity contains very complex data structures (lists of enums, maps of maps, etc.). In addition, it is possible in future to have more entities for extending the project.
For keeping the complex data ... |
Let me clarify on a bit of an abstract question.
I'm about to develop an app, through which users can capture and store images. Commercially, the main cost here that springs to mind is storage cost.
There are platforms (e.g. facebook, dropbox, instagram) that may expose an API to allow consumers to upload images.
Which... |
I am working on an android application with Bluetooth iot devices. Theses devices sends broadcasts periodically in the form of 30ish bytes containing various information.
Some of the bytes have specific values akin to enums or flags and some have fixed values like the product type which is always the same.
For now I ha... |
I am currently working on a web product where we have a testing strategy that includes end-to-end testing.
Our tech lead is of the opinion that each e2e test should only validate a single feature. For example, we would have a test for creating an account, a separate test for logging in and an other separate test for up... |
I just started as a junior business analyst and working on defining the requirement for an already existing system, so I am gathering the requirements for a just added service.
One of the requirements is that an invoice file should be able to be downloaded as a csv and xml, and not only as a excel file. I have a hard ... |
We are using a client library over Memcache.
This library has a lot of logic for Memcache client and is indispensable in current form.
One of the API of the library is put which internally just uses an async mechanism to write to Memcache. There is no way to know if the put actually went through.
Changing the library i... |
A lot of sites will save the progress of the creation of an entity or some process. For example, stackoverflow will allow you to draft a question before you post it. If StackOverflow used DDD, I would assume that the Question entity would only be valid if it had 1) a body and 2) a title. So there must be some precursor... |
I came across a class that implements a kind of "strategy pattern" with a concrete implementation defined inside the main class as a template method.
#include <iostream>
struct ObjA {
int a = 123;
};
struct ObjB {
int b = 456;
};
class Algo {
public:
void stratA(const ObjA& obj) {
strat<ObjA>(obj... |
I have nearly 300 devices interconnected in the local ipv4 network and would like to discover each other somehow. At the moment, I'm using mdns announce to achieve this (using avahi lib). This solution works up to 50 devices, but it goes more than 100 I started to face some flooding of avahi announce messages in the ne... |
I have an intuition, that I'd like to read what others have talked about. To me, it seems fairly intuitive that when you have a function which is called multiple times with the same arguments, it would be better to create an abstraction which doesn't require arguments, to avoid duplication. So for example, if I have:
g... |
In DDD, the model has to implement only the bussiness logic, and it has not the responsability about another things, like persistance.
So I was thinking that perhaps is in the application layer a good place, because it is the layer who get data from the database with the repository, call the methods of the domain and p... |
I have an interface that looks like this:
public interface IInterface<T> where T : IParameterType
{
void InterfaceMethod(T param);
}
And a lot of implementations of this interface, each with a different derived type for T.
I can't change the interface.
Now I want all the implementations to call a common line of co... |
Are there any formal techniques/tools/approaches to software defect investigation?
For context, I'm looking at ways to approach intermittent failure in large distributed systems with many variables to consider.
|
On windows, I have done one client in c++ and one server in python. In order to make the program work, I need first to run the server (in one terminal), and then I can run the client.
I am trying to deploy the project and create an installer out of the process. The thing is that I don't know how to run the server alway... |
In PHP, there are several ways to check whether a value is true, or similar:
true === $v, only works for bool
true == $v || !!$v, works with int and string, but a non empty array can also be considered true
1 == $v, works with bool, int, string and always false with arrays
Personally, I feel partial to 3. Especially ... |
Are stacks and queues allowed to be iterated over, conceptually?
It “feels wrong” for some reason but I can't come up with a reason why it would be bad to see through the whole thing that's stacked/queued. Obviously no taking the element out of there, or inserting a new one somewhere in-between.
Are my senses off or is... |
So the gist is to have a static global variable that can be modified by different executables. For example I have 2 different source files including the same dll.h:
dll.h
#include <iostream>
int globalCounter = 0;
__declspec(dllexport) void incrementCounter() {
globalCounter++;
std::cout << globalCounter << '... |
I've been reading about the IEEE 754 standard, but can't understand how or why they chose those exact number of bits for the exponent and mantissa. For example, why 8 bits for the exponent and not 7 or 9 for the single precision? Similarly, why 11 for the double precision? Is there a formula you can use to come to this... |
I am working on a project which does not have solid requirements, All is we have meetings with all the teams across and confluence pages. No one owns any requirements and it just float around scattered info and it is confusing and the meetings go no where and management does not care about this chaos. How a software pr... |
In my research, I have found two conflicting definitions of 'availability' as it relates to software engineering and architecture. According to [1]:
"The availability of a system can be calculated as the probability that it will provide the specified services within required bounds over a specified time interval. When ... |
I am working on a project on my own and I am using git just to keep track and to get used to a team environment. When should I commit on the main branch (if I should at all), do I need to create a branch for each feature, bug, etc., and then merge them to main or could smaller things (adding one field to get stored in ... |
I am working on a compilers assignment in OCaml, and the following is an example of the pre-written code in said assignment:
(* Build a CFG and collection of global variable definitions from a stream *)
let cfg_of_stream (code:stream) : Ll.cfg * (Ll.gid * Ll.gdecl) list =
let gs, einsns, insns, term_opt, blks = Li... |
I have the following domain specs:
A historic read only list of items that were published and a currently published item (if any) and an optional draft item (if any).
I thought of the following design:
Publicly accessible:
GET /items
# Returns list of items excluding optional draft
GET /item/published
# returns curr... |
Context : I am currently task with building a software to support operators in a manufacturing plant. Due to the nature of the plant, the computers all have fairly weak processing power (given that they can't have any fans and the environment is already hot to begin with). The current "client" is in WinForms and there'... |
I wrote some script in Python that creates a giant 2D matrix (1000x1000 or bigger) and fills it with random numbers. And after that, it goes through every element of the matrix and changes the number to another one depending on the current element's neighbours (something like you do in Game Of Life).
And I noticed that... |
I was reading some examples how to handle concurrency in DDD. One example is in this repository: https://github.com/kgrzybek/efcore-concurrency-handling/tree/master/src/OptimisticConcurrency/DDD.EF.OptimisticConcurrency
And the code in which is increased the version is this:
public async Task<IActionResult> AddOrderLin... |
Here's what I want to achieve:
while complex_compound_condition_statement:
foobar() # ... do some stuff
I would like the log output of the above to be:
<timestamp> INFO: started doing stuff on condition Abc
<timestamp> INFO: condition Abc no longer active
To achieve the above using straight control flow, the curr... |
Some of the checks I make to validate http requests involve making a call to an external service to parse part of the request body. These calls can fail because of network connectivity issues. My feeling is that I should return a 5xx error to indicate that the client may want to try again later.
However, what do I do... |
Something that annoys me when reading about decoupling microservices is that the problem is often stated, with either poorly explained, bad, or no solutions provided, which seems to especially be the case with synchronous communication.
Take this basic example of a customer and orders microservice:
The customer servic... |
I've inherited a system with an Oracle relational database with a couple of tables modeled like I've sketched below, where there's an entire child table that only stores a single status code in a one-to-one relationship with its parent.
Here's a generalized sketch of the schema I'm talking about:
The ITEM table is qui... |
I have the following classes in my system (python):
class Metric(ABC):
def compute(self): -> float
class Visualization(ABC)
def visualize(self)
class FirstMetric(Metric)
def __init__(self, data1):
def compute(self): -> float
class FirstVisualization(Visualization)
def __init__(self, plot_param1, data1... |
We have a legacy API service and database at my workplace.
My team works on a mobile app that uses this API for some particular data. You can think of this as DDD - our service shares some entities with the legacy API service.
Besides using the legacy API, we also use a dedicated API and database for the mobile app's s... |
While building microservice-based architecture I came across a dilemma on how to approach company level permissions for given range (or ids) of resources, i.e. allowing certain users to access subset of data for the company that the person is working at.
I have number of services, Invoices, Company, Orders etc.
Each se... |
When working with functions that run a few short "procedures" in sequence that are not used anywhere else and it makes sense to keep it all inline, in a single function, a large part of the code often ends up being separated into pairs of variable declarations, and then certain blocks where said variables are properly ... |
If we program to interfaces various parts of the implementation can be effectively hidden. We can define multiple interfaces for a single implementation and use them as needed, instead of 4 fixed levels (public, protected, package protected, private).
From this point of view Access modifiers seems redundant and limite... |
We're looking for a scalable way to implement a file browser feature backed by a robust object storage system for the files. We were looking at an S3 compatible service, such as MinIO for this. Since these files will be accessed by other features as well, we thought of giving these objects immutable unique ids, indepen... |
Should a service making a request send all the information another service requires from the requesting service to complete the requested service's job? Or should the requesting service send as little information as possible when making a request and let requesting service decide what additional information to call bac... |
I want to assign Python variables imported from a JSON file. This question had an interesting answer using a classmethod, but I couldn't get it to work and I'm not allowed to comment...
So, let's consider a really simple example: I want to evaluate z = x^2+y^2 but I want to be able to define x and y in a JSON file. My ... |
REST APIS are a Uniform interface.
Is it better to add functionality to the search parameters of a GET request with a query parameter, than to add nested resource identifiers to a collection /exists or /exists/type.
Must resource identifiers have database entities unlike /exists or can they return results from domain e... |
Say that you have a monitoring application that reports downtimes for a large number of remote systems (think IOT). A monitoring daemon polls the remote system and reports that status (on/off) via an event stream to an event processor. The aim of the event processor is to determine when and for how long the system was ... |
I want to store and analyze university course requirements. Lets say, students to register for ABC123 course following requirements should satisfy.
Must pass CBA321
Should be taken with XYZ123
Must complete EFG456
Should have passed 20 credits.
Here I have hundreds of course and similar requirements. My questions are... |
I'm not sure if my answers to the following exercise is correct:
Suppose the program is run with two threads. Further suppose that the
following sequence of events occurs:
Time Thread 0 Thread 1
0 pthread_mutex_lock(&mut0) pthread_mutex_lock(&mut1)
1 pthread_mutex_lock(&mut1) pthread... |
I'm going to write a blog app for myself, and though I've written authentication for multiple users. It seems heavy handed to use the same kind of architecture for one user.
The only alternatives to having a table/document with one user (myself) for auth would be an environment variable to check. However, I'm not sure ... |
I have this order:
class Order
{
long Id;
string Concept;
string Comments;
//another properties
UpdateConcept(string paramConcept) {...}
UpdateComments(string paramComments) {...}
}
In the domain entity, I have to have one method for each property that I can update.
But my doubt is in the applic... |
I am creating a simple P2P file sharing system, where one peer can send some Objects (e.g., String, custom objects, etc...) to another peer.
The peer, that receives the Object, can then manipulate it, extract information from it and store it.
To receive and send objects, the classes Sender and Receiver are used, and th... |
Recently I was trying to use PHP's array_udiff() function to compare a value in a multi-dimensional array with a plain old string value. I tried something like this:
// E.g. $employees[0]["name"] = "Jeff";
// $currentEmployeeName = "Steve";
// This won't work because $a doesn't always correspond to $employees
arr... |
I have a multiple same tables (14 for now), with a only foreignKey column difference. Some of them are:
DatasetGraphTable
+-------------------------+----------------------+--------------------+
| datasetID | parameterID | value |
+-------------------------+----------------------+-... |
Suppose you need to design a drawing program that relies on a geometric kernel library.
Inside the geometric kernel library, you have the definition of Line, Circle, Ellipse classes with all the geometrical data (position, radius) and functions (area, perimeter, tangentAt).
The actual program should extend these geomet... |
I know there are already questions about file structure in MVVM but I haven't found the pros and cons for the following two structures. What would be better for a large-scale project, and why choose one over the other?
For example: In the first example both modules are dependent on projects from 'Core' and it would be ... |
I'm interested to build a VR app which will allow the user to interact with some 2d screens in a 3d world.
I would like these same 2d screens to be available on a mobile app, so that the user could use them either from their iPad, or inside the VR too.
My first thought was to create the ui in flutter and build the apps... |
With C# 9 and the introduction of record a lot of boiler plate code was remove from pure data objects. And after watching a dotnet community video on YouTube where then "joked" about it's time to have more than one record in each file it made me think.
I have a bunch of records that are basically data bearers in API co... |
As all articles say the Virtual DOM is lightweight and allows us to update only those nodes that has to be updated, unlike the real DOM that updates the whole nodes structure.
So the first question: how is Virtual DOM lightweight? Since it can't affect the nodes structure I assume VDOM does not have some methods that t... |
Context
Suppose there is a e-commerce microservice architecture with the format:
In summary, a client will contact the Auth Service / Identity Service to receive a token. It passes the token to the API gateway, which verifies the token, and forwards the request.
That being said, there are services that need to be acce... |
It's common to implement optimistic concurrency control in DynamoDB by giving each item in the database a top-level "version" attribute and only allowing an update of an item to succeed if the current version matches the expected version (see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapp... |
I have a question.
I want to add 'period' in the database. A period would always be 1 month. How Would I be able to make calculations with the period?
For example I want to calculate the following:
A = Last day of Current Period - Last day of Previous Period
How would I be able to make the system understand what the l... |
Good afternoon.
My situation is this:
I have to call an external API to create some data and store it there, but I want to have a summary of that data in my own database. I have my use case that creates the AggregateRoot and my port interface that the implementation calls the external API. Where should I put the databa... |
I have a python/php background and just about to start work on a NodeJS project which is why I have this question. I have worked a bit on frontend JS but this is the first time I will be using JS for some backend work...I fully understand and appreciate the asynchronous nature of JS when it comes to frontend developmen... |
I'm building a web app that will integrate with the Etsy REST API and persist information in a database for things like order information, listings, etc. Essentially a panel to manage Etsy orders and products. What I am currently stuck on is how I should architect the backend API.
Currently, my backend is structured in... |
Question
What is a good storage layer, coding paradigm, and query language for computing over realtime data?
Use-case
For example, stock and options prices are (essentially) realtime data streams. I want to load that data into my storage layer every N ms, compute a set of strategies from the data, and surface strategi... |
I've written a web scraper and would like it to run as quickly as possible. The scraping isn't trivial; I scrape a few web-pages, gather links from them, scrape those, then gather links from those, then scrape those again (illustrated by the three different functions, showing the process to be multi-level). Since stand... |
Imagine the follow basic (abstract) setup:
1 API Gateway -> GWAY
2 Auth service (i.e. keycloak) -> AS
2 Location microservice(s) -> LMS
3 Activity microservice(s) -> AMS
Every microservice would have its own database and is subscribed to a topic to consume events of interest.
The LMS manages the user location read & w... |
I am finding the minimum value being input from stdin. For example,
1
5
3
2
-6
7
should return -6 to stdout.
My question is if it is a better practice to initialize my minimum value to INT_MAX or to the first scanf call.
#include <stdio.h>
#include <limits.h>
int main() {
int min = INT_MAX;
int input;
wh... |
I have a system that uses event sourcing.
https://laravel.com/docs/5.8/authentication#remembering-users
I'm trying to replicate the functions of the basic Laravel authentication. However with event sourcing the remember me token seems a little strange to add the event stream.
In the normal functionality its stored in t... |
Given the following design from clean architecture in which layer would you put overall application state?
In each state a subset of use cases are allowed to be invoked. For example if application is in "Updating" state invoking AddNewParameterUseCase is not allowed.
|
I recently finished developing a piece of software in python where learning models and data processing procedures are contained within different class objects that succeed to each others (modules). As I'm new to standard practices in software development, I would like to know the followings:
Should I apply unittests t... |
We are planning a complete rewrite of a very complex project (10+ years, ~15 different application modules) and we would like to adhere to DDD and CQRS as much as possible but we are struggling to fit our needs.
The context
The app is a data-analysis tool that basically stores data and allows the user to configure cust... |
Suppose I have a DB schema with two tables, a Student table and a Subject table. The relationship between these is many-to-many, so I also have a StudentSubject join table.
Now suppose that, periodically, there is a new subject and all students must be enrolled into this subject. Is there any sort of clever insert patt... |
I am working on re-platforming and migrating to microservice from an old monolithic application.
But I need a way to measure the success and progress of the project.
The things I thought about are:
Measure the amount of code being deleted in the monolith
Measure the number of calls that go to the old system vs to the ... |
I'm creating a time registration application for employees where they can register their hours.
I want to show the users their "norm" (not sure if this is an actual word or just made up by my company). The norm is basically the number of hours someone has to work in a week.
For each week in a year, I have to show this ... |
I'm currently working with a group of developers (as outside contractors) on an existing codebase (in kotlin) and the lead dev (the client) is blocking merging of pull requests (GitHub) because methods and variables in any given Kotlin class are not "alphabetized".
Only some of the classes are currently alphabetized in... |
Let's consider an entrepreneur decides to create a new company like Airbnb, Netflix, etc. The problem is about the software part. He doesn't know how long it takes to create the mobile/web app? How many frontend developers, backend developers, devops engineers, graphic designers, etc. are needed to be hired and work on... |
class Product...
public static Product newWordProcessor(String name) {
return new Product(name, new CompleteRecognitionStrategy());
}
Martin Fowler presents this code in his book "Patterns of Enterprise Application Architecture" on page 122. Does this work in the real world? When is Product constructed? Where is thi... |
I am working on a C++ application which lets users work on projects.
Each project consists of several files that should not be known / edited manually by the user.
For that we currently use a folder structure to store the settings, the files created by the user in the app and some automatically generated files.
We woul... |
I have thought of this for a while and I want to know what you think about this.
This is more of a way to structure the code that might not be 100% object oriented and that is not the purpose. I would like to divide the code into Data, UseCases and HelperMethods
Data should be more clean (or "anemic", if you will) obj... |
I have a service that use a worker to run a periodic task.
I will not use a concrete language because it is a generic question, so I will expose the general idea.
MainProgram
{
Worker.Start();
wait worker;
}
Worker
{
Execute(cancelationToken)
{
try
{
while(!CanelationToken... |
I have a static class in my code that has two methods that store different data in a SQL database when they are called. In each of the methods I open a connection to the database. Is this the proper way to do it or is there a better way to do it?
My Code
using System.Data.SqlClient;
namespace Asm
{
internal static... |
Why would so many repositories use additional — apparently unnecessary — vertical and horizontal space in coding styles?
I almost unanimously see this:
public function getName() {
return 'webauthn';
}
public function newKey( array $data = [] ) {
if ( empty( $data ) ) {
... |
I've made an endpoint for creating events: POST /events/new
The request should have JSON data on the body. This is the JSON structure that is required for creating a new event:
{
"label": "my first event",
"description": "lorem ipsum dolor sit amet",
"meta": {
"status": "draft",
"isOnline": ... |
I arrived in a project and they have 2 instances of a microservice. Each instance running in a 16gb RAM + 4 CPU setup in AWS (using Kubernetes), horizontally scalling up to 4 - 6 instances at peak days, but normally, 2 instances are enough to deal with the throughput at most times.
I didn't saw any problem with this se... |
By definition, a pure function is deterministic + no side effect.
Is there any example for a function which has no side effects, but is non-deterministic? I.e., a function without side effects, but not pure.
To me non-deterministic function comes from randomness. But random generator has side effect. AFAIK random gener... |
I've to store a static pdf with an user guide of my application.
I'm using Spring boot and Angular 12, what is the best way to store it?
Put the file on resource folder of Spring boot?
Put the file on asset folder of Angular? (I'm not so skilled in
Angular, I don't really know if this is a valid option).
Create a bran... |
Imagine there is a stream of requests for about 500 types of work. There can be say 5 workers in parallel. One type of work should be executed by at most one worker at the same time. The requests for a specific type of work should thus be done sequentially. So further requests for that active type of work should be enq... |
I'm working on my first big system design project at work for the first time in my career. In the past, while i've worked on large systems, I was always working with someone else, so I wasn't really responsible for design, I just understood the choices the made and pointed out potential upsides/downsides on specific th... |
TLDR:
I am trying to
validate a Azure AD B2C access token in my Flask web API
use scopes from that access token to authorize calling protected resources
use timely and secure solutions such as PKCE for OAuth 2.0.
what already works:
[ client app ] -- authenticate & get access token for api --> [ Azure AD B2C ] OK
[ c... |
Here's a ubiquitous data structure in, say, game and UX programming:
there're a fixed number of items (say, "5")
they're all "zero" to begin with
you can put one in on the "left" (FWIW I usually call it something like shove to distinguish from the usual meaning of push)
once there are 5, each time you put a new one in... |
All guides and blog posts that I have read about dependency injection use a simple example where one object A depends on one object B. They apply DI by creating object B somewhere else and passing it to A via a setter/constructor, instead of having object A create and maintain object B directly.
Such examples, however,... |
I am going to type out my problem in terms of my domain use case;
When an Operator has an Ingest with a valid Dataset (Lowside, Drive and EntryPoints selected), they will opt to then Scan the Ingest. The Scan will run over all the EntryPoints in the Ingests Dataset. A series of antivirus and content scans will occur - ... |
I have a python script that is supposed to be used as a small cli program.
This is google's recommendations on how to document cli syntax. I was wondering, are there similar recommendations, or specifications, perhaps from GNU?
|
UserA and UserB are signing up for some joint service together. They both have to independently agree to T&Cs before sign-up is complete. Once complete they both receive an email to sign-in.
A 1 or 0 is being stored in a MySQL table (TC_ACCEPTANCE) to indicate T&C agreement for each user (USER_A_ACCEPTED and USER_B_ACC... |
I interessted in the "usecases" and "how they interacts with the "context" at "clean architecture".
If I understand right, there will be two contexts.
First is the context of the domain-model with instances of the intelligent domain-entity-classes, which are includes all the buisness/domain-logic (e.g."Client")
Secon... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.