instruction stringlengths 34 36.1k |
|---|
A play arena contain a list of Machines and Amenities
playArena :
guid : GUID
name : string
location: Location
owner: string
amenities: Amenities
playing_machines: PlayingMachines
Amenities is list of Amenity -> Array<Amenity>
PlayingMachines is list of PlayingMachine -> Array<PlayingMachine>
Initial ... |
Imagine you're creating a completely new version control system, like Git, Mercurial, SVN etc. from scratch. Rather than identifying commits by SHA hashes, you identify them using an ordered sequence of numbers and letters, from 1, 2, 3, 4, 5 etc. If you make a branch from a commit, you call that commit 1a, and then fu... |
If a class is written well, you should be able to gleam all relevant information about the class simply by looking at its header.
If one sees that the constructor is marked explicit:
What should one assume to be absolutely true about this class?
What should one assume to be potentially true about this class.
What sort... |
Docs and blog posts describe what row version columns do, but rarely delve into the decision process of when it's appropriate to use them. I suspect that many developers just add them to every table without considering whether they're actually needed. This saves development effort, but it comes at a cost that I may wan... |
I am fairly new to programming; I was following a tutorial that was using php 7.3.8. So I went to the documentation website of that same php version, and it says it’s no longer supported. So, I stumbled on the questions.
What does that mean that is no longer supported?
That it won't receive any updates?
Is it safe to u... |
As I am learning OOP principles, I know that it is always good practice to hide the inner workings of classes so that the end user can't access or break them. I understand why this is important. The human mind cannot comprehend overly complex code. I also hear the term "Black box" quite often. A common example I hear i... |
I have a Curve class that has some CurveData inside as private member as well as getter functions for topics of interest (e.g. peaks, width and so). So the math logic of a curve is inside this class.
Things to be done with this Curve are:
Test its values (returned values from functions) with some thresholds.
The test... |
Is it possible to fetch data and update it if a time constraint has been met? Originally, my implementation was a cron job that regularly updated the data in my PostgreSQL table every minute on the minute after selecting all the rows that met the time constraint. (Meaning the job always ran at 12:00, 12:01, 12:02, etc)... |
I'm currently working with a pre-existing class (not written by me) that has functions which call other functions, passing through the parameters to the helper functions. Sometimes there are layers to these functions, so that func1 calls func2 calls func3 calls func4, where a parameter of func4 is passed through all th... |
How do I solve this riddle of contradicting "good practices" to properly cover my app with unit-tests?
These are principles I found about writing unit-tests:
Pyramid of testing says unit-tests have to be written first and there should be more unit-tests than integration tests
It is useful to automatically calculate te... |
Let's suppose we have this expression:
(i % 1000000) * 1000 + ms
where i is an always increasing number, and ms is the millisecond part of the current time ( ranging 0..999). So each time we are calling the expression above, at random intervals, while i is increasing always obtaining all unique values, the result of t... |
I have a requirement to cache some static data as it is being consumed by our system. There is a static API that gives a map of records and we are fetching the corresponding record based on request.
Instead of calling the static API for every request, we are planning on caching the data in an in-memory Java cache that ... |
I am currently creating a software model for controlling a simple (two-way) pneumatic cylinder. In essence, this controls just a movement from point A to point B. The controller has two outputs (OnMovingToA, OnMovingToB), which can be linked to a relay, valve, etc... to move the actuator to resp. A or B. The controller... |
Context
I have a service class whose sole purpose is to interact with a specific API, let's say the Automotive API. The API mostly works with generic AutomativeRecord which basically represents a database record on the API backend with its fields stored as an array.
AutomotiveService.cs
public class AutomotiveService :... |
I have a application built with nodejs. It's hosted on AWS and uses postgres as the database. The application allows for users to create bookings. When a booking is created, an email is sent to the user to notify them of the booking.
The problem I'm having trouble wrapping my head around is how I'd implement recurring ... |
Is it common to write test for CI/CD scripts?
Background: Some CI/CD jobs/scripts have become rather complex over the years (new features, edge cases) and I believe it would help rewriting them with e.g. python instead of bash. However, since these scripts have no tests, rewriting would definitely be error-prone. There... |
I want to come up with a way to make it easy to write classes that represent quantities with units, such as length, weight, etc. For example,
var height = new Length(32.2, LengthUnit.M);
var weight = new Weight(164.2, WeightUnit.Lb);
In addition, these classes should automatically handle unit conversions and implement... |
My friend is building a small open-source project with a few convenience functions. He'd like to release both JS, PHP and Python versions of the package to npm, packagist and pypi. The main part of the package is just data that can be shared, so the actual code to translate is very small.
Should I recommend him to buil... |
I have been using an implementation of UML statecharts in C++ similar to that defined in the book "Practical Statecharts in C/C++" by Miro Samek (https://www.state-machine.com/psicc).
One of the "problems" I keep encountering in my development over and over, is how to associate an action with a transition that requires... |
I have Items and Im creating an API which validates different aspects of an Item. eg: whether it has a valid height, width or depth.
My request body looks like
{
height_check: true,
width_check: true,
depth_check: true
}
The response looks like
{
height_check: {
valid: true,
... |
I was reviewing a pull request of a programmer that works under me, and found that in testing fixes to their code, I ended up completely rewriting it.
Should I push my changes and then explain what I changed, or should I scrap my changes and just try to explain to them how to fix their code?
I don't want to offend them... |
I'm doing a simple project that represents a CI Pipeline in a low scale. So I'm trying to model "the best way possible" to practice DDD.
Basically I have the following information:
PipelineSettings (A configuration file that shows me the steps the pipeline will have)
PipelineSteps (A collection of classes implementing... |
I have a problem where our current SDLC model is the V-model which is great for its verification/validation of all phases, but lacks the support for iterations.
Spiral model on the other hand has iterations and fits, but does not focus on verification, validation and testing activities like the V-model.
Is it valid to ... |
I have to create a table to map some strings that are my input, to the result value that is a value that I can choose, like an id (or string).
So, to make an example, I have an excel file made of a not normalized list of names, that are all the possible values that I can expect:
"audi A4"
"Audi A6"
"audi a6"
"ford foc... |
Canva has Templates that are unique & can be easily modified by anyone & replaced with their own text, images, etc...
I want to build something like that.
I have multiple options to use but don't know which one is good or which one is fast enough to code.
My options are:
DOM with html-to-image for screenshot
Canvas
Ko... |
I have a project where I am planning on using maybe 4 raspberry pis to record a bunch of different sensor info like temperature, humidity etc. I would like to be able to access this info from a webpage. For this, I am assuming it'll be easier from the website perspective to pull data from a single database that's hoste... |
I am trying to understand Rabbitmq and how I can accomplish sequential message processing in certain circumstances only. For example if I have 2 queues. One for pricing an order and one for sending out an invoice. Sometimes these queues would get messages and be processed independently, but other times they are depe... |
I'm interested in modernizing an existing codebase for a commercial software package written in Java, in part by moving it to Maven. The primary motivator here is to shrink our git repo, which is very large due to the build system being ANT with its dependencies checked into git. I've done a few small side projects i... |
Maybe I'm overthinking about naming, but it's a problem I've encountered several times and it was really annoying every time.
I have three interfaces. The first is IAssembler, which has assemble(...) method. The second is IDisassembler with disassemble(...) method, and the third is [no good name for that one] which inh... |
When designing my simulator, I have gotten stuck on 2 main design choices.
The simulator can be described as having X number of nodes (between 50 - 2000) that each need to independently do some processing during each time-step in their own thread. After they are all done processing, then the main thread needs to do som... |
I have a Nest.js application, and lately I've been thinking about how I can ensure that data is synchronized between two sources - my database and an external database.
For example - and to my question - is my database versus Stripe's database. I have plans with recurring payments, and I track how many licenses a cust... |
I've got a GRPC API that I'm designing. It includes an RPC method that requires the caller follow-up with another API call. Some pseudo-code a client might write:
val apiInstsance = makeAPIInstance()
val questionFromMyAPI = apiInstance.computeQuestion(clientInformation)
val clientResponse = doBusinessLogic(questionFr... |
One thing I've long struggled with being able to grasp properly is, when designing a program in an object-oriented language, where and how should explicitly named/defined interfaces be added? In particular, I have heard at least the following statements on the matter:
The "SOLID principles", of which the last three (i... |
I am trying to understand what can be done with closures that would be difficult or impossible to do without closures.
One use of closures I have found is to make an object's variables private, for example:
function CreateEmployee()
{
var name;
var obj =
{
"getName": function()
{
... |
Monad is a monoid in the category of endofunctors. Endofunctor is a functor that maps to itself. What does it mean? Well it means that, no matter which element in the set is taken as an input, the output value must also belong to the same set. I understand that if the input of the function is an integer, then the outpu... |
For the purposes of this question it will be assumed that the conventional commits spec is used as a version driver for semantic versioning.
Given a project is in active development. Releases are planned but not often enough to warrant CD. Thus a release-from-branch strategy is chosen.
If a release branch were to be cr... |
Outline
When you build an Adapter that connects your application and the database,
How big should you make this adapter? Should it contain all possible queries that could be made to the DB?
Do you split it up into several adapters?
By what means should split it up?
Concrete example
I'm imagining the following rough ... |
A monad is a monoid in the category of endofuctors. Category is a set of two things:
Set of elements
Set of binary operations between these elements.
When we talk about the category endofunctors we also have a set of two things:
Set of endofuctors
Function compositions as binary operations
Function composition is a... |
I don't know from where I got this but in my head a function returns a value and a method does not.
I know that with OOP a method is a function related to a class. But I am trying to remember where I got this idea.
|
Abstract
I'm trying to figure out a solid, scalable, clean and practical architecture for react projects.
As a a playground I have a project with two Screen and a JSON server.
When I try to apply a clean, one-directed architecture, I end up with a very complex Structure.
(Here, a Screen stands for *a site, that is sh... |
So I'm trying to understand the connection between the Requirement Types given in my Software Engineering lecture.
We discussed 5 different Requirement Types: User-, System-, Functional-, Non-Functional- and Domain Requirements.
Is it true to say that System Requirements are better and more precise User requirements an... |
Hypothetically, consider a social photo platform - each pic gets its own url, this page contains the image, text about the image, buttons for the user to click, related pics, and some user-specific elements (maybe notifications, etc.).
There are different ways of going about the frontend. In each case, elements specifi... |
First some context. Working in teams which use a CI environment, many people will know the typical Gitflow release process.
Without going into too much political detail, the company I currently work for has decided to "release features more often", up from a 2 week cycle where develop branch was merged upwards step-by-... |
As a Scrum Master, how does one plan to minimize the impact of the sprint deliverables/to the team when a team member is leaving?
|
When we have a math problem such as 3 + 5 + 2, we say that it is associative. We can choose which step to pick first: 3 + (5 + 2); we know that brackets affect the order in which the operations are performed.
I've learned that function composition is a binary operation and it is also associative. They say, function com... |
Problem
Hi, we have an API that it's pretty similar to a standard CRM. That is, we have a really big amount of resources (even our own customers can define new resources). All of these resources share the same endpoint: /resources/<resource_name>. This resource name can be any name, like customers, leads, contacts, etc... |
Colloquially, type hint and annotations are used interchangeably in Python. After reading PEP 484, I was unable to disambiguate the terms "type hint" vs "type annotations" from the text. Are they synonyms? Otherwise, do "type hint" refer to the typing system and "type annotations" refer to the written text itself (e.g.... |
I am using a networking library I created which contains a Client class. I have a GUI which will display all these clients in a ListView with columns, such as one containing their online status. The online status property is only for the UI, so it is not present in the class in the networking library.
What I am current... |
I'm wondering how to choose between those "patterns" - please forgive me if I don't use the right terms - when having to deal with complex object coming from the front I want to process.
Simple Beans
Simple beans means the separation between data structures and logic, like this:
class Post(val title: String, val conten... |
Following context:
in a set of metadata that contains a lot of possible fields there exists at least one field (possibly more in the future) that can be empty by intention but realistically will be relatively rarely and in most cases the field being empty represents a mistake/carelessness of an employee.
Due to that fa... |
At first, we have a working function name foo
void foo() {
bar1(9);
bar2(9);
}
Noted that the value 9 is hard-coded. Then, we want to make a change so we can make 9 a parameter yet preserving the old foo function, so we change it to
void foo() {
foo_ex(9);
}
void foo_ex(int x) {
bar1(x);
bar2(x);
}
Cod... |
When catching and wrapping an exception in PHP, assuming the new exception doesn't have a meaningful code of its own, should you also use the caught exception's code value? or the default value? In other words...
Should I do this?
try {
do_something();
} catch (GenericOrThirdParty_CaughtException $e) {
// Reus... |
I'm busy working on a website – somewhat new to this – and I don't quite know where I should store static data: in the public folder as a separate json file, or within the .js file as an object.
In the json file, it would look something like this:
{
"navLinks": [
{"title": "Home", "path": "/", "number":"one"},
... |
I currently have a database centric web app for my company. For the office staff, the whole system is based around orders. There is an order list page. Warehouse manages his part by reading, preparing and marking incoming orders as 'prepared', 'dispatched' etc..
Telephone staff takes new orders from customers using the... |
It is considered the best approach that a microservice db is private to it and shared nothing approach is the best.
I recently came across a cloud based system which used postgres, mongodb & elasticsearch. The per service DB is followed, to the extent that each service was running its own cluster of storage engine whic... |
Edit: The question below is summarized by this question:
I sent you [payment] to run computations. How can I make sure you are actually running the computations?
Thanks to user253751 for this
Edit: TL;DR
I'm currently making an open source application that essentially creates a cluster computer over the internet. Thi... |
When using composition, when should we favour wrapper methods? Let's say we have the classic car example.
public class Car {
private Battery battery;
//wrapper method
public void load(float p) {
this.battery.load(p)
}
}
public class Battery {
public void load(float percentage) {
}
}
The ... |
I have got the following scenario, which I have been thinking what would be the "best" way to solve it.
Request comes from the FE, which changes the status of a delivery,
and that should trigger different things depending on the value of the new status.
-if confirmed, send email and also create pdfs
-if dispatched, cre... |
Scenario:
An API that responds to a request with multiple JSON objects contained in an array.
The responses are paginated such that each page returns an array of JSON objects.
I deserialize the JSON responses into an object, then append that object onto a List (or some other collection), and then return the collectio... |
I'm building an infrastructural service with my team. We are building a service that will help other teams in our org send out a notifications to end users when certain events occur. We are currently having an issue agreeing on which service should be listening to occurrences of these events to then trigger a correspon... |
I have an ASP.Net Core Web API where I am having difficulties designing the REST resources based on the EF Entities I have.
There are three entities that describe a Reservation. First, there is the Group Reservation:
public class GroupReservation: Entity
{
public int Id { get; set; }
public string? Reference { ... |
Backstory
Probably a stupid question, but I just have a sneaking suspicion that "asynchronous" is the wrong terminology to us for naming my template function here:
template <class T>
auto asynchronous( auto &&lambda )
{
QEventLoop wait;
QFutureWatcher<T> fw;
fw.setFuture( QtConcurrent::run(lambda) );
QO... |
There are many version control systems out there, and they tend to use one of the following models to store separate versions of a repository:
Snapshots - each version of your repository is stored in its entirety, i.e. if you make changes to file1.txt, there are two stored versions of file1.txt representing the differ... |
Is there a best practice for managing shared state between a parent and child objects that is most likely to avoid bugs, maintain consistency, and be easy to implement/understand and maintain?
As a concrete example, consider a crossword puzzle solver. I'm envisioning the following objects:
CrosswordPuzzle
A grid wit... |
The Java project I am working on currently has a complicated folder structure, and to add a new functionality, one needs to add many .java files in different places in order to let it work in our project structure. For example, when I want to add a new object User, I need to add Entity, JsonModel, Controller, Listener,... |
Code in Python as example.
For instance I have an emoji class with following attributes and dunder method:
class Emoji:
def __init__(self, name: str, animated: bool = False, id: Optional[int] = None):
self.animated: bool = animated
self.name: str = name
self.url: str = url
self.id: int = id
def __e... |
In git flow, there is a point where you decide to create a branch from the current develop being the new release. For example 1.7. Everthing that is ready to this point is considered beeing in that release, everything after this point is a new release (e.g. 1.8). Only bugfixes should go into the current release branch.... |
I've already read this carefully, but still need more clarification.
I'm not new to dependency injection, but new to Hilt, and trying to implement Hilt in my multi-module app.
The reason?
I currently have a static application class wich not only provides a context, but also a singleton SQLite database, and it also hold... |
tl;dr is is a good idea for const methods to be able to mutate objects referenced as reference members?
Imagine you have some kind of work queue that uses items that look like so:
class Consumable { /* ... */ };
class Consumer
{
// ...
virtual void consume(const Consumable &);
};
struct WorkQueueItem
{
Consu... |
I want to create a git repo that will include scripts in /nfsdrive/sbin/ and the services that activate these scripts—which reside in /etc/init.d/.
I've searched the documentation and the relevant discussions, but could not find if the above is at all possible, much less how to accomplish it.
Is it possible to create a... |
In my job I work with C# (although the language is irrelevant for my question, and now I'd like to focus on Android) and we usually inject interfaces and not the actual classes, so I was wondering what are the real benefits of that?
As far as I know, I can understand interfaces (if no DI is taking part) as a way of not... |
We have a scenario that is in a VERY tightly controlled industrial environment. This is all C# on Windows.
We gather data from different types of sources - sensors monitoring environmental data, sensors monitoring production line stats, sensors monitoring production line health, etc - with specific "service application... |
Well, I'm developing a personal project using TDD and Clean Architecture, and I chose to build an abstract class to gather all use-cases behavior in one single class. My question is: What you think about making test for this abstract class? Would you write tests only for its subclasses or would you do a "mock class" ju... |
I want to illustrate my problem statement with a use case. I am building a trading system that acts as a container for deploying trading strategies. The trading strategy comprises dependent tasks. Let's suppose there is task T1 and T2. T1 runs at the market open (the core of the strategy), and T2 runs after the market ... |
I design a common API for selected printers of different brands in Java. Each printer uses a different underlying SDK with different functions, but any hardware my code runs on will have only one printer connected, this is a known guaranteed hardware limitation. Despite dealing with different SDKs, I also have common l... |
There are a few threads about how to handle the version number with semver upon changes in dependencies (usually resulting in a +1 to the patch number). Mine is probably a corner case: what if you are just updating a development dependency (e.g., a linter, a test library, a formatter...)?
Usually, from the user perspec... |
I've gotten this idea in my head that i shouldn't use a libraries variable, if the variable name begins with '_', as it is standard to write private variables that way.
But now i'm thinking i'm taking that too literally. If my choices are to use "_var" that points to a HTML element or add a unique attribute to said ele... |
I have not previously designed a nontrivial HTTP API, so I apologize if anything here is textbook stuff. I wasn't able to find anything going into this in much detail when I looked.
Let's say I have an API where you can upload some data and then request a potentially long-running operation be performed on this data. ... |
I am a very beginner writing one of my first webapps. I'm using FastAPI and I'm stuck on the logic of creating an endpoint that has to do a lot of things before it returns something back to the user. Since I'm new I also lack a lot of the vocabulary that I think I'd have if I were more experienced so bear with me:
To s... |
I have a segment of customers which may range between 1 and 5000. For each customers, I need to do some processing by making some query to the database using the data from the customer. The query is expensive and is the reason why I plan to use a queue to handle these tasks.
I figured a simple queue with one producer a... |
I recently started learning about DDD and I'm in the process of designing my first solution.
I have a business requirement to design solution for Auction module and there are many types of auctions like car auction, property auction etc. all auctions types share same set of properties with custom properties to each typ... |
I feel as if i am over-thinking this, but with a RESTful API design with resources being themselves resources of something how should these 'typically' be accessed?
Of course, an acceptable answer is 'it depends', but i am trying to understand what is usually what people might expect, and then also what is easiest to r... |
With the purpose of learning Hilt I started "migrating" my multi-module Kotlin app from using classes with static methods as helpers to Hilt injection.
After a lot of headaches, now everything's going fine, and I could say I'm happy and in the 80% of the migration, but suddenly a question have come to my mind and stopp... |
I recently started learning about DDD and I'm in the process of designing a solution for an Auction module the issue I'm facing is that the different types of auctions have different characteristics for example:
I have Auction for License plates and when creating the Auction you should provide the base letters like "AA... |
I have different availability requirements (90%, 95%, 99% guaranteed uptime) for certain subsets of data. For example, the subsets of data are split based on the possible values A, B, C.
What would be a good way to do this? Guaranteeing 99% uptime for all sets would be a waste of resources and too expensive given the r... |
I have a colleague that insists refactoring to make the code testable and introduce tests should be independent from changes in architecture as part of refactoring, e.g. introducing a factory pattern. They think that such design decisions, like introducing a factory pattern, should be conceived and discussed with the t... |
I've just started dipping my feet into OOP.
Is it considered bad practice to have classes that reference attributes that depend on another function being called and thus may not exist (version 1)? I'm self-taught so trying to gauge what is considered better quality. Any mistakes are easily fixed by just making sure I... |
I am working on a REST API for a company that, until recently, has been focused on the Australian market. The result of this is that the API has resources and fields which model the Australian market, especially in relation to taxation, superannuation etc. We are now looking to move into overseas markets, starting with... |
I have an MVC application in Java with GUI components in a View class. The GUI has to support two languages, so texts on buttons etc. depend on which language was set at start up. Strings are in .properties files and I have a MyStrings.get(Key) to get the string corresponding to Key.
Should I call MyStrings.get(Key) in... |
I have an issue regarding the differentiation between two Rest methods that have the same amount of path parameters:
@GET
@Path("image/{ratio}/")
@Produces("image/png")
@PermitAll
public Response getImageMe(HttpServerRequest request, @PathParam("ratio") String ratio) {
//Do something
}
@GET
@Path("... |
I was reading some of the documentation for the linux kernel and I stumbled upon an article about adding new syscalls to the linux kernel. The article essentially says that any syscall in the linux kernel must be supported permanently:
A new system call forms part of the API of the kernel, and has to be supported inde... |
I have never used atomic operations, and remain largely ignorant of how to utilize them. And yet, I often come across objects like this when peering into Qt's backend:
https://doc.qt.io/qt-6/qatomicinteger.html
This leads me to question if there is a feature here that I have not been properly taking advantage of.
My qu... |
Let's say some method of a parent class is reimplemented in a child class.
This child method is intended to do the same that the parent method, with a minor change.
In this case, in the documentation of the child method, is it useful to cover what the parent method do ?
If we do, the child method is 'self-supporting' ... |
I have a decently sized registration form that will require some PII data, as well as some obscure shipping information. I am working on best UX practices for input repopulation considering the time and effort needed for the form. I was curious if storing address info in localStorage, when there are no ties to a part... |
I do know that the best practice these days is to model immutable classes in Java. An ex: below
// It makes sense to model this in an immmutable fashion
class 2DPoint {
private int x;
private int y;
2DPoint(int x, int Y) {
this.x = x;
this.y = y;
}
public Int getXCoordinate() {
return this.x;
}
... |
I apologize for asking this intuitive question. I'm not good at programming and my recent work requires me to work a lot with SDEs. I wonder what might be the advantages using the this pointer?
I understand why it exists, and sometimes "this" makes it clear we are assigning value to a member variable (in the following ... |
I currently have a CI workflow for tests that use data present in my repository. However, since this data is very large, I would like to move it to another remote repo and somehow give my CI tests access to this data from that other repo. One way I could do this is by using git submodules, but that would still force me... |
Suppose I have a member function void A::foo(B const &b) where a class B instance is just a bunch of data. Would it not be better to remove the dependency between class A and class B by rewriting the member function like void A::foo(int var1, double var2, double var3)? Or could this modification be classified as a Prim... |
A seemingly basic question here.
Is there anything you can do with multidimensional arrays that you can't do with nested arrays?
Many languages have been designed with both facilities and syntactical differences, but I can't for the life of me work out what you can do with multidimensional arrays that you can't do with... |
Sorry my title is terrible i couldn't think of a concise title to use.
I have a bit of code that needs to consume two quantities from two objects, this is done using a TryGet() type of method and the code looks like this:
if(A.TryGet(resource, total) && B.TryGet(resource2, total2)){
//do what ever
}
The problem is... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.