instruction stringlengths 34 36.1k |
|---|
Assume I have a request:
app.post('/order', ()=>{
// task 1
// task 2
// task 3
})
and task1 and task2 is completed but task3 failed.
for example a user paid order successfully but saving order in database fails.
specially in node.js application that global environment is shared among all http clients and if app c... |
I am building a new Python library project to be consumed by several of my application projects. The existing code consumes environment variables for various configuration settings. Should my library project read configuration from environment variables? I've always learned that libraries shouldn't make assumptions ... |
I am working on an Authentication system (java based) that will authenticate users and create a session for them. This session is valid for 5 hours. I do not want the same user to have multiple sessions at the same time. For this reason, every time a user logs in, user details are stored in a table. Its primary key is ... |
I thought, In a microservice architecture, only the "Configuration Server" will be responsible for providing configuration to individual microservices even if it's a small config. So that we can change it from a central point without going through individual microservices for changing the config.
Just want to clear my ... |
I've seen that with the Dictionary API now has methods with bool TryGetValue<TKey, TValue>(TKey key, out TValue value) and I like this kind of methods because they're signaling to the other devs that you must not check the value but the output of the Try method.
And now that I've seen this I've a tendency to this for m... |
I have taken over the maintenance and development of a mature .NET Framework ASP.NET MVC application which uses an Entity Framework repository pattern. Several developers have worked on it before me and there are various styles. Database access is predominently accomplished though a mixture of EF LINQ and raw SQL. Most... |
I use the Laravel framework.
I've got controllers, like CustomerActivityController, and I've got a service layer with services like CustomerActivityService.
Say I want to create a new customer activity via an API call in JSON format. The controller receives a JSON string as request data, and that JSON is parsed to an a... |
I have two classes. "System" and "Bluetooth". I want to have a really loose coherency between these two classes as they should be able to exist or not without depending on each other's existence.
system class should be able to notify the Bluetooth class when data is available to be sent by Bluetooth and vice versa, the... |
For this question we got for a mock test we did and I have put the correct options in bold
Consider the following use case diagram, is it correct to state that:
a. Customer directly interacts with Bank via Valid customer.
b. Only valid customers can undertake withdrawal, deposit, and transfer transactions.
c. It is po... |
I have a multitenant application where a user can belong to multiple tenants. I'm using Identity-Server 4 for the authentication.
I have two applications Angular and API. When a user is not authenticated, it's being redirected to the Identity-Server and proceeds authentication. Once the ID4 ensures that the client cred... |
I have recently joined in a new company as a frontend developer and I got access to their current repository which is made in ReactJS. I can see that current team is not very experienced in reactJS and standards. Some examples like
not using redux or any state management
lots of unused packages
Using class based compo... |
I have been working on an Android application for some time, and ever since the beginning I've developed a practice of splitting my class's (mostly activity/fragment) code up into multiple files.
This is because the Udemy course from which I learned Android development had an instructor who followed this practice.
Thes... |
The web application I am working on is currently (partially) tested automatically.
All scenarios are hardcoded in custom code in this way :
WebElement bt = findButtonWithLabel("foo")
bt.click();
WebElement input = ...
input.sendKeys("...");
// ... do that
// ... verify the text "baz" is present on the page
I want to s... |
I see the term legacy signature a lot in the documentation of programming languages. For example in the php documentation :
Passing the separator after the array (i.e. using the legacy signature) has been deprecated.
But I can’t figure out what it means. I googled it but the results seemed to have no correlation w... |
I have the following problem - I write the code for object data manager, and one of requirements is being able to save/load data into some persistent data storage. I want to make it as the following:
there is an interface, IPersistentDataService.
if user uses an option to save/load from file, they can give arbitrary f... |
The Python Package Index (PyPI) is a public repository, and it seems that anyone can upload packages to it using a tool like twine. The openness of the system raises some questions:
Say, a person/organization tries to publish a package, but discovers that the name is already taken. How does PyPI resolve these situatio... |
There is a number of devices with Internet access but they are on LANs and have no public IPs. As time goes by more devices will be added.
I need to be able to communicate with each device on demand (metrics, diagnostics, updates, ...). I do not need or want full root access.
I understand I could create an SSH tunnel i... |
I previously asked this on StackOverflow, but doesn't fit there and I was suggested to move it here.
I was thinking about using two seperate backend languages for seperating concerns in a project of mine. Another reason would be learning.
One backend would be a local windows service working with a special/proprietary i... |
[I'm using the term interface here with C#'s interface in mind. I won't tag the question with a C# tag because it really isn't a C# question.]
In my work we do unit and integration tests but we don't follow TDD. The tests are often written after the classes.
In this work, I often see interfaces that matches the whole c... |
So far my weakest side has been proper code structuring and organization. I wanted to know how I can properly apply separation of concerns to the following code to make it more organized.
I have a function deleteCurrentList().
It does two things: deletes the currently selected list and navigates back to the previous pa... |
I'm reading values from a (PE) binary file. The values have a known length and position in the file and are stored with no padding (right next to each other). They store various types (int, long, pointer, array...).
I'm trying to parse those binary structures and store them in a useful way. The obvious way to do it is ... |
Consider a context where we have Users saving Questions and adding personal Tags to them.
In a graph-based paradigm, a first approach could be something like:
(User)-[SAVES {tags}]->(Question)
However, with this solution tags are treated as properties of the relationship, and I want to have Tags as nodes (just like Use... |
I want to build a search with basic typo tolerance.
There are quite a few string similarity algorithms (and implementations for almost all languages I guess).
However, humans tend to make some typos more frequently than others. E.g
mixing up the order of letters when typing, e.g tpying instead of typing
hitting the ke... |
Given an auction system, there are several ways to apply a discount to the transaction's final amount, e.g.
Special discount for a given seller
discount for a given buyer
Discount for a specific buyer and item combo
etc...
Given how confusing and complex the business logic could be for discounts, there is a proposal ... |
Given the (old) debate over whether Singletons are overused/abused/are worth it - would it be a bad idea to inject the dependencies as default parameters? In this way, we could get rid of defining singletons for the dependency container registry for the corresponding interfaces - while still leaving the objects in ques... |
Is it possible in theory to have a programming language that allows for object lifetimes that exist beyond the current scope but without using heap?
As a little background, in embedded development it can often be advantageous to avoid heap and lean heavily on the stack. On our team we use the stack as a large object g... |
My service B is part of a chain of services and calls a downstream service C.
A --> B --> C
Service C is returning HTTP 500 errors for any error it faced, including bad requests or input validation errors that normally should be 4** errors.
There is no option to change / update service C.
Since service B is stuck betwe... |
I'm wondering if there are some best practices to deploy Docker images to Digital Ocean using Terraform.
Because I don't expect much load and don't need failover features etc. I'm not aiming to deploy to kubernetes. At least not for the moment. I just wanna deploy a standalone Docker app.
This leads me to the question ... |
Given the microservices pattern is the decomposition of software by business capability with ownership of state, and a single customer view is an aggregated, central, "single" data store of all customer data that can be used to drive application functionality, are these two patterns able to live together or are they in... |
Sometimes code will need to be moved. A common example is some logic that exists in a controller needs to get moved to a helper class so it can be called from outside of that controller. So someone else who didn't write that original logic will cut the code from the controller and paste it into their new class. When th... |
Imagine a scenario where a gift card has been purchased with cash, the gift card is duplicated, and each card is used to purchase an iPad at a self-service counter at exactly the same time.
What are the possible ways to prevent or mitigate this duplicate transaction in an Always On architecture?
I have come up with:
P... |
I have the below given data model
itemid - name - collectionitemid
example:
itemid |name | collectionItemId
-------------------------------
101 | abc | null
102 | def | 101
103 | ghi | 101
104 | jkl | null
105 | mno | null
In the above model, there are items and collections, there can be no collectionId... |
For anything larger than a 64 bit integer, why would I want to pass by value?
[Update] The question was closed, because it was not specific enough. One comment suggested that I specify a language. I deliberately did not do that, thinking that this site should be language agnostic.
I was prompted to ask this when I was... |
We are just starting with event driven (and clean) architecture.
So far we have two main entrypoints, a consumer (reader from a Redis Stream / Kafka Topic), and an API.
As this is almost a modular monolith and not a proper isolated microservice, we added an extra layer that we called the Processor, it basically redirec... |
There's a public FOSS library available online, which has not seen any commits by its author for about 3 years. 2 years ago the maintainer added a README.md comment saying he's sorry for being unavailable and will soon attend to bug reports and PRs. But - he hasn't. He appears with his real (?) name, a photo, and a lin... |
I'm developing a commercial closed-source application that will have a user-interface, and the back-end will be generating C++ code that needs to be compiled to produce a final end result.
When I distribute this application to the end-users, do I distribute the compiler as a component of the installation or will users ... |
I work developing software, and very often I find inconsistency in the company's code. The thing is, there is a method named createOrUpdate(), and this method basically does what its name says, creates or updates a given record. However, I believe this method violates the Single Responsibility Principle, because it doe... |
I'm starting to run into this sort of dilemma while many third-party APIs, but I will use MongoDB for my examples. Consider the following code:
var settings = MongoClientSettings.FromConnectionString(connectionString);
settings.ServerApi = new ServerApi(ServerApiVersion.V1);
_mongoClient = new MongoCl... |
I have a use case to create a service that consume messages from a message queue, process them, store them in the DB, and expose the processed results via an API. Therefore, the service I'm going to create will have to have both an API as well as listen to events.
I want to clarify if this is an anti-pattern in a micro... |
I'm taking another look at the pros and cons of the Visitor design pattern for a talk.
There's obviously the issue that the Visitor has to be aware of every class it has specific handling for, but that's an inherent feature of the pattern.
The bigger problem I have is that, unless I've misunderstood something, every vi... |
I have a simulation in Python which reads its configuration from a toml file. Since I have tons of parameters, the toml file can grow quite large.
This is an example file, similar in structure to my actual configuration file:
city.toml
name = 'New York'
[[houses]]
address = 'Foo Street 42'
color = 'red'
[[houses.res... |
I am working on a program that will listen to a queue of incoming message and will process each message differently depending on the metadata of that message. The messages must be processed in order and if a message fails to be processed, it will block the queue until that individual message is processed. The specific ... |
This MDN article here summarises quite well the technique of Content Negotiation on a REST API.
In essence, if we have a GET /student/:id endpoint, we might want to see different representations of that resource, (html, pdf, json, xml), and we can do this by attaching an Accept header to the request.
They are all the s... |
I am working on a small project with microservices architecture in Spring Boot. As to not make unnecessary calls to users-microservice, I have duplicated some necessary User data (id, name, summary, photo) also into the posts-microservice, by having an Entity named UserExt ('external').
The posts-microservice contains ... |
Doing TDD in a kata is simple. A red test, small amount of code, green test, and refactor. Repeat. And that's it.
But, I work on a real application. With a REST controller, a service layer for business logic, a database layer and a converter from entity classes to data transfer classes.
How can I start TDD in such case... |
I am new on DDD and hexagonal architecture and I am stuck in deciding where to place a very simple piece of code.
To code is a simple JWT decode. For SRP reasons, I want to isolate this action into an specific class like the next one, but the question is where...
class JWTDecoder
def initialize(id_token, signing_key)... |
I have an application that needs to publish events to an event broker and consume events from the event broker.
I want to do this with an event bus. This event bus should have one public method: dispatch.
I do not understand how this works. It has been described to me as this: the event bus will publish messages to the... |
When doing PR reviews, should the reviewer be checking that the code is correct (e.g. the logic is correct, etc.) or should the only focus be higher level concepts (e.g. architectural/functional/etc.)?
I've been doing a lot of code correctness checking in PRs, mainly because we have been seeing some quality issues, and... |
I'm working on an application where it has financial control for the incomes and expenses of the company. These informations can be controled by accounts (bank accounts - can be 1 or more), categories and subcategories.
The main objective is to display the current month financial information (or the same information on... |
Currently I am reading UML Distilled - Third Edition (Martin Fowler) to catch up some new thoughts and spot interesting things I am not yet aware of.
On of those things I came up is the differentiation between generalization and classification.
In Chapter 5 - Class Diagrams: Advanced Concepts, Martin Fowler wrote at th... |
I'm trying to design an application that uses the microservices architecture. The service would have an api gateway, a user service and then a seperate service for each analytic source.
For example, lets say I had twitter analytics data and instagram analytics data. There would be a seperate microservice for twitter an... |
My workplace's database has a pattern that I've not seen before. Every column that is intended to be a key, whether primary or foreign, ends in _SK. This is shorthand for "surrogate key". It appears to be an informal way to tell the developer that said column is safe to use in joins and won't have any type mismatches o... |
Let's say I have a CQRS system where my write model contains the business rules. My read model is simply a DTO; it is a collection of properties and "dumb".
Now if you were to create a REST api, it would use this read model and return it.
Now I want to add HATEOAS to this REST api. Meaning that instead of just returnin... |
I need to write (in PHP, if that matters) my own password generator to generate simple passwords. Passwords that will be used by kids or elderly people only. That will generate passwords that are easy to remember, yet still has at least a minimum level of security. Something probably as close to XKCD #936 as possible.
... |
I am developing a front end application given a back end with some API.
The application has two similar views. Both views make use of a big table that's also used as a form . For example, in the table there are some values which are inputs or check boxes, or even buttons. That table also comes with a nice search... |
I've mainly studied SQL structures, and I know that the representation of the entities can look something like this:
However, I'm building this app with MongoDB, so NoSQL DB. I'm aware that MongoDB is non relational. Is there a standard way of representing these kind of databases?
Is it possible to use the previous fo... |
I'm working on a design for an HTTP based API that takes in requests to perform a long-running task that requires CPU and RAM intensive processing.
To give an impression of the compute requirements, when deploying this to a k8s cluster, I allocate about 3.5 GB of RAM and 1 vCPU to each pod, and the VM is a high-compute... |
The api has one endpoint with some parameters. Based on these parameters I can predict how long the processing of the request would take. It can go from seconds(s) to tens of seconds.
When expected time is small, I want to make response synchronously, and return 200 upon completion.
For heavier requests I'd like to res... |
So I have a couple of Java RESTful microservices, and since the past few years I have basically been using Docker to build them and deploy them over to a Kubernetes cluster.
Our team is upgrading Kubernetes versions, and it was brought to attention that latest versions of Kubernetes don't support dockerd, and has moved... |
I know there are potential duplicates, but imo this is different because there are around 100 developers actively working on this nightmare.
I have unfortunately gotten into a job where this GUI project exists. Development started around 20 years ago and it has to support different hardware and OSes (Windows, Linux).
T... |
I'm writing a webapp that serves users with different roles and permissions. One of the features of my application requires an API call to a secured endpoint. If the user doesn't have the correct permissions, the endpoint responds with a 403 Forbidden. In my application, the failed API call has no effect on the behavio... |
I have a client/server application that exposes data and commands through REST APIs. This API exposes a GET /recipes/:id endpoint that instructs the client on how to show a recipe. A recipe can be made of diverse activities, each of them carrying specific contextual data. Summing up, the API response would look like th... |
I'm working on a project which needs to always be up-to-date for my users. It's quite simple to make an auto-update feature, but I need to know how ethical this is.
If, when the user installs the software, it tells them it'll automatically install updates silently in the background (when the user opens it intentionally... |
I have an application that can be reduced/simplify to this flow:
user sends request to app A
app A inserts info about the request and user into DB ( marked as "B in progress" and "C in progress")
app A pushes the data into queue and returns to user
app B retrieves data from queue and process it
app B finishes processi... |
In my PHP Laravel application, I want to display special offers to users, depending on the quality of their house(s).
There are 4 Models: User, House, Offer, OfferTargeting.
Each User can have many Houses.
Each House record has details like size, type, city, country etc.
Each Offer records holds the details of the of... |
So, I'm trying to understand how this is done in real life... If I have a website with an API and a UI, and a User Story comes in like... as a user I want to be able to login that requires changes changes to both tiers and different teams work on each tier.
Would you create separate user stories for each team?
Do they... |
I am curious how others tackle the issue of needing small, sometimes trivial changes in a pull-request. The problem crops up a lot where I work. A developer completes a task and makes a pull-request, and after some review and changes it is good to merge except for one last detail. Rather than ask them to once again mak... |
I wanted to understand what are the best industry practices and the pros-cons in the following 2 choices:
A single service that serves internal only API and public API, vs
2 separate services - one for internal only API and another for the public API
I would like to add more context as I understand the answers will d... |
We are currently splitting up our Intranet monolith into multiple (Micro)services. The layout in itself is already finished and we have decided to split them up in a way that there is only ever one service connecting to a different outside service. One of these services, for our news and companywide calendar has to con... |
So, i just start learning in AI field and i want to develop my skill more. So, i just curious is it possible to predict last 3 digits of a closing stock price? which mean the output result will run from "000" to "999" in total 1000 number and to make it more clear lets say the closing price of Dow Jones Industrial Aver... |
I'm developing an API that given a few parameters, reads the given data, transforms it and returns it as JSON.
Eg. (some logic included)
Request:
POST /myApi/exportAsText
Content-Type: application/json
{
section: array,
answers: array,
targetLevel: int
}
Output:
// Goes through data, create big text
{'text... |
I'm trying to design a data updates mechanism in my micro-services architecture.
For the sake of simplicity, let's assume we have two micro-services A and B, B exposes an API for creating some tasks, using simple REST, POST /tasks, which creates a task and returns a unique task identifier to query on - task_id. Then an... |
My question regards to constants in Python. Which is more "convenient" or "acceptable" among software engineers in general:
Putting classes of constants in another file called "consts.py" as such:
consts.py
class Messages:
GREETING = "You are greeted by {greeted_person}"
or in a class of classes of constants as ... |
Intro
Structured concurrency is a relatively recent concept for structuring concurrent programs. It has implementations in for example Python, Java and Swift.
Examples of structured concurrency often describe a server application which has to receive or make multiple requests on the same time.
Like this:
async with tri... |
I'm writing integration tests for an already existing product.
I'm using the Spring Integration Testing suite for this purpose, which allows testing a real DB connection by creating a transaction and rolling it back after the test execution.
This looks safe to be used to test also against a production database, however... |
My team writes a lot of Python code in PyCharm to do quick simulations and calculations for our mechanical engineering work. Often, we'd like to include a little image (a hand drawn sketch, CAD screenshot, or a PowerPoint slide with a diagram made from AutoShapes) to explain how different variables relate to a physical... |
Is there a name for a function that outputs more data than was put into it? For example: let's say I input a one byte value into the function and it returns a three byte value, is there a name for this type of function?
|
I am often confronted to this problem in my scripts and I feel I am lacking some software design culture, I hope this is the right place to ask and sorry if this sounds too simple.
I write many scripts in Python to do various ML related tasks. They start small (e.g. I just want to compute some results) and often end up... |
Situation
I have some existing functions which expect containers which can be iterated and which have certain value_type. The value_type can be a value or some (smart) pointer.
All the value_type have traits implementations for their base types, f.e.
template <>
struct Trait<A> {
static void test(A const& v) {
... |
I am designing an API using .NET core 6 C# which has 2 versions. For v1 I have something like the following for the business logic interface (fictional names and simple fields just to facilitate understanding):
public interface IV1Business
{
Task<MyModel> Create(string configuration, string metadata);
Task<MyM... |
Currently at my company three people take part in the annual performance evaluation of a software developer:
the developer,
product owner from the scrum team of the developer,
head of software development (line manager).
There isn't any 360-degree review system. Additionally, scrum masters usually are asked for writt... |
Let's take a hypothetical system, a state based,
exceptions thrown from persistence layer or other outer layer, should propagate to ui layer through domain layer. Domain need not know about this exception. so no catching(ideal domain?)
the issue is that the outer layer catches the exception, but now the system is in so... |
As suggested by Uncle Bob in his book "Clean Code", I am actively trying to keep my functions small and readable.
However, I often encounter arguments drilling when I try to refractor a big function into smaller ones.
For example,
func bigFunc(input) {
funcState := ...
for {
smallFunc(input, funcState)
anot... |
The question is simple: there is no shortage of opinions that state automated unit tests are to be written only for public methods.
What is the authoritative source and argument behind this best practice?
|
I have two bounded contexts, Store and Inventory. The Store context has the Product aggregate, the Inventory context also have an aggregate called Product. Product is a different concept inside each context.
Now in my Store context I want this behavior in the products: "Please select the items from stock needed to sell... |
I am working on an online exam management system, which have those main actors:-
Super Admin. Can manage questions/answers under all functional areas.
Functional Admin. Can add questions/answers under his/her functional area only
Applicant. Attend the exam
The system itself. with modules including; Exam creation, Addi... |
We're building a PDF service for internal use, to permit common operations like HTML to PDF, merging PDFs, extracting pages, convert to/from other formats, etc. We intend to use a queueing mechanism so everything would be async. The only thing we're trying to decide is whether or not we should front the queue with a RE... |
If I am working on a project, say it has this file structure:
car/
body/
__init__.py
doors.py
bonnet.py
engine/
cyclinderhead/
__init__.py
pistons.py
__init__.py
crankshaft.py
engconstants.py
utilities.py
Now invariabley the pistons.py file wi... |
I am designing an API that some operations may take a while, for example, creating a backup (not the actual case).
I am planning to have an endpoint to query the current job
http GET /api/v1/jobs/{uuid}
{
"code": 1,
"status": "created",
"running": true,
"completed": false
}
To create a new task, the client sh... |
I'm designing a REST API in which users create groups that other users join and leave.
A user creates a group by making a request like this:
POST /groups
Request body:
{
"name": "Avengers",
"description": "Earth's mightiest heroes"
}
A user retrieves a group by making a request like this:
GET /groups/{id}
Respon... |
I have a program that accepts computer names and then will perform CIM session tasks. The computer names are passed in from the user input and separated by "," (ex: program.exe -computers pc1, pc2, pc3). Then after accepting the input the program will multi-thread against the computer names at the same time.
I'm stuck ... |
I need to make an app for employees & employers.
When is it worth writing your own CRUD generator for a project with the aim of process automation?
With such a generator I wouldn’t need to create manually basic CRUD models, for example: job type, countries, cities, male, work experience, education, especially when cons... |
I would think the answer to my question is yes, but I have never really seen it in practice or any OSS project (and links to any OSS sample projects are highly welcome because the typical examples lack a lot of domain logic for me).
So, my specific case:
My application is mostly network-driven, that is, the UI is just... |
I'm helping a software team to embrace a transition to DevOps and I realized that they struggled a lot with testing. The one point that troubles me the most is that they absolutely want to write unit tests in pytest, when the application is developed ... in C#. Part of this excentric idea comes from the fact that they ... |
We are developping an app and I am not really pro at rest API etc.
We decided that a maximum of business logic should be in the backend and started to do "business" route. But sometime I wonder if i don't split too much my api/controller.
For example, let's say we have a "car" object, in my backend. it's stored in "car... |
Let's say you are performing a PUT request on an endpoint for a resource that holds a list of entities. For example, a football team and it's players. It would be fair to say that the list of players is within the bounded context of its team?
Does this mean that the aggregate root should have the ability to change anyt... |
Here, I suggested the following approach to implementation of a simple text adventure game (in Python). I think that this principle could be used to develop an adventure, similar to The Colossal Cave adventure, by storing a following rooms in a deque. Rooms (represented here by tuple of (function, params), but possibly... |
Disclaimer: this is not an attempt at solving P vs NP, but a way for me to better understand the problem.
Let ¥(n) be the Subset sum problem, n being the number of inputs.
Trivially, a brute force algorithm can solve ¥(n) in O(n2^n).
Let's Divide et Impera trying to solve the problem using n P algorithms:
First example... |
I have the following situation in my spring boot application:
I use unidirectional relationship modelling for my database entities, in order to prevent difficulties with a bidirectional approach. (Cascading, Updating both sides etc.) Of course I don't want to expose this structure to the presentation layer, thus my DTO... |
I have a class hierarchy with a base State class, several inheriting classes each named after their relevant state, and an FSM class that contains all the states in a particular state machine as well as the logic for moving from one state to another. A simplified version in Python:
class State:
def __init__(self):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.