instruction stringlengths 34 36.1k |
|---|
Processors have come a long way in their handling of unaligned data - from crashing at the very notion of it, through suffering severe penalties, all the way to having almost no impact.
I suppose it is still possible to do harm, if for some reason the use case happens to somehow abuse cache line boundaries, but all in ... |
A common problem I run into is when I have a Factory (let's say ThingFactory) which creates multiple different IThing implementations, and each of these concrete implementation classes requires an exclusive set of constructor parameters.
With a naïve implementation of the ThingFactory, it would need to know about the u... |
I have 2 entities with a parent-child relation (like a base product and product variants), basically the two entities have the same properties and at runtime (when instantiating the object) if the the property X have a value in the parent then the same property X should have the same value for the child entity instance... |
For a given, tree-like data structure:
- Alan
- Barbara
- Charlie
- Cecil
- Brian
- Chris
- Candice
- Cohen
- Boromir
- Corcoran
- Arthur
- Bort
- Clive
- Chad
- Berman
- Chud
- Angel
- Barry
- Cri... |
I have three layers. I wish to reduce coupling between them and other modules.
I wish to use the command pattern between all layers. A command should be able to be passed from one layer to another.
For this, all layers must have implementations of the same set of interfaces, for example the command interface.
I'd prefe... |
i'm making a custom form builder app similar to google forms or wufoo and i've completed the basic database design. However there is one thing i can't figure out. I'd like to keep track of version of each built form. Like if there is a change in an existing form i don't want to just update it to lose old form design, i... |
So I've been trying to understand the difference between MongoDB's Query API and its Query Language but I haven't been able to find a definitive answer.
I've been reading the MongoDB Docs and it is written that the MongoDB Query API is "the mechanism that you use to interact with your data".
However, on Devopedia, MQL ... |
I'm dealing with creating a few internal libraries for a project that can offload emails and logs to a queue (Service bus, storage queue).
The issue I'm having is how to configure the the queueing endpoint, without passing it in, which would require the projects using said library to be aware of the queue endpoint as w... |
Let's say there are two layers of an application:
Business logic layer
Data access layer
Assume integration tests need to be written also for the Business logic layer. Alas tests that run against the database.
Let's also say you are implementing features in a branch in the Data access layer and in this branch you com... |
Assume an application developed in a PaaS public cloud environment. The application stores and processes some kind of sensitive data.
Encryption-at-rest seems clearly described already, and the option to manage keys outside the cloud which can help ensure nobody outside your organisation has access to your unencrypted ... |
We have been continually facing this challenge during the last year. Upper IT management wants us to use Agile Methodology internally (development team) while the external client refuses to do so and wants hard commitments with clearly defined requirements, clearly defined deadlines, and clearly defined payments and fi... |
Assume there's a public void process method on a Java class called A that currently takes a single String argument id.
class A {
public void process(final String id) {
// Some implementation
}
}
The existing method's String id argument has a specific format: type#integer where type can be foo or bar (so foo#1 ... |
I am trying to create a use case diagram. In the diagram, I have two actors that have access to the same use case (View Properties) but they have different functions related to the use case. Can anyone please let me know which one of the diagrams below is correct? Should I keep one "View Properties" use case or should ... |
I'm currently playing around with a CQRS implementation and I'm having some trouble understanding the following concept:
Event Bus for publishing update events (required): Whenever the write
database is updated, a change notification is published as an event on
the event bus. Interested parties can subscribe to the ev... |
Right now, I have this enum, called MemberCategory, defined to be:
public enum MemberCategory {
MEMBERSHIP("Membership"),
GOLD_MEMBERSHIP("Gold"),
SILVER_MEMBERSHIP("Silver"),
STANDARD_MEMBERSHIP("Standard"),
PEDIATRIC("Child")
public final String textValue;
public MemberCategory(String te... |
I work in a software company with a single product, a 25 year old monolith application (1.2m lines of code) handling all HR related data (employments, salary, collective agreements etc.).
I've been put on a team that needs to research how we can modernize our application and so I've started reading up on different desi... |
My team owns several services. One is our primary focus: an accounts service. We have a plentiful stream of feature work and tech debt to address there, and everyone (engineers, product, design, management) is aware of its going-ons and going-wheres.
Two other services though, have to do with exporting our data to a th... |
Currently my company is storing the installers (and in some cases the installed directory copy) for some open source third party tools that our build uses. Were storing these files in our github repo which makes it very large and slow. I want to clean this up since the files themselves are not needed directly for the b... |
I only recently started to work with backends. My database is supposed to store information about maven-like artifacts. There are going to be applications and configuration artifacts. Now those artifacts are pretty much alike - they all have group name, artifact name, versions etc. However many times I want my logic to... |
I work at a company where we have your typical sprints filled with engineering stories that need to get done. But then we have "work" that is not allocated within the sprint. This "work" is stuff like 20% time, reading and presenting papers, work related to various guilds within the org, and a bunch of other things. ... |
We currently have a REST API service (let's call it as A) written in Python which triggers various heavy calculation jobs for Worker (W) written in Python as well. Both services are interconnected using a self-written PostgreSQL queue lib.
That's how they communicate at the moment:
1. Call POST request to service A to... |
I'm writing a new microservice app. event driven app.
The app handles crypto currency wallets.
There is a service: "Coin Service", this one holds data that every other service need access to.
I have 10 services, 9 out of 10 services needs to have access to coin service data.
I dont want to sync all of its data 9 times ... |
I'm looking for suggestions on how to modernise my development/release practices by potentially introducing some automation. I'll outline the current process to help explain why I'm currently struggling.
We have 2 long life branches, master and staging. Live servers point to the master branch and our test/staging serve... |
Let us say I have an entity House that I want to store on a database. The House has an attribute yearBuild. If the house was build before 1990 its status should be 'ToBeSelled'. Now I have two ways to model this
a) store the status in the database as attribute(metadata) or
b) extract the status on runtime each time I a... |
I am still an beginner/intermediate programmer at best so apologies if I misuse terminology.
I work with SCADA software for my job, specifically Ignition by Inductive Automation. It's made for rapid application development, and all you really need to know is that it's built upon java, so what I end up using in practic... |
Older iPads used to have a home button:
Newer iPads don't have it. They have a line on the screen you're supposed to swipe up to get to the home screen:
Now if an app has a row of links or buttons at the bottom of the screen, it has to leave extra space for that line on the screen.
How are people handling this? Am I ... |
When updating to a new major version of .NET (in this case from .NET 5 to .NET 6) without needing to make any change other than selecting the new target framework in Visual Studio, does this warrant a new major or minor version or does bumping the patch version suffice, when adhering to SemVer-principles?
When I update... |
I'm new to DDD and I would like to clarify some concepts. I'm thinking about DDD in the client-side.
The first one is regarding transactions:
My understanding is that transactions are a responsibility of the application layer, when the use case has to coordinate different entities with some level of integrity.
However,... |
Since I don't have much knowledge of multi-threaded design and English is not my native language, I don't know how to exactly describe my problem.
Let's say I have a mini-program in school, which has the responsibility to analyze a runtime feed. The feed is a continuous list of messages with the following format:
{"typ... |
Is there an accepted name for what it's called when someone takes are relative small codebase and splits it up into many tiny libraries, containing just a few or even just a single class, or likewise splitting up a single coherent class into multiple smaller classes that depend on each other.
During my travels, I've tw... |
I'm working on an application with a database containing many recipes. The API is written in Django (with Django REST Framework) and frontend in React.Each recipe is assigned a high-quality image. In React application, the user can see all the recipes with their images in a list view. The problem is that they take too ... |
I have a website and mobile applications Android & IOS, all platforms are connected to the same database, what we are trying to do is to enhance the user experience by showing him specific products based on his selections however right now we can do this a cross all platforms only if the user is logged in using his use... |
Summary of my question in a short form: How to propagate changes of domain objects upwards without introducing application logic into them?
Following 'facts' are based on prescriptions from respected software architecture authors.
Fact 1: In layered architecture, a lower layer should never make explicit method calls up... |
I am implementing if/else statement, by using function "inCase" to make it more readable:
const size = 'small'
const equals = str1 => str2 => str2 === str1
const inCase = (obj) => (predicate) => (whenTrueFn) => (whenFalseFn) => {
predicate(obj) ? whenTrueFn() : whenFalseFn()
}
const renderMobileNavBar = () => co... |
Basic question: I am wondering if there are any industry practices or style guides that mention which of these two styles is better:
if x == 0 //or nullptr
or
if !x
(I am thinking of programming languages where for the same variable x both styles are syntactically allowed and semantically equivalent).
I've always pre... |
What is a suitable software design approach for handling user input from hardware buttons, where the function of each button depends on state?
I'm designing a musical instrument which has a lot of hardware buttons (something like a Novation Launchpad or Monome Grid). I'm used to building screen based software, where yo... |
I'm writing a simulation of a car that can receive commands and act on them and I'm trying to implement it using the command pattern.
class Car {
move() {
console.log('move');
}
}
interface Command {
execute():void;
}
// there can be more commands like this. eg: TURN, ACCELERATE
class MoveCommand implements... |
I am currently responsible for feeding data to an STT model. My backend is written in Python/Django and is primarily responsible for managing a Postgress database. The database has a table that saves data records; each instance, or record, will at some point end up being fed to the model. Each data record has a bunch o... |
Given a class as follows:
class IntList {
public:
IntList(std::vector<int> list) : m_list(list) {}
std::vector<int> list() { return m_list; }
std::string toString() {
std::string repr;
for (const auto integer: m_list) {
repr += "int:" + std::to_string(integer) + ";";
}
... |
Context: we operate in a highly regulated industry (medical), and aim to have automated test cases to cover all of our requirements - allowing us to still release quickly, but safely.
We have a requirement or acceptance criteria that reads something like:
x object should be read-only for users
Editing this object not... |
I have a campaign, which has URL as a child.
If I make a patch request to add a list of 3 URLs out of which first one is invalid URL, second URL already exists in the campaign and we do not want to duplicate the URL and third one is a valid URL which can be added to campaign.
What should server do?
should it return 40... |
I have read through a number of posts on Software Engineering but am unable to find a suitable solution for the problem my team and I are trying to solve.
We are building a system where we have multiple Actors / Personas, for example: an application user, patient, staff member, practitioner etc.
As you can imagine each... |
I have a software application where we have 2 services, say A and B.
A delegates some long running work(tracked by an id) to B which is done asynchronously.
They both talk via HTTP.
Post submitting the job, A periodically does getStatus calls passing the id.
Given that any of A or B can die, I need to handle failure sc... |
Currently I have a monolithic gRPC server that implements several service stubs that are utilized by a large amount of internal client programs (none of this is public internet facing).
As our requirements have gotten more complex and more backends are being accessed by the monolithic gRPC server, I am looking to break... |
I have multiple use cases where I need to call an "entry" function, do a bunch of stuff, and then call an "exit" function. (In my case, "entry" is enabling a chip select line and "exit" is disabling it.)
I'm tempted to do the following, but it seems too obvious. How might this trip me up?
#define WITH_CHIP_SELECTED(.... |
I am developing an algorithmic trading framework using DDD/event-driven principles. I've decided the following components sit within my bounded context:
Data feed -> [Entry Point] -> "HandleData" command -> [Alpha Model] -> Insights -> [Portfolio Model] -> Targets -> [Execution Model] -> Orders -> [BrokerGateway]
Each... |
Im making a website and trying to learn Test Driven Development (TDD)
I'm doing one of CS50 projects, were we need to make a website to trade stocks. I decided to use this oportunity to learn TDD. I learned how to use the unittest module from python. But now, im taking way more time to write the tests than actually wri... |
I want to move my current relational database installation into a docker container or a set of a docker containers.
I have a web server with an associated relational database. I provide a set of 40 web services to my clients. Each service is a derivative of my web application. I use an apache web server. It uses redire... |
I am pretty new to Clean Architecture / Onion Achitecture, I actually not sure if the 2 terms are exchangeable.
So it pretty clear to me, considering is a few days I am reading and study about it.
It get even more clear after have read this one article and Clean Architecture on Frontend.
On that one, actually I use the... |
I have a design question to all the programmers out there.
Until now, I wrote most of my software in vb.NET oder C#, especially if I needed a Frontend.
Now I would like to have a Frontend which is accessible via a Browser, so I would like to use an Apache Server with PHP. That is fine so far, but is it possible to use ... |
I'm writing an app which uses a logger with different logging levels (info, debug, warning, error, etc.); but - I'm used to the custom of writing program output to stdout and error information to stderr.
My question: Suppose my logger uses all of these levels, and that I use the logger to report all errors. How do I co... |
I am implementing a basic ledger system for which I want to calculate costs based on the FIFO system. Is there a more clever method than an O(n) search?
Example
Suppose I have two lists of transactions:
Incoming Inventory:
Date
Batch
Quantity
Price
Jan 1
A
3
5.00
Jan 15
B
5
7.00
Inventory Sold:
Order
... |
I'm developing an application with DDD pattern with three layers:
API
Domain
DB
After adding a new field to the domain object, I realized that many places need to change. Imagine the following model.
type TodoItem struct {
UUId uuid.UUID
Title string
OwnerId string
Project *Projec... |
This is a pretty vague question, but, sometimes, I'm not very good at naming specific tasks, but I know it's very important and I don't want to name it something ungood.
I have the following file structure:
Project/
|-- project/
| |-- Connection.py
| |-- ???.py
|
|-- Tests/
|-- test_connection.py
|-- test... |
In mathematics, adding two functions can be considered an operation in the space of functions. The result is another function.
I can model this by making functions an abstract class and implement all relevant operators for it. An object of that class can be assigned with basic functions (e.g. a constant) and the operat... |
I’m making an inventory for a game using nosql (mongo). I made some ItemType records (contains common data like icon, name, weight) and some ItemInstance records (representing specific items, referring to ItemType).
Now I have problem with mixing static and dynamic data in ItemType table. For example, health potion is ... |
I have a command line application written in C#. Here's some facts about the program that are relevant to my question:
The application has a "data directory" (e.g. ~/.config/myapp) where all user data is stored, including log files.
I use Autofac for dependency injection.
I use Serilog for my application logging (prov... |
I followed the guide here https://quarkus.io/guides/building-native-image to set up a minimal quarkus webservice graalvm native image. Ran command 'time quarkus build --native' to compile the example. The compile time on my laptop was 2 minutes, 12 seconds, the resulting image size was 38Mb.
I then followed the guide h... |
If we implement the following function:
template <typename... Ts>
[[noreturn]] inline bool die(std::string_view message_format = "", Ts&&... args);
We can then write:
if (bad_thing_happened()) die("A bad thing happened!");
or, for example
things_are_ok() or die("Things are not ok, and foo is {}", foo);
I know this i... |
Sometimes I need to use the same use case with different details implementation. It is easy and straightforward for presenters as each use case has its own output port and therefore different implementations.
BUT in the data layer, there are Gateways that have different abstract methods used in different use cases.
The... |
I have been using "Perf" when writing about performance of some pieces of software (in tools, pull requests, etc.) but was wondering recently if this was an appropriate practice.
Can I assume software engineers, both native and non-native English speakers, would understand what "Perf" means in this context?
(And just t... |
So I have a project which does not have any regression test or automated unit tests. We release every week. We use forking git flow which is basically everyone forks repo and pushes their changes in their specific fork.
From their fork devs push to develop branch which is pushed to pre-prod where tester tests it and th... |
We have several C++ projects that use clang-format and clang-tidy and other similar tools. Currently the config files for these tools are stored in each project's Git repository. Now I'm trying to put these files into a separate repository so that they can be shared between all projects, so that all projects use the sa... |
I understand that a SocketTimeoutException (I'm in Java, but I guess it's the same in just about every major language) happens after a server or client doesn't respond after a period of time, let say 10 seconds.
I know it can happen if, let's say, the client sends a request to the server, and that request takes a long ... |
Let's say I was to create a scraper. At some point I'll need to come up with algorithm of identifing whether or not a piece of a newly scraped text matches the one that's already in the DB. How would I check whether those 2 pieces are identical?
If I decided to use a hash to compare them, it wouldn't be reliable becaus... |
The idea is that for each resource we want to dispaly in a grid, there will be one endpoint for data and another for metadata.
The metadata endpoint will bascially return a list of columns and their types based on the POJO being displayed.
From one point of view, I can see the productivity gain with this approach. Howe... |
I have one design problem for one of my projects based on location tracking. The scenario is I have multiple devices(for some business) all over the city and have GPS installed inside, the device is calling the Ping API for updating its most recent location every 10 seconds. I am managing a queue-based solution(RabbitM... |
In my Java 11 / Spring Boot codebase I have enums that don't respect the convention to have all uppercase constants because when we move to frontend the data there has to be camelCase (or even random / weird case).
I am not designing this from scratch, more dealing with something pre-existing.
Here's an Enum example:
p... |
People say "don't expose primary keys from the database in your API" because its a major security leak, so I'm trying to come up with a way for:
RESTful HTTP requests to reference server-side resources without requiring their DB PK
example: I want to update a Widget resource with a PK ID of 293, so I want the equival... |
When trying to follow a functional programming paradigm, I often find myself in a situation where I have a chain of functions that I would want to combine/compose somehow, but they all also take in a similar set of parameters. I've been trying to research best practices surrounding this kind of set up, because it's not... |
I am looking into building an iOS application and using an internally built API to access data. My API has some authentication endpoints that takes in a username and password and, if the login is successful, it spits out a JWT.
My question is, what are best practices for iOS logins such as this? I've been doing some re... |
We have to fork a repository and keep it up to date, with adding changes here and there. The important branches are remote/1.0 and remote/1.1
The workflow currently used is to fork the repository, create our own 1.0 branch that is the same as remote/1.0. Changes are then made that are pushed to our 1.0. Now, we have to... |
I have an endpoint GET home/{homeId}/laptops . Its response is :
{"homeId":string,"laptops":string[]}
If homeID does not exist I can return '404 Not found' OR an empty response with the homeId and the laptops array empty such as :
{"homeId":'homesIdentifier',"laptops":[]}
The client does not really care about the err... |
So I've got a class that calculates a discount (Let's call it class "A"). It has a price fetcher class as a dependency (constructor injection) (Class "B"). The price that is returned (by class "B") is used to calculate the discount. However it is not obvious that class "B" is used to fetch a price unless you go into th... |
I am well aware of a programming-to-an-interface term. That's a good thing! I understand that these allow to add decorators; or perhaps one can implement a service that works faster and by injecting it instead of the original the whole thing would work faster as a result. In all of these cases the end result remains un... |
Our system needs to process PDF invoice files from generic external third parties.
Using HTTP is the most obvious, but this isn't the greatest of ideas in case we need to deal with bulk uploads.
Even when we push all HTTP requests on a queue behind the http controller, when thousands of PDF's are sent to the server as ... |
I have a domain entity called a "Booking Window" that has a Start Date and End Date, and defines a period in which a Member can make a Booking. The business is a mobile car wash, and Members can book a wash every 14 days.
I have a means of establishing the first Booking Window - at the point of the Member signing up. ... |
In many languages, the convention for naming Booleans is typically to prefix them with "is", "has" or "can". This convention seems to be applied mostly to fields and methods (e.g. Java's Scanner.hasNextInt()). Is there a convention for naming a method's Boolean arguments? I don't see the same convention being applied t... |
We are building bot application that suppose to support both Slack & Teams. Both Slack & Team has a single Web hook endpoint which makes the app code tightly coupled with them and hard to make the core business logic verify-able.
Hence, we thought to divide our single monolith into two sub apps. Core & Slack Adapter. C... |
Well, I've been studying software architecture a lot, Clean Architecture in specific and I came across some multi meanings terms and "Use Case" is one of them.
I'd read in some places that we don't have a defined connection with use cases from CA and use cases from requirements specifications in software engineering no... |
So I am learning how to use the factory function in javascript/typescript. I created a to-do list project where I had to pass the instance as a parameter to the function. I wanted to ask is it a bad practice to use this approach
eg
const Animal = ()=>{
const legs = (noOfLegs:number)=>{
console.log(noOfLegs)... |
Let's say we have an undo/redo system and we have a superclass storing an object that should later form a tree of the attributes that can be undone/redone.
This would require every class that should get involved into undo/redo to extend from this one superclass, depending on how big the system grows, this could result ... |
I have a outlining app that I am writing using unidirectional dataflow and some of the concepts from Redux.
When the user has selects items in the outline, and clicks indent, an indent action is fired. This needs to update the state of the app via some complex rules that modify the parent property of some, if not all,... |
Is there a good pattern in microservices systems for delaying the processing of a JMS message until some other task has been completed. Let's say, for example, a message is sent to a topic when a customer makes a transaction. Two microservices receive the event, one of which updates details of how much a customer has s... |
Say we want to write a Java class that represents a fixed-size list. Let's call it Chunk.java (as in, it represents a chunk of data to be processed or sent somewhere). My implementation of this class can be outlined as follows:
A chunk is represented internally by an ArrayList.
It has a constructor that takes as argum... |
I am working on a project that is structured in hexagonal architecture. It is a multi module gradle project where web layer is a separate module that depends on the domain module.
Sample code related to the question:
class InvoiceController(val invoiceService: InvoiceService) {
@RequestMapping(..)
fun getInvoice(co... |
There is somebody else's project (A), a part of which (foo.h) I want to use in my project (B) with some modifications. The modifications make sense only in the context of B, so I can copy foo.h into B and track its changes using B's version control. But in the future, I may want to merge new changes made to foo.h in A ... |
Given:
You have a list of opportunities* that may improve the speed metrics of your website. For example Total Blocking Time (TBT) is one metric that heavily impacts the experience of a visitor.
You've run lighthouse (or any other speed testing tool), which tells you "Estimated Savings" for each of these opportunitie... |
I am learning Domain Driven Design currently and I'm trying to use it on an application that has a complex domain.
The application is fully configurable, meaning that most the domain objects can have most of their proprieties modified by an admin doing configuration work. Although it should happen rarely and mostly whe... |
I have the entity class.
@Entity
public class User {
@Id
@GeneratedValue
private long id;
private String name;
private String lastname;
@Column(unique = true)
private String email;
private String password;
//getters and setters
}
I use the following class to fill it.
public cl... |
Context
To level set, I've been working with OOP and FP for my whole career, so my experience with the imperative paradigm is limited. The team I joined is made up of very senior (20+ years xp) imperative programmers using a domain specific language - think Pascal. The team is challenged to try new things (not the focu... |
So I want to inject an Application Client, say a Rest Api client, in my code. In order to create this client I need to go over the network to get it's user and password that is in a HTTP Vault.
This behavior got my team divided, some saying it's an anti-pattern to go to the network before finishing injection, some othe... |
If for example we have a user, project and a task service where a task is assigned to a single user and user can be part of multiple projects - how can one enforce a rule so that one cannot assign a task to a user that is not part of the project?
For example, a POST request comes in to /tasks/1/assign with this data:
{... |
Well, we all know the main concept of TDD: write a failing test, then implement the testing component to make your test pass.
I've been working on a personal project in Clean Architecture following TDD, and I'm gonna start testing some basic use cases that just CRUD some entities. These interactors classes use presente... |
Problem
I am currently working with a class that necessarily has a very complicated initialization function (>350 lines of code) given that many computations and attributes need to be performed and defined.
I am considering using either helper functions within the __init__ function of this class in order to make the co... |
I am learning about Dependency Injection and I have been recently implementing the following classes for an app that executes commands over ssh using Python. I am confused about whether I am using it in the wrong way.
I am using a ConnectionFactory class to create an ssh object that I call dynamic, because it depends o... |
With the introduction of the slash character to specify position-only arguments, is it recommended to put a slash in every method after the self parameter?
For example:
class A:
def something(self, /, some_arg):
Many built-in objects seem to do so (see range, str.encode, etc.).
Is there some sort of advantage (may... |
In polymorphism, your base class defines an interface. The inheriting classes fill in the data for that interface. The key is that the interface remains the same.
Given that, if your interface is properties/attributes (not methods), is it more appropriate to override a getter, or to simply define/overwrite the attribut... |
We are looking at implementing Multi-factor authentication for our application, using Time-based one-time password (TOTP) algorithm.
What we want to achieve:
Users should have the option to enable Multi-factor authentication
for their account. Once enabled, they will be prompted for the
Authorization code (which they... |
I'm currently working in a firm, based on an executable, who uses different DLLs. There are several issues:
Everybody builds the binaries on his own PC.
The executables (*.exe and *.dll files) are not (as I call it) signed.
Signed? What is that?
I mean that, from the executable file, it is impossible to retrieve the ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.