instruction stringlengths 34 36.1k |
|---|
So I've been going over some design patterns and I came across this discussion
https://stackoverflow.com/questions/43565475/using-lists-instead-of-decorator-pattern
I've been thinking that in all honesty I can always replace a decorator design pattern with an ArrayList of methods that I can activate in the order of ins... |
Suppose I write a function with the following declaration:
void sumAllBytes(const ByteArray& bytes);
I will use Qt as an example because that's what I'm familiar with; but I am asking about the general concept.
For those familiar with the Qt framework, it provides a QByteArray class. I want my code to be able to work... |
What is the best practice, for creating a template repository, and then creating n projects based on that template?
With "template" I mean: Let's say the template site is x. So x is a site with features that many new sites will have in common, and would want to utilise. For example, features like login, authentication ... |
I am working on a form building feature that will be used across different applications within our organization. Since each app has a slightly different stack we are planning to implement this feature as its own service. It will be hosted separately from our other applications with its own isolated database. I am prett... |
When writing tests for my FastAPI endpoints I am not sure which is the best way to setup the test (store data in the DB, prepare data for the body of a POST call, etc.).
I can either use:
direct calls to the DB to set it up (SQL)
methods from my Repositories (Repository Pattern)
other endpoints to get tokens, prepare ... |
I'm attending a software engineering class at my university, and my final consists of a fully-documented desktop application to be built in a four people team.
While designing and coding this software, there's a question that always pops in my head, since my professor keeps repeating that everything that happens in cod... |
I am designing a new process to request service accounts. I am in charge of both, the process design and the technical implementation of the request & creation flows. I am new to BPMN and currently learning as I go.
The process starts when an employee requires a service account. The next step is that the employee fills... |
I have this object
RelativeFoo{int relativeCode, Origin relativeTo}
And I want to map it to this other object
AbsoluteFoo{int absoluteCode}
In order to do this, I need to use a service whose implementation calls an external API
AbsoluteFoo absFoo = fooProvider.obtainAbsoluteVersionOf(new RelativeFoo(1, Origin.BAR))
... |
Should I use separate actors for "Video Watcher" and "Channel Creator," or a single actor called "User" that represents all users of the system?
i have a webapp where user can participate in an event and user can also create their events and manage them i cant find an answer should i use separate actors organizer and p... |
I'm looking for some guidance around REST design for user account endpoints. I generally understand REST and some of the principles involved, with paths being used to fetch items from a resource:
/user/{id}
This is generally fine, but I've run across a design problem that could have two options. In many API's I've se... |
Similarly to a sports team chemistry or even a better example would be fifa ultimate team chemistry where putting certain players in the team would improve the team's overall chemistry
Say there are around 20/30 possible players
How would i go about doing this with examples like this:
player A, player B add to the team... |
(FYI: I asked this question on stack overflow and was directed here)
My problem is as follows:
I have a dashboard running on a server at customer premises which updates every 15 minutes
The dashboard has multiple views
The dashboard has hundreds of KPIs (key performance indicators)
I want to replicate the dashboard at... |
I have a Product entity:
public class Product
{
public int Id { get; set; }
public string? Name { get; set; }
public string? Description { get; set; }
[ForeignKey("Brand")]
public int BrandId { get; set; }
public Brand? Brand { get; set; }
public List<ProductVariation>? ProductVariation... |
Overview
I am tasked with designing a system that serves as an Interface between a User and one or more microcontrollers in different Variants.
As an example, our Microcontrollers Type 1 are milk frothers. They heat milk to a preset temperature, also they spin a little circular spring to make the milk foamy with varyi... |
I have the following dilemma with designing a piece of software.
How can I design a relation between the follwing entities so that a configuration rule can be global or apply to a building / room or a combination of buildings / rooms?
How should the result data
I think I should use the following entities:
Configurati... |
The Microservice arcitecture is still a new thing for me to work with, so it gives me some unanswered questions.
In my case each MicroService has its own database.
I need a UserService to handle CRUD operation for users.
Lets say we have a User table with the columns Id, Name, UserTypeId and a UserType table with the c... |
I have recently developed a small module that performs queries against a database. At the end of each test that contains code performing modifying queries against the database, I added an assert that checks that a record irrelevant to the query did not get affected. My reasoning is that I want to prevent a future deve... |
I have read many blogs and stack exchange posts about global state (usually) being bad practice. I'm now trying to avoid this where possible in my code, but I'm running into a case where I don't know how to avoid global state:
Suppose I have a task which handles events. If I want to count the number of events it proces... |
Suppose I have a std::span-like type, that represents a matrix or an image, or a class modelling a 3d mesh. I would like to say
template<class T>
class 2d_span;
class 3d_mesh;
But that would obviously not compile. What to do instead:
Use exotic unicode symbols. They are sometimes hard to read (depending on font), an... |
I'm developing a web game that currently all runs on one server. It uses SignalR to maintain connections between the server and clients, and the server also sends all the web stuff to clients (HTML/CSS/JS/etc.)
I've been thinking about how this would scale up if many more clients were to start using the site. Reading... |
I know that a lot of interpreted higher level languages like to abstract a lot of things and therefore cannot directly be compared with lower level constructs.
For example in some languages primitive values are implemented as references to value-objects. Most famously in Python.
When I learned programming, I was taught... |
I am currently working on my own iOS application and am going to be using a locally developed API for fetching data. I wanted to outline my current account sign-in architecture and verify this is correct and can prevent as many security holes as possible.
I will be using Patreon OAuth to verify the person logging in is... |
I was working on a small CLI tool to convert between time units and seconds.
Someone filed an issue about how the code was treating a year as 365.25 days while the Gregorian year is supposed to be 365.2425 days, where 'day' is defined as 86,400 SI seconds.
Upon further research, I stumbled onto the concept of mean trop... |
I have a gRPC service and I was thikning about the security aspects in the client side.
I have only one certificate (public and private certificates) for the client, that it is uses for all my clients, WPF clients, Android clients... etc.
By the moment, in my WPF client application, I copy the certificates (certificate... |
This has erupted from quite a turbulent meeting between two senior developers, a lead developer and an engineering lead, and after 90mins reached no resolution.
We create Spring Boot Java services which are then dockerised before being deployed to an environment.
As part of our automated build our services are compiled... |
I have been going over our app web api and making sure all async work is async all the way - and no artificial asynchronicity is enforced.
Say I have the following web api controller:
[HttpGet]
public async Task<IActionResult> Foo()
{
//no async work
return OK(...);
}
I planned to remov... |
The company I work for is maintaining and developing a web application that uses many Node.js packages. A lot of these packages are really outdated. I can intuitively understand that it is good to keep packages updated but I was looking for concrete reasons as to the benefits of updating such packages.
What are the var... |
I'm trying to know if we can freely raise new exceptions when maintaining methods of a versioned library.
Here is a minimal example of what the change could be:
import logging
def check_id_old(identifier):
"""
:param str identifier: An identifier that's less than 10 characters long
:return: a verified ide... |
I'm trying to find the best solution to abstract the return type of the service layer.
I have a controller that calls a service to create a user. The service calls a REST API and receives an HTTP status code (201, 400, 409 ...). I don't want to return the HTTP code to the controller to keep the application loosely coup... |
I've been tasked with refactoring/simplifying the architecture of a (relatively) large node.js codebase and it makes ample use of global variables. I don't have much experience with javascript so just wanted to get a general sense of whether this is indeed super confusing and bad practise or if I'm in the wrong.
Here's... |
We store data – some kind of metadata like car manufacturers or types of computer parts – in one of our applications.
This data changes rarely. Let's say it changes once every two weeks.
This data is also relevant for other applications in other domains.
We now want to make this data available to these other applicati... |
My task is, I think, pretty interesting, if a bit unusual. Any number of threads can call function f(). They add some data to a buffer and begin waiting (the function is blocking). Eventually some extra processing has to be done on the whole buffer, and all the previous calls to f() wait for this processing. Either the... |
I have a Azure Web App that generate different types of notifications. At the moment, every notification is written in a queue. A queue function I call scheduler read the notification and redirect it toward other functions. Each one of those functions generate a type of notification: email, push, sms.
I have different... |
Given:
Let's say I have 3 objects A, B, C that form a cluster. Each unit (A,B,C) is independently tested with mocked collaborators. The "integration" is the call to A that calls out to B and C based on some conditions (e.g. either both are called or only B is called, say).
Testing Approach:
Unit test for A relies on m... |
I work on a survey that has a lot of questions. This means we have a lot of columns/variables to work with. This translates to a lot of conditionals that have to be done a certain way according to a specification. The implementation in the code can be different, but it has to map to the spec. We are moving toward Pytho... |
We're all too familiar with waiting for compilation, especially on large projects.
Why isn't a thing to interpret a codebase for quick iterative development instead of generating code for a binary each time?
Is that because if we are compiling at -O0, most of the compilation time comes from parsing, so it won't matter ... |
We have 2 vehicle types in our system Car and Bike. Both can be associated with a Report.
There are components in our system which operate on Report but when dealing with the report they need to check if the report is for a Bike or for a Car.
I'm trying to decide between these 2 options
Create a report type for each i... |
Really dumb question. I really like the new feature called "optional chaining" in JavaScript, and it's used in quite a few places in my front end code. However, I am concerned that whoever maintains JavaScript, maybe Mozilla Foundation, will remove this feature in the future, and my code will be broken. Is that likely?... |
Let's say that there are two products, product A and product B.
Product A is a desktop product that customers download and install locally on their machine. This product follows a typical versioning process where quarterly releases are sent out to customers to install at their own discretion. For example, 2023.05 woul... |
I created a simple parser in Rust and defined the AST like this:
enum Expression {
Number(i32),
BinaryOperator(Box<Expression>, Operator, Box<Expression>),
Identifier(String),
}
enum ProgramLine {
SetIdentifier(String, Expression),
Print(Expression),
}
struct Program {
lines: Vec<ProgramLine>,... |
In a Flutter app I'm developing, I have a class hierarchy of model objects of a certain base class. To take a typical example, the abstract base class could be Vehicle. Then I have a (pretty much) parallel hierarchy of widget classes that show info about a particular subclass of Vehicle: Car objects are shown with CarW... |
Web browsers are imperfect machines.
So let's say you came across an error. You might search your code to find the problem, and then failing that, you turn to online research that indicates the error isn't because of an error in your code but some error or other unexpected quirk in a correctly-configured browser.
Your ... |
See "Note" on second page:
This convenience gave rise to serious inconsistencies and was removed several years ago
The book was authored in 2003.
What exactly does it mean by "Serious inconsistencies"?
Was a compiler flag for backwards compatibility created?
Did this behaviour also exist in C?
|
Context ( You can skip )
I will be doing a presentation on Python, and will be touching upon V3's decision to be intentionally backwards incompatible, and how that has affected Python long term. I will be examining in particular their decision to remove the print keyword, because it was a decision that was not strictly... |
I'm trying to understand why anyone would prefer Floyd-Warshal over Dijkstra:
Dijkstra gives a correct result, using an understandable system, combined with backtracking.
Floyd-Warshal makes an entire list and filters in there.
The only thing I can imagine, is the case of enormous graphs, where Dijkstra only gives a ... |
I'm refactoring some old code, I have a lot of istanceOf in the business part:
if (record instanceof RecordA) {
RecordA recordA = (RecordA) record;
//mapping to recA and other stuff...
recA_dao.create(recA); //save a copy of the record to the d... |
I am building a consumer application that reads messages from a queue and runs basic sanitization and deduplication and persists them to an RDBMS.
The functional requirements are
messages must not be lost
Validate and sanitize the arriving messages before persisting them.
Invalid messages go to the database in an erro... |
I am working on a simple library that will help me work with prescription drugs. For instance, DrugBank contains a list of FDA approved drugs, and, importantly, how these drugs interact with one another. So, for instance, we might have drug A, which might then interact with drugs B and C in some way.
In a previous proj... |
At deployment time, I register my microservices in the following way:
They register themselves in Keycloak to have an identity as a confidential client;
Then they call an endpoint on a dedicated internal microservice "AUTH-SRV" that grants them the appropriate permissions/roles;
They also register themselves with the ... |
I'm learning about Big O notation and how it relates to computer science and I understand the sentiment behind Big O, however I'm struggling at understanding how we define a "step".
In the book I'm reading as well as a lot of different articles they use something like below to express an O(N) example since, as N increa... |
.NET Boolean type usually makes if else pair all over the code.
Functional Boolean should be more like Either type. Ideally represented as Either<Unit, Unit>.
However, my issues with Either type are the following:
Either<Unit, Unit> verbose, ideally it should not be generic type
It is not communicating clearly that Ei... |
Suppose you are given a python API:
def onArgumentReceived(x):
doWhatever(x) # expects a unicode string
I am not a security expert by any stretch of the imagination, however on the face of this, without explicit checking, this just instinctively feels like an obvious place to find a vulnerability laid bare.
Wherea... |
I've read that you should pass in an interface instead of a concrete implementation so that the consumer doesn't need to know anything about implementation details.
I don't understand how injecting a concrete class exposes implementation details?
class ServiceA() {
private something
public method1(){
res = ... |
I have an app written in java and using mysql as DB. I need to create a coupon distributed system where I have 100 coupons stored in DB and the first 100 customers who login should get those coupons. With a single server its pretty straight forward I think, but how do I implement this where my application server has mu... |
As part of an university project I am currently working on an eeg-biosignal classifier. While the project itself doesn't really focus on design ("anything that works") I am trying to learn and apply some best practices.
Some Background
The experimental setup is essentially as follows: A subject sits in front of a scree... |
I have read several discussions about storing BLOBs in the database vs in an object storage. What I need in addition though is a functionality for querying these BLOBs. The BLOBs will be immutable compressed multi-dimensional arrays that will be 10s of MBs. I mention that, since they are not files that will be served, ... |
I have an application that employs "zero knowledge" data security, where even with full backend access to our application, customer data cannot be read without knowing their individual passwords. I use what I believe to be a fairly standard method for this: password, after hashing, protects a data key; password change ... |
Is inheritance in use case diagrams between actors limited to one specific diagram or is it applies to other diagrams too? e.g. I got 2 actors let's say Actor A, Actor B. I got also two use case diagrams lets say Foo and Bar that show some use cases (Foo got 3 different use cases than Bar, Bar got 3 different use case... |
I'm looking at creating my first packages to clean up my codebase.
Below is a very simplified version of my current project structure:
my_project/
|-database.py
|-app_1.py
|-app_2.py
|-constants.py
To explain each one a little bit:
database.py - all the sqlalchemy orm table classes used by app_1.py and app_2.py
app_1... |
I have a complex object that has several fields can be updated until it is locked.
Is it proper to save this locked entity as another entity which has no object child, only string data.
complex object
{
Student student;
Teacher teacher;
Address address;
//...
}
after it is locked. this information will never chang... |
Due to the previous supply chain issues, I currently have multiple variations of a particular sensor that performs a function in my design. Each of these variations have their own library associated with them, however, they all use the same functions names so that it's easy for me to swap between variations when sensor... |
Advice on unit testing is often focused on publicly exposed classes. What about cases where the only public class is simply there to instantiate internal classes? Should the internal classes be unit tested, even if they are not exposed to the outside world?
My intuition tells me that the internal classes are doing the ... |
From what I understand of DDD, my entities and value objects should be able to enforce its own invariants, meaning that its constructors will check for nulls, must contains numbers and letters, whatever else. In this way an instance of a domain object will always be valid.
And from what I heard, if my domain throws an ... |
In Software Engineering by Pressman:
The steps in continuous integration are:
Check out the mainline system from the version management system into the developer's private workspace.
Build the system and run automated tests to ensure that the built system passes all tests. If not, the build is broken and you should
i... |
I'm struggling to understand how to improve the performance for an HTTP Request that comes with a huge body.
Now, let me explain better what I mean with performance!
Imagine I have a DB with the table "User" that contains 100k elements: if the client wants to visualize all of them, we can:
Send 100k elements all toget... |
I'm trying to build a simple compiler for a subset of the C language in C. To achieve this, I needed to figure out a way to represent the grammar symbols. Basically, each symbol can either be a "terminal" or a "non-terminal". Each "terminal" must be associated with a string that can be recognized by the lexer as a lexe... |
I am trying to design a schema for pairing styling data with text. However, I need it to pair styling metadata to only one part of a larger string.
For example:
"This is a test string"
I want to style This as italic, and test as bold.
The question is, how do I efficiently designate subsections of this string as being s... |
I have the code but I want to be pseudo as possible so I learn from other ways as much as possible.
So what I am building is web based tool and in one section we have a table.
This table renders lines of data given it matches conditions.
So the way it works is user enters a number and based on that we out specific line... |
I was thinking how to design a simple cards game, like poker, in a DDD way, but I am not sure about some points.
Basically what I want is this, but I will try to simplify the problems that I have.
I have a match in which I can add players.
A match is played in 10 rounds.
Each player play in the round in its turn (for ... |
Say I have a ReactNode post:
const Post = (props:{content:string}) => {
return(
<div>
{textProcessor(props.content)}
</div>
)
}
the role of textProcessor is to 1. to sanitize the text, and 2. to identify links and inject html to highlight them.
const textProcessor = (content:string) : React.ReactNode... |
I'm a software engineer by trade, yet I am shocked and fascinated by something I learned just recently. For example, I found out Facebook has businesses and sites share information about my activity on their sites with Facebook. Many sites do this including ones I would not expect. Sidestepping all other types of moral... |
I am developing an API responsible for returning the distinct searches made on a service given a date prefix.
Example data:
2015-08-01 00:00:18 %22http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DeYbdd2ChagY%22
2015-08-01 00:00:19 %22http%3A%2F%2Fwww.dnb.com%2Flc%2Fcredit-education%2Fbest-in-class-risk-management-strategy.ht... |
I have an endpoint that teachers can use to invite students to a virtual classroom by providing their emails in a list format. Let's call it POST invite-students. I have these four resources:
api/v1/virtual-school - includes endpoints for inviting teachers and editing their permissions
api/v1/virtual-classroom - inclu... |
I have a batch endpoint of the form
POST /entities
["id1", "id2", ...]
Where the endpoint takes an array of ids and returns a batch response.
Now I want to set a maximum value to number of the entities to prevent service from processing huge requests. But I am not sure if this belongs to the controller or service lay... |
I coudn't find a better phrasing for my question and hope it is not too confusing.
my question mainly targets the open/closed principle and extensibility of my program.
I tried to condense everything as good as possible.
Brief Overview
I have a program that acts like a test bench. For a given system, I have several Ite... |
I'm designing the architecture of a platform to introduce a message broker in an existing data collection web application.
This web application is currently used to upload data from excel files that are then validated, processed and inserted into a database. Every time a new set of data is inserted we should run one or... |
I am facing a bit of a conundrum with how I can structure my application, as I try to balance speed, cost, and efficiency.
I currently have a website, algfinder.com, which solves states of rubik's cubes. The computation runs purely on the client, and can sometimes crash on mobile devices due to too large of memory dema... |
First question here, so preemptive apologies if I've committed some faux-pas. Additionally, I am aware that this question is about possibly the micro-est of micro-optimizations ever, and "micro-optimization is the root of all evil" and all, but this question has been stuck in my mind for the past 3 weeks, and at this p... |
I am creating the backend of a microservice that will serve as a tool to see in real time how the company's employees are distributed by projects and what days they have assigned to each one. The database I have raised looks like this:
ModelType = TypeVar("ModelType", bound=Base)
CreateSchemaType = TypeVar("CreateSche... |
I'm designing a small platform based on a series of event-based micro-services. The persistence storage I'm targeting is (the managed) Amazon PostgreSQL (Amazon RDS for PostgreSQL) — although I can go with Amazon Aurora as well.
Basically I'm trying to avoid sending events programmatically within the system. Previously... |
I am currently looking for a way to encode a list of random numbers most efficently (as in length).
To be specific, I have an array of 11 numbers containing each number from 0 to 10. The order will be randomized, and I need to get the smallest possible representation of these orderings.
I am currently trying with the f... |
As shown in the following image, I have two different branches with their corresponding PRs (PR1 and PR2). The top arrow is the develop branch.
PR2 is build on top of PR1. PR1 is build on top of develop. Keep in mind that I also compared PR2 to PR1 in the Github UI.
Now, at some point in time as shown below, I needed s... |
I have a legacy project with many classes with high coupling, and I have a necessity to test some of them. So, I decided to introduce dependency injection principle but stumbled upon where to create dependencies.
class Context
{
ICallManager* m_pCallManager;
public:
Context(ICallManager* pCallManager);
...
};
... |
I am having trouble naming and thus searching for the right keywords for a pattern I am seeing in my web applications and their associated difficulties. Here are some examples of the pattern I mean:
CMS: A page layout can have various regions in which editable elements can be added. Some of these elements might need to... |
I'm looking for some guidance on a design proposition I have to accomplish the following use case:
We have several small microservices that each generate a unique set of "analytics" or attributes about a customer
We want a consolidated interface for partners to request each set of analytics, e.g. via a REST call POST ... |
I work with other Software Engineers on a web app product. Also, the source code is hosted on GitHub.
Recently, there was an introduction of a Continuous Integration procedure enabled by a script written as a yml file and GitHub Actions.
After every Pull Request on GitHub, the CI script checks if the new code is breaki... |
First of all, I am serious :)
You have array of N elements and we can compare them (e.g. operator > works).
Let's try to (unstable) sort it using following brand new sorting algorithm.
First, consider "smart" optimized bozosort - you choose 2 array elements at random, you compare them and only if first is great than se... |
We are planning on building a desktop application with a few web components. I want to know how resilient is this architecture.
Essentially the design looks like
Mixing web components with desktop applications is possible, but the backend server is running on localhost. Is this a good idea?
ZeroMQ is a distributed q... |
I work with other Software Engineers on a web app product. Also, the source code is hosted on GitHub.
There is a behavior pattern that I do not understand. Some co-workers push branches (adding features or fixing bugs) as standalone branches, without an associated Pull Request.
I do not understand this behavior. I can ... |
I'm working on an implementation of the "log transform" operator on an image for C++, and we currently have it formulated as follows (python code). Note we use log10 instead of the natural log.
def log_transform(mat: np.ndarray, dB: int = 40):
mat= 255 * (20/dB * np.log10(mat/ mat.max()) + 1)
mat[mat< 1] = 0
... |
I've seen similar questions but in this case the code deployed to all stages (local, dev, staging, prod) will be the same.
The idea is to have a special field on one particular request, something like isTest that would allow a certain endpoint (consumed by a web client) to perform a DELETE action that otherwise would f... |
What's the cleanest and most coherent way to assign a new value to an object field when the calculation of that value is outsourced to another method?
The most obvious way would just be to update the field value when it's calculated in the method, as so: [examples in Python]
class MyClass:
def __init__(self, arg):
... |
I have a C++ component that contains important data that needed from various other components in my program.
The component might contain its own task or not. But in either case it will also hold the data in structs or classes.
The other components that will include the component in question might not need all the data ... |
Having a poor knowledge of the extended features of the available message brokers, I was wondering how to approach this.
We have some environments where only RabbitMQ is available, others where RabbitMQ and SQS are available.
For scalability reasons, we would like to be able to use SQS on environments where it is avail... |
I have consumer pools that consume only events matching a specific attribute (e.g. origin=WINDOWS, the other origin=LINUX).
Since ordering is important (ordering is based on instanceId, so this is the partition key) and the throughput is very high, I'm using one Kinesis Stream for each pool (SQS High Throughput might a... |
I am looking for a solution to load a Java Keystore dynamically from memory instead of from a file on disk. Can you suggest any libraries or best practices for this scenario in the context of Java, SpringBoot, and Docker?
|
Context: I'm not employed as a software developer. But I do hobby projects pretty regularly, and I was curious if application dependencies can be super varied during compilation and testing (if all developers are compiling their code locally) between 2 or 3 developers. Unless there is a cloud-hosted solution that has a... |
I currently have a nodejs(nestjs) app, and a postgres database. The database has a maximum connections available as 1700, and I'm trying to spike a 1000 request in a single instance of a second. The test takes about 4m to complete in which the app/database resources aren't consumed very much (CPU/memory), and I analyz... |
KAOS is a goal-modeling strategy that is widely taught in the academia.
I have seen that almost no known diagramming software supports it except objectiver, which was developed by the same group that invented KAOS.
Is it used in the industry? Are any FAANG/Fortune 500 companies using it?
|
I need to generate grid shells for a given level. For example, the 2d grid "shell" at level 0 is just the cell (0,0).
The level 1 shell would be every cell surrounding (0,0), the level 2 shell surrounds that one, etc.
The formula for the number of shells at each level is 8*level for each level above 0, and 1 cell for l... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.