instruction stringlengths 34 36.1k |
|---|
As I learned from the DDD rules, you have to change the entity through the aggregate root.
However let's say we have a value object "Address".
Is it allowed to do in the AR:
(I've seen this in the eShopOnContainers by Microsoft
public void SetAddress(Address address) {}
Or do we have to do it like this in the AR:
publ... |
We are looking to develop an asynchronous server in C++. We are coming from C#, which has built-in support for async-await networking. However, with C++ it appears as if it is basically mandatory to use ASIO, other you're out of luck.
I am wondering if there is are any other options besides ASIO if we want to make an a... |
I'm building a service to send push notifications to the user.
At first, I designed an Interface for the push notification adapters, something like this:
interface PushNotificationAdapterInterface
{
/**
* @throws NotificationException
*/
function sendNotification(string $appIdentifier, PushNotificatio... |
A while ago Herb Sutter wrote The Free Lunch Is Over: A Fundamental Turn Toward Concurrency in Software which I basically interpret to mean that, in order to improve performance, software engineers are going to have to embrace concurrent, specifically multi-threaded programs.
When I first read the article I thought I w... |
I'm developing an API with ASP.NET, but I'm having some questions about the best way I should develop the controller layer for the products.
I'm having these questions because each product will have its own service and its own purchase path, so product1 might have a step 1, step 2 and step 3 to buy and product2 might h... |
I'm in the planning stages of a project involving communication between users in the browser environment and numerous devices running in a widely distributed manner. The end goal is that users using the web application will be able to send commands to the devices, the devices will receive and act upon these commands, a... |
So the recommendations for using GET vs POST in a REST API that I've read on stack overflow are geared almost exclusively toward CRUD operations involving a database.
However if you are simply writing the API to expose a machine learning model to serve predictions, most of the examples I've seen online use POST request... |
I'm working on a CSS library that includes hundreds of selectors and rules for quick templating instead of writing regular CSS.
This is used as a replacement of attr() CSS function until it works for any rule and not just content:.
At first I generated a minified CSS file to load. But as there are many loops for each p... |
Let's say there is a database that persists transaction data , e.g transaction items list of sale invoices , in raw format. Something like this
InvoceId
Item
Price
1
Product-1
2.8592
1
Product-2
10.7559
1
Product-3
5.25
Data is exposed to other backend and frontend services by an API , let's call it AP... |
Suppose I'm the first person write a proper Doxygen comment for a source file. Suppose also that there have been multiple contributors to the file - original author, previous maintainers, current maintainers, people who contributed a function, or just a minor one-liner bug fix.
What's an appropriate way to list them (u... |
I am working on a Spring Boot web application. The REST APIs are secured by JWT tokens. Currently I have only access token generated (not implemented refresh token concept).
My question is related to login/logout of users in this scenario. Most of the blogs suggest that on logout, maintain a list of blacklisted tokens ... |
I want to model a machine with a class machine. By the way the architecture of the project has been built, the module that defines each machine is its own directory.
So in directory manufacturer/machine_111/ there is a file machine.py
Class Machine(ModelX):
def __init__(self):
....
def do_something(self)... |
I have a base class called FieldBase and I want to inherit from it to have different types like TextField and NumberField. I have a property Called Value which for the TextField is String and for the NumberField is Integer. Now I want to access the Value property in the base class and do some checks, but I cannot becau... |
I am going through this OO design course: https://www.coursera.org/learn/object-oriented-design/home/welcome and starting to look at the use of CRC cards. (class responsibility collaborators).
I wanted to apply this to one of my own projects to get some experience using the technique. I have previously written a sql... |
I am looking for best answer to I think typical issue when, there is a frontend calling backend ( some api gateway ) and that gateway needs to get information from microservice A ( ie: its GET request ), but that microservice needs also to call other microservice B.
It can lag of course.
IMO its bad architecture desig... |
I am working on a project where the architect decided to put an ESB (integration layer) between the Front end and back end. The driver was to make the services reusable across channels and the enterprise and to utilize the existing infrastructure (ESB).
This was really achieved for a small set of the services where the... |
As the title says, I've been noticing this trend that have been all along the evolution of programming languages. Each one has had a niche build tool and a dedicated package/lib repository system.
Its hard for me to ignore that nearly all of them are:
Downloading/uploading archives with certain files and metadata.
Ext... |
I think it's fair to say that they are quite similar to each other.
The only difference that I know is the intent.
Chain of Responsibility: Avoid coupling between the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along... |
The intended effect (semantics) of the POST method is resource specific, e.g. executing a command with arguments:
POST /command HTTP/1.1
{"parameter-1": "argument-1", "parameter-2": "argument-2"}
The intended effect (semantics) of the PUT method is to create or replace the state of the target resource with the state ... |
While this might seem more like a piece of an easy task to others, it's honestly not easy for me. At this stage, I find myself wandering how best to version my functions/methods.
What does this mean?
I have a function that does one thing and one thing alone. It saves Contacts to a local DB e.g RealmDb. This function is... |
I have an Use Case that has an UseCaseInput (which is a parameter object of the use case) and an UseCaseOutput which is the output object, the UseCaseInput has lots of parameters in which will be used in various dependencies as parameters (repositories, adapters, etc), some Entities are going to be persisted in the dat... |
In some recent projects, I found myself having some longer spike phases in which I build many cheap prototypes and explore different design decisions, long before I would consider my code of acceptable quality.
Usually, when I check in my code into git or any other VCS, I refactor and clean it at the same time, so that... |
We have two application A and B that I'm refactoring. They both use the same database. Those application are written using the Symfony framework and Doctrine as database layer.
I've moved some of the business logic from A into a library in the same git repository and tried to decouple it from the application. This libr... |
I have a service, call it serviceA, which has a relational database. This service is old and bloated, modifications to the code are very difficult. But I also can't get rid of it, it's the heart of the system. Now I want to build serviceB. ServiceB is basically an extension of serviceA's capabilities, it has exactly th... |
What are your thoughts on having a service/process be both an API server and a background worker, consuming messages off a queue like SQS?
I have typically kept these two separate to keep single responsibilities for each, but also it seems weird, at least in NodeJS, to have an API server bootstrap itself to be an API s... |
When working with big architecture, I experienced high costs when it comes to changes of a data model that is used in multiple applications, servers, databases.
So I thought about designing a server with a database, whose only job is to manage schemas of a data model.
Its features should broadly and mainly be CRUD on S... |
Context: Currently designing a product with a DDD mindset. Currently in a monolithic approach. However I'm refactoring a few things so I can change to a more loosely coupled monolith.
We have an entity called "Risk" (which is an abstract class with N subtypes). Currently have two aggregate roots who have a list of risk... |
Given a method that is widely used and has a void return type:
from somepackage import download_model
from somepackage import get_filename
def download(name, download_path):
response = download_model(name, download_path)
file_name = response.filename
file_path = model_download_folder + file_name
if file_na... |
I find myself writing a lot of boilerplate mocking code for my unit tests. I think there must be a better way.
Background
I am working on a project that relies on complex configuration that is stored in a database. The API accepts an id, which is then used to load the configuration.
A very simple example:
public class ... |
(This relates to the problem domain I have previously elaborated on here - though the exact details are not that important for this question)
I'm writing an analysis application for Blockchain (DeFi) smart contracts to help me learn DDD.
The source of truth for data and state is in fact the blockchain. I can always go ... |
Spring Boot/Java 8/MySQL here.
I have a widgets table in my MySQL DB that is modeled by a JPA entity like so:
@Entity
@Table(name = "widgets")
@Data
public class Widget {
@Column(name = "widget_property")
private String property;
// all remaining fields here...
}
And which has a matching, typical, repos... |
Basically, here's the problem.
I work remotely for a company, and I need to have a local copy of the production database to play around with it and test my work on it before pushing the code. The prod DB is around 6GB, and so downloading it and then restoring it is time-intensive, to say the least. I want to commit the... |
I hope that's a proper place to ask my question.
I am wondering how is best to integrate RabbitMq (or any other message broker) into my project.
There are 2 options:
Simply collect all messages, whatever comes from my other services and dump all into Rabbit
Collect messages into intermediate service, to ensure "con... |
Let's say I have an abstract class A exposing a method called getE() which returns an object of type E which is an enum. The value returned by getE() will be defined per subclass. Put differently, every object of a certain subclass of A will always return the same value if getE() is called.
This is how I have implement... |
I have an interface
public interface MovieDataFetcher {
List<Movie> fetchAll(String query);
}
And these concrete classes
public class ImdbDataFetcher implements MovieDataFetcher {
public List<Movie> fetchAll(String query) {
OkHttpClient client = new OkHttpClient();
// get the json data, deseri... |
I usually write my code in a test driven style. I write tests as specifications and then my code. It's great and useful.
I always try to ignore implementation when testing and only test behaviour. I don't care how it gets done, just that it got done. I find this especially easy for functional programming.
Now here is t... |
I want to send two different json response for the same API based on a flag.
I have a final response json as below for /api/v1/student/, which is created by fetching responses from few other REST apis.
{
"students": [{
"name": "string",
"courses": [{
"courseid": "string",
"c... |
I'm learning about DDD and in many places it's stated that the domain model classes should have properties with private setters and explicit methods to change the model's state.
I wonder the reasons of that claim. Isn't the whole idea of the C#'s property to simplify the getter and setter?
|
I need to work on a project where we have a "case". Within this case we need to attach different things, in a timeline.
Those things can be:
Status change (Open, On hold, Closed)
Messages (just text)
Calls (call history, "call lasted x seconds")
Call rating
Now I don't really have a way of storing this in a MS SQL da... |
We have a REST API endpoint which creates a presigned url (/createPresignedUrl) to upload file.
How that works is when API call is fired, server would create a presigned url and send that in response. Later, client would use this presigned url to submit the file to our server.
Should that endpoint(/createPresignedUrl) ... |
I have read this thread: Is it bad coding practice to create something in a get if it does not exist?
But, my question involve a method which gets a record from a database or creates it if it doesn't exist. I have two separate methods for checking if a record exists and the second to insert if it doesn't exists. But co... |
This question is mostly related to the way language implementer do implements static class initalization (pretty specialized question). It is for curiosity and also to potentially improve my code to gain few nanoseconds
For most object oriented language I know (C++, C#, Java), there is a possibility to define a static ... |
Let's imagine an application where users can work collaboratively on projects. There's a project listing where a user can subscribe to a project, and a coworking screen where multiple users can work on a project.
So far I have identified the core domain, "coworking", and a subdomain, "collaboration project listing".
Bo... |
This post implies that the creators of Rust had to add the "async" keyword to make the async/await functionality backward compatible.
Why do we need the async keyword?
In a new language, where backward compatibility is not an issue, would there be any drawbacks to eliminating "async"? An alternative might be to have th... |
I have been trying to figure out if I can create a class or struct with a property that is of the same class or struct. An example would be
struct Number {
var Value: Int = 0
var Rate: Number() //Default value for rate would be 0
}
Effectively this would be a recursive line of code but I don't want it to exe... |
So, I'm working on developing my first Angular project with/for a friend of mine and I have a design question before I really get started with things.
I'm going to be storing persistent data on AWS DynamoDB (login credentials, whatever else), and my question is:
Would I be wise to develop my own REST API to interact wi... |
Why do they always say you can only change one aggregate per transaction? Decoupling?
Is it a rule you can break or is it more of a strict thing?
Does it also matter if we are in a monolith vs microservices?
|
I'm learning DDD so apologies if the question is too naive. Assume an application that manages user publications developed following DDD and using a RestAPI for external interaction (for whatever front-end layer for instance).
Looking at the Publication model we would have behaviors like ApplyLike, RemoveLike, Comment ... |
Asked this originally here, and didn't receive any answer so far, hence posting here too.
Let's say company A acquired company B in a certain region. This means, A and B were competitors in that region, and now A will be the only player.
Resulting, customers from company B will need to be migrated to company A customer... |
I am having an .Net Core Solution consisting of 3 Projects:
The Site (Asp.Net Core MVC WebApp)
The API (Asp.Net Core API)
The "Common" library for shared functionality.
The Common library contains all the business logic in form of Services. These Services are used by both web projects (registered inside their Startup... |
Scenario:
Our CLI-script downloads data
Therefore, amongst other things such as pre/postprocessing, it calls a function from another (internal) python package (which is maintained by another group)
The internal python package finally executes a request to an (internal) web server
In order to test the download-data fu... |
After reading, Does it ever make sense NOT to condense one to one relationships?, I wanted to take the question further with regards to contemporary design of entities, front-end code and controllers. The top answer is great, but one thing not addressed is how a code-first approach and modern websites may, if at all, i... |
My very large team is following trunk based development with many short lived features branches, trunk, and a release branch for when we create release artifacts. This is a team that keeps the release branch around while a release is ‘live’ in case we need to go back and patch the previous release. In other words, our ... |
I am currently working on a project using Flask to make REST apis, blablabla. But, working with request validation tools that we use, I am thinking of whether it would be necessary to validate the responses of the controllers.
I read a bit about Design by contracts and I saw how it was done in Eiffel programming langua... |
So basically the ISP states we should break big interfaces with members that are not cohesive with each other to smaller and more cohesive interfaces, which is very close (if not the same) to what is stated in the SRP.
Assume we have a Printer class that implements the IPrinter interface and assume for a moment the pre... |
In a debate with our solution architect, there were 2 proposed solutions to handle (illustrated below on the figure)
In the first, the API Gateway manages Authentication, Authorization and Accounting (and whatever required state management) , thus playing its role as security gateway, then calls the business service (... |
Assume we had a User class which should hold references for all different kinds of request, let's say at the moment we only have 2 :RequestA and RequestB, both inherit from the base class Request.
Now we are told to create a class representing the new kind of request in our business. We then create a RequestC class tha... |
Considering example below, one observe that for reference type argument is successfully understood as nullable parameter. For value type conversion to T?/Nullable<T> fails.
T Method<T> ( T? t )
{
// Error CS1503 Argument 1: cannot convert from '<null>' to 'float'
float f1 = Method<float> (null);
// ⇑⇑ float <fl... |
Is there a designated term for replacing hard constants (literals of any type) peppered throughout code with changeable constructs (can be a variable or #define or any similar mechanism)?
Basically, the overarching effect is integrating data into one place where one change is seen in multiple places.
For example:
int y... |
The question is specific to the API notation shown in the screen under the heading Table Name with the comment Joins Multiple Tables. I am using Spring Boot with JPA (Database: RDBMS)
I have defined API notations for multiple requirements that UI ReactJS based Portal application consumes the APIs. Are these notations f... |
Currently I'm on a project where my objective is to obtain the best code quality.
We have unit, integration & e2e testing. The e2e tests are written by the Business team in cucumber and these tests are the final condition to achieve the end of a user story. Also, all features must have the metrics that we want to chang... |
I am trying to follow Clean Architecture by Uncle Bob. I have 3 layers:
Core (Hosts business logic, and is the central layer)
Application (Host application usecases, and is directly above the core)
Infrastructure
I know the responsibility of the Infrastructure layer is to host any external dependencies that our appli... |
We finished developing our prototype using Node.JS and Express.JS (which works with HTTP1.1) and I am trying to upgrade to HTTP2. However I am having a lot of troubles to do this.
I first discovered that Express.JS does not support HTTP2, and the release of Express.JS 5 which should resolve this issue is postponed ever... |
Background
I'm trying to come up with an approach to building microfrontends.
Here are the facts of my circumstance:
Team 1: Develops the shell web app called "ShellApp" that will embed (host) other microfrontends
Team 2: Develops a microfrontend web app called "ChildApp" that will be embedded onto "ShellApp"
Both tea... |
I'm designing a python api to play a singleplayer card collection game and my prototype includes a state machine which uses pyautogui's locate function to recognize and update current game state through clicking the game directly. I am planning to use statemachine packet from pypi. Ideally this Api would be hooked up t... |
I have an app which uses barcode scanning to gather information about fruit.
A barcode could be bound to either an Apple or a Pear: the app asks a remote API which one is it, and then stores the information locally.
Two possibile solutions i have tried (pseudo-code):
1.
enum FruitType {
APPLE,
PEAR
}
class FruitInfo
{... |
Say I have a system with 5 microservices behind a gateway, and a user signs in through an IDP (OAuth)
A user U passes the access token in a request, and the call first reaches the gateway before it enters the services behind, say A, and then A calls B in order to complete the request.
Now, for inter-service authenticat... |
CLARIFICATION: There's a few articles around this point, I am trying to understand based on my use-case, what would you recommend as the AGGREGATE ROOT
The problem
Given a domain that allows creating new invoices with a constraint that each invoice must be unique (Identified by a code, set by the issuer's system, eg: I... |
Current setup:
We follow the cache-first strategy right now.
Always fetch from the cache first.
If absent in cache, fetch from DB and update the cache.
Cache TTL is 30 min. After this, the cache-key expires.
Problem with current setup:
As soon as we upload new data to DB(>10K records), the cached data is stale for us... |
For instance, if you have a hash table with the array of buckets 26 nodes long, one for each letter of the alphabet. You use that to keep track of names. So when a name "Jed" is added to the J linked list that already has "Jack" and "John", rather than just adding Jed to the end of the linked list, you structure that J... |
I am working on a microservices project involving 4 services - Auth Service, Service-A, Service-B and Service-C.
All the services are implemented using Spring Boot.
The Auth Service is responsible for authenticating logged in user and generating a JWT bearer token.
Each of Service-A/B/C has JWT filters which checks for... |
I'm trying to make better use of OOP, but I don't have good instincts for this yet and I sometimes worry I'm making things more complicated and/or less efficient. I'm wondering what is the best way to handle this situation working with groups of related objects that essentially map to DOM elements...
I've written a cla... |
I have a bookshelf microservice that manages user books' status (pending, read, reading now...). It exposes some REST endpoints to set book status:
PUT /users/{userId}/bookshelf/pending/{bookId}
PUT /users/{userId}/bookshelf/read/{bookId}
PUT /users/{userId}/bookshelf/reading/{bookId}
This microservice stores no data ... |
Our team had a discussion about the use of an API Gateway when our on-premises applications have to do a external HTTP call.
The scenario would be very simple:
On-premises application --> API Gateway --> Destination
We already have an API Gateway instance that handle incoming requests from clients, so the current API G... |
I'm creating an authorisation service, which does signing using a key.
For local development I was randomly generating a key on application start-up.
Now I'm deploying to the cloud (currently going with AWS), I'm refactoring this approach to be more robust / persistent.
The current idea I have is to generate some keys ... |
I want to understand how Dependency Inversion gets rid of switch cases.
Consider a service that needs to communicate with several databases.
class StockUpdater {
private final DataStore datastore;
public StockUpdater(DataStore datastore) {
this.datastore = datastore;
}
public void update(StockItem item, int... |
We are starting a journey in our company to use Kafka as our event backbone for both streaming data and for an event driven architecture. I foresee a pattern where we would want to consume events off Kafka and update a database, and also expose REST APIs to retrieve data from that database.
I had assumed a Kafka consum... |
Currently I have being request do implement an endpoint that would be responsible to update/create/delete sub-items for a single entity. The entities in case are students in a given classroom and the request would send the current status (number of students) in the given class. To summarize we have classroom that has a... |
Suppose I have the following entities:
class Employee
{
public string Id { get; set; }
public ICollection<EmployeeBadge> Badges { get; set; }
}
class Badge
{
public string Id { get; set; }
public Employee Owner { get; set; }
}
The employee and badge may or may not be stored in different ways, which is... |
The client wants to put a CSV file on an FTP server, have it processed then have an error file put back in a different directory.
We are only a small company so we can only afford to support Java as the language.
We also don't have an FTP server so we are considering using Azure blob storage with a blob trigger and Fun... |
Here are a couple of examples in Python:
clearly_even = 2 * get_integer()
print(solve_for_any_integer(clearly_even))
def solve_for_any_integer(x):
while x % 2 == 1:
x = make_even_from_odd(x)
return ... # Solve for even
When it's clear that an even number is passed, I'd make a solve_for_even function and call ... |
I see two possible interpretations of the semantics of request methods defined in the HTTP specification RFC 7231:
The intended effect of a request method is fully defined by the HTTP specification (e.g. for GET, retrieving a representation of the target resource) and any extra effect implemented by the target resourc... |
I'm working on the low-level design of a bike rental service and I was wondering if the solution is good or where it can be improved.
Context & Requirements
I used an exercise I found online which says:
City wants to start a bike rental service based on subscriptions where customers pays an annual fee that will allow t... |
We develop a Single Page Application (SPA) for enterprise clients. When we deploy a new version of our SPA we would like to upgrade a subset of clients whilst leaving the other clients on the more stable previous version. After the new version become stable we then upgrade the rest of clients. The release cycle will al... |
I'm working on a web application using Spring (Java and JPA + Hibernate) and I was wondering if there is a way of locking a MYSQL table and then when another web service (or even another thread from the same application) tries to read or write the locked table it waits for it to be unlocked.
For example, imagine a use ... |
Let's say I have an application where a user can do exercises and track them. I have the User entity:
class User {
private int stamina;
private int experience;
}
And the Exercise entity:
class Exercise {
private Date finishedAt;
}
The user can have many exercises. Once an excercise is done the u... |
As a prerequisite I will say that we are wedded to postgres to provide this solution.
This is a very broad problem, and I think it must be solved many times over, but unfortunately as it's so general I can't find any really interesting solutions online.
We have a task we need to run, say "reindex customers". This needs... |
Having a bit of trouble on deciding the best way to store crypto values which are usually in decimals. Do I go with Double or Float? Or is there an even better type that Swift offers?
My initial gut feeling was Float, due to a constraint that I will have in the application (I won't even be dealing with amounts that are... |
I am working on a very LEGACY MVC App using C# which is built from 2009. They dont have any client side validation at all. In other words, they dont use Validation mechanism provided by MVC framework as the following link
https://docs.microsoft.com/en-us/aspnet/core/mvc/models/validation?view=aspnetcore-5.0#client-side... |
I started working on a project and I saw some methods with this With prefix and I'm wondering if this refers to a known pattern.
Does anyone know of this naming pattern?
|
For example:
PostCode
PK PostCode
Address
PK HouseNumber
PK PostCode FK
Seems reasonable. But can we carry on indefinitely?
Room
PK HouseNumber FK1
PK PostCode FK1
PK RoomNumber
Door
PK HouseNumber FK2
PK PostCode FK2
PK RoomNumber FK2
PK DoorId
Obviously I'm repeating da... |
I noticed that the default behavior for Visual Studio C++ projects is to organize files using filters instead of folders on disk. Essentially all the source files within the project are stored in the same disk directory, but the filters virtualize the files into a hierarchy.
What value do "filters" offer compared to th... |
I am engaged into a discussion with my peers where there is a disagreement between where ease of service fits into FURPS model.
I feel it should be part of Usability. Though my peers suggest it should be under Supportability
Would appreciate it if someone can clarify the confusion.
|
I understand that using the React Profiler in production should have a small or negligible impact on user experience at least for profiling 20-50 (guess) components on a page.
I would like to know if anyone can share any known data/estimates on the performance impact on the user experience when shipping the production ... |
I have a Dao interface which doesn't have any methods defined.
Then I have multiple classes which implement this interface, like PetDao and HouseDao.
For some of the implementation classes, and some of their methods, I need to do an operation.
Let's say this operation is defined in the Operation class, and the method i... |
In a DDD implementation, I am trying to design my domain model and the way to properly interact with child entities of an Aggregate through the Aggregate root.
Imagine the following two classes in an Aggragate called "Basket".
class Basket
{
string Id;
int TotalPrice;
List<Item> Items;
}
class Item
{
s... |
Coming from the world of C#, where, despite sharing namespaces, it's quite common for every class to have its own file, I find that Rust codebases seem to have a complete different sort of philosophy (and perhaps less organization) in the sense that lots of structs, enums, traits, etc. are combined in the same files, w... |
I'm learning about immutability (specifically in C#) and I can't understand the examples out there stating that making an object immutable brings real benefits (besides a shared object in a multi threaded environment, which the benefits are pretty clear).
The most talked example in my readings is DTOs. It's said that D... |
I am trying to solidify my understanding of the definition of a fully dressed use case.
I was asked a question in an interview which was as follows:
Operations contracts are generally written for:
All fully dressed use cases
All use cases
The most complex operations in fully dressed use cases
The most elementary oper... |
NOTE: I believe I have a bit of an X/Y problem here, so please, bare with me. Also, I have trouble explaining things sometimes, so feel free to ask me to elaborate, and I will improve anything I can about my question to make it clearer.
I have a system in which I have a central service that calls a processor to perfor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.