instruction stringlengths 34 36.1k |
|---|
I have been struggling with how to create an "object-oriented" cross-platform abstraction.
In C++, a class requires a certain amount of coupling between its interface (i.e., public methods) and its implementation (i.e., private methods and data).
There are a few design techniques/patterns that I know of to somewhat sol... |
Given the following hierarchy of objects: a keyed collection of ClassA objects, where each ClassA object contains a keyed collection of ClassB objects and each ClassB object contains a keyed collection of ClassC objects.
No suppose we start out with the root collection of ClassA objects (called a_objs) and we want to l... |
I'm working on a game prototype: I have a Cell class which, given a mouse click on its collider, can raise an event that should be listened in two different modules: Camera and UI.
The Observer pattern implementation that I generally use follows this diagram:
But in this case it seems too tight and I don't see a simpl... |
I am currently drawing a "C4 Containers" Architecture diagram using C4 Model. The Core Software System of System Context diagram is now exploded further into the Containers diagram (should I say it is a Zoomed-in view?).
I have a few software systems that are external to this Core Software System but still part of my ... |
Imagine a situation where out of 5 state implementation classes the implementation of a method only differs on 2 of them (i.e. 3/5 share the same implementation for a particular method).
This situation can be handled in a couple of ways when the generic State is an abstract class rather than an interface:
The abstract... |
Our team has not had dev and test environments since it started 2-3 years ago. We had decided to give this (creation of dev and test environments) more priority.
Current Environment
One production environment with outdated software (OS, programming language, tools) - but security patches are regularly installed
5-6 de... |
I am using django to develop a turn based chess variant. I just finished using django-channels to create a lobby and match 2 players together. Now, I need to make them play each other and I'm thinking about what the best way to design these interactions is.
The first idea is to have each client store their own state, ... |
I am working on a small suite of enterprise applications, and I am trying to determine the best way to make them more consistent and maintainable across the board. The applications are .Net Blazer Server apps in C# with SQL Server Dbs using Entity Framework Core, but the question I have is more relevant to db structuri... |
I encountered the following situation: I have two modules, TokenService and Wifi which are initialized from main(). The modules themselves don't know of the existence of each other and function completely independent, yet they need access to the same global resource which in this case is the nonvolatile storage flash, ... |
I am looking to see if there is a general design pattern or strategy to handle a use case I see often in our codebases. My best attempt to generalize this use case is "Map permutations of n parameters to a specific value, and look up the appropriate value when provided those parameters."
Due to high cardinality of some... |
What are the rules about acronym usage that are related to the business ?
I always hesitate between using the acronym or not. When talking with people who work here they will understand faster when I use the acronym. On the other hand using the full name helps me when I still need to learn what the acronym means.
For e... |
I have a multi-threaded application.
There is 1 thread that produces a resource and puts it into a queue and many (not constant amount) consumer-threads that get the resources from the queue.
When there are no more resources that the first thread procudes, the first thread must terminate the queue, that is, notify all ... |
Why is it necessary to have an instruction set for processors and controllers? Can't we simply convert high-level language programs, like those written in C, directly into binaries without the need for an instruction set?
|
I have read this article which indicates a double tuple structure, but it is unfortunately light on implementation details, which is what I am looking for.
So... how are interfaces implemented in Go?
Pure guesswork on my part:
It cannot be a v-table in the C++ sense, because the interface is implicit - a struct doesn'... |
I am learning about building a language VM with the long-term goal of writing an own language.
For guidance, I am looking at this LC3 tutorial by Justin Meiners and Building a Language VM by Fletcher Haynes. (I have also previously gone through the Nand2Tetris course).
In the LC3 approach, I note that the opcodes and t... |
Context
After creating a (bash) CLI interface that creates self-signed SSL certificates (for onion domains), the user can choose to re-use some of the data that is created in past runs. For example, a self-signed root-ca may be used for multiple services, which may be created in separate runs. Another example are onion... |
There is a software (once monolith) that makes use of a long list of mappers. You can think of them as Choices field, where each item translates into different conventions.
For ex, say that they are JSONs of all unit systems (weight, distance, storage, time, temperature etc) and their different standards (metric vs imp... |
I just finished a discussion with colleagues regarding the use of exceptions in code. Here is the code (pseudocode) that they had written:
resp = fetch(URL)
if resp.status_code != 200:
return False
I suggested that they use the below (pseudocode):
try:
resp.fetch(URL)
except HTTPError as e:
logging.info(... |
Often I want to open a new window from within some view.
I see opening a window as view logic. So I don't want code in my viewmodel that creates/opens/changes Windows or anything else that
interacts with view-things directly.
When I've got a feature like a button that opens a Window when clicked, I do it as follows.
I ... |
This is just a simple code-style question. Imagine you're writing a function in language 1 that is supposed to be called from language 2. Should the function follow language 1's style guidelines or language 2's style guidelines?
For example:
// This file is written in language 1
// Language 1 uses `PascalCase` and lang... |
I work with Computer Vision applications, mainly in Python and C++. Recently, I get involved with a customer that wants to create a UI based on React JS to visualize the results of our software in real time.
I have an object detection software that will read the streaming of an IP Camera, and apply the AI model to dete... |
In the python docs, I read this about the ABC (abstract base class) meta class:
Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class.
I don't come from a strong technical background so can someone explain this to me in really simple terms?
I have an ABC, which repres... |
I've created a backend following a microservices architecture and now I need to implement logging.
my understanding
After reading some articles about this topic, I've listed below some "pretty good practices" (correct me if I'm wrong):
each service logs to the standard output
In a single microservice, logging must hap... |
I'm doing a project to teach myself more about MongoDB and ASP.NET development and I am stuck. The project is a mockup of a JobBoard website, where Companies would post offers for potential Employees.
I'm stuck near the part where I want to implement the requirements for the job. I found a very cool looking system on o... |
I'm using FastAPI and in my schemas (that is, serializers) I have something like this:
from pydantic import StrictStr, BaseModel
class Str255(StrictStr):
max_length = 255
# my schemas:
class CatSchema(BaseModel):
name: Str255
owner: Str255
age: int
The reason I use Str255 is to apply DRY, by avoiding t... |
Context
I have a multi-tiered architecture that contains 2 presentation layers, one business layer and one data layer. See image below for a visualisation.
Here you can see that there are two components (applications) inside the presentation layer: App 1 and App 2.
Currently, I deploy all of these layers 'monolithical... |
After much hard work, I've convinced my manager that some absolutely awful code needs refactoring. As with any project, they've asked me for a time estimate and I've found myself stumped. How can I estimate how long a refactoring project will take?
Answers/comments have proven the following points to be relevant in my ... |
In C you cannot assign arrays directly.
int array[4] = {1, 2, 3, 4};
int array_prime[4] = array; // Error
At first I thought this might because the C facilities were supposed to be implementable with a single or a few instructions and more complicated functionality was offloaded to standard library functions. After al... |
Suppose that the following are true:
You believe that unit tests should be atomic. That is, tests should always test exactly one thing.
You have written a CRUD app in a general-purpose language such as C#. In particular, the app can Read and Update.
Your app stores all data on a SQL server. Your language therefore nee... |
I'm writing a small card game with a friend and as of the last year I worked with DDD and love every minute,
So it felt natural to me to use DDD for our core domain logic of the game.
Doing a little bit of research on best practices to integrate DDD with game logic, I stumbled into this question : Domain Driven Design... |
Currently, my repo contains application code and what I call non-functional files, which include deployment scripts, README file, build system requirements, dependencies etc. These files are released as part of each release so that other developers could completely rebuild the environment if needed.
My project follows ... |
This post assumes, that dtos on the UI side (SPA) could be viewed as business objects in almost all cases - except that the business logic is missing. I'm fully aware that a dtos first responsibility is to represent data that was send over the net. In a lot of cases though these object are almost identical to business ... |
In the web development application context, when someone says resolver, they talk about getting the data and modify it and then return it?
What about adapters? are adapters essentially resolver connecting data to a different formats? If you talk about database adapters, what does that mean?
|
I am working on a huge code base (more than a million lines of code with a sophisticated architecture) written in C++ over the span of a couple of decades. The task on which I'm working at this point is understanding the use of a specific class whose functionality is unknown to almost every developer of the team. The r... |
Many resources in the REST API I'm designing have a graphical representation. My fist idea was to include the image URL into the resources:
Resource1:
type: object
properties:
image:
type: string
format: uri
Same for Resource2 etc.
The problem is it's not always the same URL. Web clients want an SV... |
I would like to draw a flow chart for a recursive call function whose return value is used, the real function is much more complex, but very similar on the basic idea as following:
List getDigit(Integer arg) {
List<Integer> result = new ArrayList<Integer>();
result.add(arg);
if (arg != 0) {
result.addAll... |
My Domain layer contains below model:
public class ApiResource
{
public bool Enabled { get; set; } = true;
public string Name { get; set; }
public string ClientId { get; set; }
public IEnumerable<string> HandledScopes { get; set; } = Array.Empty<string>();
}
Later, the Infrastructure layer uses EntityF... |
If I understand the UML 2.5.1 spec correctly, the definitions and constraints for UMLClassDiagram and UMLComponentDiagram are identical and furthermore the set of things those diagrams may show are identical.
So whether I call a diagram a class or component diagram is a matter of taste and clarity.
Have I missed someth... |
I've been learning C recently.
I've completed a number of coding challenges on websites like codewars in C, and I always find myself wishing I had something like Python's flexible data structures. In fact, I usually end up creating a poor approximation of them.
This got me thinking, first of all, do people have boilerp... |
I'm designing my service layer for a GraphQL API and there are many situations in which I can't decide if code relating to a table should belong in it's own class, or the class that 'owns' the data. For example, I could have a user class which can get a users appointments, products, etc...or I could have two classes: A... |
I have a testing project, in Katalon Studio, that uses data classes, called models. This is a conscious design decision.
Also a conscious design decision, is the decision to separate the concern of creating models from the concern of the test(s) that uses them. For this, for the most part, I use model factories that ha... |
I am writing code that will assign entities to transaction. Each transaction has a counterparty entity.
Requirements
The entities should be (de-)serialisable (from pydantic models into JSON and vice versa)
Individual entities will be stored in a database
Entities have some hierarchy, e.g. a Supermarket is a type of Co... |
In our company, there is no standard for how to document APIs. Missing API documentation slows down the development process.
Therefore, we want to introduce OpenAPI.
We want to use code generators to ensure that the OpenAPI specification is up-to-date and to ensure that the services are compliant with the OpenAPI speci... |
Right now we have a monolith application, and we will still have one monolith probably for the following years. What we are trying to do though, is to break the responsibilities more clearly in well-defined bounded contexts. For this question, let's say we have two bounded contexts:
Company bounded context: in this bo... |
I am developing a package for the Unity game engine. I want to add additional functionality to my package if another specific package is present. I am faced with a dilemma I am not sure which of these two options is better in terms of API design and usability.
While not frequent, one can expect users to swap between ha... |
I am working on a ChildModelListSheetHandler, that has a childModelListDict.
As what you're probably thinking, it maps the foreign keys that are the IDs of the parent models, to the list of child models associated with that parent model.
I start working on a derived class thereof: RateCardChildModelListHandler. So far,... |
Currently my company has 2 applications that use Identity Server for SSO. Not every client we have uses both applications but some do. The part I'm uneasy about is that both apps have a user management section that adds users to IS by calling an api in IS. They even get a different token to do this behind the scenes (u... |
Why does the infrastructure layer depend on the application layer, and the application layer depend on the domain layer in the onion architecture ?
In its definition, the dependency flow inwards. But I can't see the advantages of having the application layer depending on the domain layer, and the infrastructure layer ... |
I want to build a grpc server which will be run by a company (service provider) and multiple client each run by a different company (a client). I thought of this instead using a Rest API to get benefit from the grpc speed.
My question:
Is it a good practice to connect multiple clients using grpc to a server over intern... |
I am trying to build a "world" consisting of Fields
for simplicity lets say there is a water and town field
i created two classes
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Water extends Field {
}
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Town ext... |
Lets say i have an application where user can register, and the username has to be unqiue value.
Now lets say i have N partitions and for each partition i have M replicas with multiple leaders.
Now i have questions regarding these scenarios:
First:
User 1 attempts to register with username user1 - the write request ge... |
We have an application that fetches user data from an Azure tenant via MS Graph. We need to distinguish between guests and regular members.
Guests come back with Usernames that look like this:
johndoe_agreatdomain.org#EXT#@mydomain.onmicrosoft.com
In our web application that actually displays this information, we nee... |
I have to create custom buttons but in order to encapsulate the logic of button creation I've this class (VB.net):
Public Class ButtonCreator
Public Shared Function CreateBaseButton(Optional label As String = "") As Button
Dim btn As New Button()
btn.Text = label
btn.Size = New Size(100, 25... |
Does modular design decrease compilation time in cpp? My professor said so, but I don't understand how, because the build and compilation time depend on the amount of code, right?
Also, wouldn't resolution of header guards in a separate module and stuff like that actually increase the compile time (marginally as I unde... |
I am making a appointment system for various businesses.
Each business provides us the following type of information (system already impemented):
Weekly schedule which day of week id open and close where stored upon weekly_schedule:
business_id
day_of_week
open
time_open
time_close
Deviations from the schedule stor... |
I'm writing my own F#-esque language and I'm using LLVM for code generation. I want my language to support continuation passing style and I think I've got TCO figured out but I cannot figure out how to make continuations use heap memory instead of stack memory. As far as I can tell there is no direct mechanism for maki... |
Am exploring options of adopting feature flag based development to deliver builds faster instead of getting tangled in release branch management rabbit hole.
As of now I am not able to find a good architecture pattern for iOS & Android native app development which will make it easier to adopt feature flags. We can use ... |
Let's say this application has a User and each user must have a firstName and a lastName. We could simply call the service with two strings from the controller (method A):
class UserController {
function createUser(Request req) {
userService.createUser(req.firstName, req.lastName)
}
}
or we could pass... |
So I want to make an application in which a user will hit an endpoint to save a job model to storage that includes some metadata to perform a long computation against which will be offloaded to a distributed task queue, allowing users to lookup their job run statuses or computation results via ID of the saved model. Ho... |
PHP have what it calls "traits" which despite the name is not like traits in Rust, Scala or other languages.
In many other languages with support for traits, a trait create a is-a relation. So if class Foo implements the Bar trait then Foo is a Bar.
The same goes for "mixins" which also basically inheritance and create... |
I am looking to create a "my actions" block on the dashboard of the website.
This block would include all sort of dynamic actions that the user needs to do.
Some examples are:
The volunteer still needs to sign volunteer contract 1
The volunteer still needs to sign expense note 1
The volunteer still needs to sign expen... |
I think that I've taken the Open-Closed and Single Responsibility principles too far. Previously, I had one huge static class containing every method that has C# talk to stored procedures on my SQL Server. Here is one such method.
public static void DeletePerson(int PersonID)
{
CallCommandAndHandleErrors((Connection... |
I'm developing a doctor-patient system that consists of two microservices, namely the "doctor" and "patient" microservices. Both doctors and patients share some common attributes, so I introduced a third microservice called "users" to manage these shared attributes. However, I'm unsure about the most suitable approach ... |
I like the practice of naming boolean variables with a prefix like "is", "has", "should", or "can".
But what about the functions that produce those results?
Currently I'm using:
const isReadyForPublicProfile = checkWhetherIsReadyForPublicProfile(teacherOf);
const shouldWarnAboutProfileChangingToPrivate =
checkWheth... |
Currently, I have to define a general design approach concerning the future extensibility of a software written in C#. The software is built in modular design: A main part doing the general handling, and several manager/driver classes who operate the hardware, handle the database etc. The goal is to create the software... |
During this weekend I read "Get Your Hands Dirty on Clean Architecture" by Tom Hombergs. I am working on a microservice that was born with Hexagonal Architecture in mind, so I was able to recognize a lot of patterns already; anyway, I am still a bit unsure of the role that a Spring Application would play in such archit... |
I am wondering what some possible workflows are for writing database migrations for a team of developers. We seem to run into a problem where one person writes a migration, names it and gives it a number (the latter is done automatically by the migration package called Alembic). Prior to this migration being submitted ... |
The contents of search string are typically sent as part of the URI query:
https://domain.name/resource?search=something+i+am+searching+for
Those same contents can be sent as the value of a custom HTTP header:
$ curl -v "https://google.com" -H "custom-search-header: something i am searching for"
> GET / HTTP/2
> Host:... |
Context:
We have Java maven Multi Microservices Project.
The structure for each microservice is a contracts package and a service package.
When we update a version of a specific microservice the versions-maven-plugin knows to replace the version in all the dependents poms.
Once there is a change in one file of a servic... |
I have a SaaS application in which users can connect their RDBMS (postgres, mysql etc) and query data from it. I'm wondering what's the best practice to keep their connection details safe. Currently, I'm saving them to my application db (postgres) in plain text.
Maybe I can encrypt them?
Eventually, I'd like to achiev... |
I am working on design of a distributed system which will process some events. For simplicity lets say, multiple instance of same service will be consuming from same queue, every message will have a id for which the event has generated and it will read the current value of it from the DB and increment it by 1 and updat... |
Let's say I have a C# .NET library with the following classes:
public class FooService
{
private readonly IDependencyA a;
public FooService(IDependencyA a)
{
this.a = a;
}
}
public class BarService
{
public BarService()
{
}
}
This library supports dependency injection, but it ... |
In my working project I have a CustomerRegisterUseCase, that has following steps:
validate email is already in use;
hash password;
save customer in temporary table(tranfered to customer table after email validation);
generate email validation code;
send email validation;
But other part of company wanna create a custo... |
I'm trying to design my new open source project I want to launch.
I want to be very careful with design/projecting because I had trouble maintaining software in the past.
I have code that works and now I want to rebuild it from scratch in a more organised way.
The project it self is based around a physics simulation en... |
The most popular answer is - it is an object whose state does not change after creation.
What does it actually mean?
My understanding is that any method call on the object should give the same result. So, it makes me wonder could an immutable object refer to mutable data? For example, Is an immutable object referring t... |
I'm new to Git, having worked with TFS for nearly 20 years, and I'm currently trying to get my head around "rebase". I broadly understand what it's doing, but there are a couple of caveats/warnnings that I keep seeing, but I don't really understand them:
"don't rebase after pushing"
So if I've rebased my master branch ... |
I often see/write classes that contain every part of the application where the application will talk to a SQL server. For example, you may have a class like this
public class Data
{
private Func<IDbConnection> Factory { get; }
public Data(Func<IDbConnection> factory)
{
Factory = factory;
}
... |
Scenario:
An application is going to perform operations on an entity. That means retrieving it from storage, possibly making modifications, and then persisting those changes back to storage.
I'm hearing conflicting approaches.
We should retrieve an entire entity from storage (like a repository), our application logic ... |
If i understand NAT correctly, by default a device outside of the NAT cannot reach a device inside it. If the two devices use a central server to connect however they can obviously communicate. My question is whether it is possible to remove the central server after establishing the connection if the central server sim... |
I am a react developer and writing the client on pure JS. I have sometimes missions to received data from server and send data to server. Now between the client team and backend rough discussion regrading how to send the data.
The server use map object for almost every thing, even for small data sets of information, th... |
I can write an enum with properties besides the name and ordinal. A very generic example would be:
public enum ExampleEnum {
EXAMPLE0(Example.example0),
EXAMPLE1(Example.example1),
EXAMPLE2(Example.example2);
public final Example identifier;
private ExampleEnum(final Example identifier) {
... |
I am building a chat app using flutter and sqflite. In the chats screen we display a list of chats, each contain name and last message. Every time a user sends a message, should I update the last message column in the local storage? Or maybe when disposing the screen I update the last message? What is the best practice... |
I'm working on an event-driven system and I'm facing a problem I never considered before.
There is a particular user command - let's call it "A" - that must be processed possibly with a delay of 10 minutes because user wants to be able to cancel that action issuing a new command - say "C" - until that delay has passed.... |
I’m working on a system where we have several scheduled long running operations.
In our case this is website crawls that we perform for customers. The current setup is pragmatic where we have one service running that is responsible for distributing the work to four different “crawlers” that is running as threads in the... |
I've started work on a web application personal project that is more a learning opportunity more than anything and I'm brainstorming the stack. My number one priority is to not overcomplicate things especially splitting up things into too many services. My second priority is to make sure that if, necessary, the entire ... |
In my embedded project I am designing a framework that allows the user to create widgets at compile time. All widgets must provide the same base functionality. Further, there are multiple widget categories which may share common code.
The user is supposed to create instances of the specific implementations ("the startu... |
Does it make sense to implement TLS encryption for a service which will always be behind a reverse proxy? The reverse proxy will be able to handle encryption to users directly.
+-------------------------------+
| +---------+ +---------+ |
| | service |<--->| reverse |<--O---> Internet
| | | |... |
Consider this Java code:
int rowIndex=8;
int offset=0;
libFuncCall.populate("B"+rowIndex+offset, data);
Here I mistakenly missed the fact that, resulting argument is a String though I had rowIndex and offset both integers. The actual code would have been:
libFuncCall.populate("B"+(int)(rowIndex+offset), data);
Until... |
When implementing projects in Spring Boot (especially CRUD applications), I often find myself writing a lot of repetitive code that just calls functions and services from lower layers. For example, when implementing a web service with some REST API, you end up with a controller, a service, a repository, and a model for... |
The following sequence diagram is rendered by Sparx Enterprise Architect. Is the start of the new activation (blue) correct? Shouldn't it rather continue with the existing activation on the Object2?
Please note that the flow starts with the asynchronous (red) call.
If the diagram is correct, why the new activation is ... |
I am building a .NET Framework WPF application, however, I want to use IConfigurationBuilder, which is a part of the newer (.NET Core and up) Microsoft.Extensions.Configuration namespace. My understanding is that .NET Framework apps traditionally use the app.config file in conjunction with ConfigurationManager class.
U... |
I currently am developing a TypeScript shared library. The library needs to be imported in sections to minimize the imported bundle size, so I broke it up into packages with a monorepo with Lerna. Things are going great. Each package has its own dist folder and each of those are published to the GitHub artifact store f... |
If I'm writing Scala functions and have to check for nulls in situations where I can't avoid it (say, working with Spark UDFs and some legacy Java types), is it better to turn things into Option or to write conditional branches?
Example:
case class Foo (
bars: Seq[Bar]
)
case class Bar(s: String)
def findBarWithCon... |
Designing a SaaS application that will be used by multiple business customers (tenants). Decided to use the single tenant model - a single instance of the application and database is deployed for each customer.
The problem deals with monitoring and managing the instances. We can easily create an admin portal (for CRUD... |
I am working on improving the code quality and portability of my C library, specifically a ring buffer implementation, that will be used in larger applications. I have encountered a dilemma regarding error code handling, and I would like to seek advice on industry best practices.
In some of my libraries, I currently us... |
We have a .NET c# solution that uses AliaSQL to run database migrations / to build the backend. I have a situation where we need to write some SQL Server logic that will
copy records from Table A to Table B based on some logic. It's not a straight copy.
must be triggered at a specific point in time, not by the pipeli... |
Imagine I have graph data that is beyond the size of a single machine.
How would you shard a graph database?
I asked on Hacker News and people suggested sharding based on a hash of the predicate-subject-object, ala RDF triples.
I could partition the graph across replicas and query all replicas to aggregate answers.
But... |
The SLF4J documentation says that it's best practice for libraries to not include a concrete logging binding.
I'm wondering what to do about transitive dependencies though.
Let's say my library A depends on another library B which depends on commons-logging.
Should the pom.xml for A have an <exclude> for commons-loggin... |
In interpreted languages like R and Python if I import and module, and use its functions, is that considered as dynamic linking of my program to that module?
|
I'm working on a .Net core API for product configuration and ordering. The ticket for Permissions has come up and I've been tasked with developing a solution, ideas of middleware have been mentioned.
Considering:
Clean Architecture
Don't repeat yourself
Singular Responsibility
When should I, (or at which layer should... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.