instruction stringlengths 34 36.1k |
|---|
I’m currently writing a software for my company (3rd world country), and I wanted it as simple as possible to install and maintain, so I started with Qt and no server app beside the database, (MariaDB or MySQL). The app is made to be used by different users on the same machine.
The app the communicating directly with t... |
I have worked with Git workflows where we release from dedicated branch specifically used for release (e.g. Gitflow's master/main branch). In such workflows, there will be multiple (at least 2) long living git branches. One for development (called develop), and one for releases (called master/main/release/production).... |
I've got a class which stores two data series like so. I need to do some complicated processing on each of these arrays, but for now we'll just get the average of each data series. I could either do this:
class DataMangler
{
private array $dataArrayA = [];
private array $dataArrayB = [];
// stand in for co... |
I know this question has to have been answered in countless ways before, but I would appreciate some help pointing me in the correct direction.
I am developing an embedded system that receives "commands" over a communication line. Obviously, in the OOP world, a specific type of "command" could be represented as a spec... |
For a paper I am writing, I need to find the origin of the following two phrases:
Code against the interface, not the implementation
and
Test the interface, not the implementation
(Note: the second is more important to me than the first.)
I googled around, but was unable to find anything. Apparently, everyone knows... |
I have experienc with designing relational dbs but first time attempting to store JSON in a mysql table. I am using mysql 5.7.8 which has the ability to store json data type as a column.
When I create the schema for the table should I have two columns where one column is a key and the second is to store the JSON docume... |
I have read that the null data type in JavaScript is a primitive data type, however due to a bug or something in the first version JavaScript, null is considered to be an object.
However, let's assume that null is a real object (and not a primitive data type like it really is), what does that mean exactly, i.e. what do... |
I need to write continuously into a JSON file in C++. The format and structure are defined as requirement. The data is produced in the process itself and needs to be stored multiple times per second. It's actually a protocol of realtime data.
Structure is basically:
[{Object01}, {Object02}, ...]
With every tenth of a s... |
The context
I have an IoT project where the sensors are sending data to my Postgres database. The sensors are manages by a stand-alone service which provides a REST API to query various information about the sensors (e.g. are they online).
I would like to have a unified interface for querying all the related data regar... |
I'm working in a large company and am doing my first Java project here. We have certain code style guidelines. In the Java guideline, it is said that "assertions are only intended for debugging and bug hunting, but should be removed in production code".
I personally like to write assertions to get notified of invalid p... |
How should I go about using TDD and writing tests in this scenario?
Suppose we have request handler classes. In short, a handler applies a "request" (e.g. Update details) to an entity then saves the result to the repo.
However, the existing handlers follow this sort of implementation pattern (simplified):
// You can sa... |
A particularly nasty bug just happened to our software. (JS/react something was preventing onclick from firing about half the time - turned out a constant rerender was happening). This wasn't really easily to solve and the culprit wasn't found easily. So the way the bug was found was by going back in history till the c... |
I have an app where certain data is stored in the database. Multiple users access the same set of data (similar of a collaboration tool). However, they can non deterministically work on stale data. For example, if there are three work tabs and someone is working on tab 1, it may not matter to him if tab 2 is modified. ... |
I want to execute everything in a user context. Meaning that if the request comes from one user then the service has a token of only this user and can't execute anything for another user.
Now the problem:
Service A publishes a message to MQ which is consumed by Service B.
Service B then makes a REST call to Service C t... |
If my service is inserting into a varchar column with a certain max length, I can either
validate its length prior to inserting to avoid getting an error from the database if the string is too long
try inserting it as is and then handle the error if the database say it's too long, and giving the consumer a validation ... |
Based on this explanation of multi-tenant architectures here:
A multi-tenant architecture is one where a single software instance
and database serves multiple customers
I cannot fathom how it is preferable to have a single database instead of spawning a single/multiple databases per tenant?
I would think that it shou... |
I am building an app (.NET, but whatever) which is supposed to be able to send notifications to users.
Each Notification can either be a Reminder or a Newsletter, and I'll possibly add more types in the future. Each type is handled differently. Reminders are periodical, so I need to keep track of who is reminded of wha... |
Many programming languages have an implementation language (mostly a system language like C) which is used to implement important parts of the core of the language. Besides the libraries are written in the language itself (like Ruby or Python). My question is for an interpreted language like Ruby or Python, this means ... |
Lets say we have a table 'A' with 4 referenced tables : Table B,C,D,E
In our Data Acces Layer we could write a method that returns Table A containg every entity of B,C,D,E by joining in order to reuse that method in bussnies layer.
Is the better aproach just creating a new method for every query you need? For example i... |
Sometimes the UML component diagram contains a database component. Does this database component represent a class that programmers create (which includes host, username, password, port... DB connection with PDO, SQLI... etc.) or does it represent the real, entire database?
|
I am looking for a way of dealing with the following situation:
1- Have an items collection in MongoDB
2- Have a users collection in DynamoDB
3- Each document in the items collection has a "reference" to a user or multiple users via an id attribute of the DynamoDB.
4- I need to query the items collection and populate e... |
I have a project written in python that I would like to create unit tests on.
This project has a dependency on a database project which is a sort of abstraction layer to data connections.
The issue with this db project is that it's huge! So when I want to run the unit tests as part of a continuous integration pipeline ... |
I'm trying to implement a project using the Onion Architecture (aka Hexagonal, aka Ports and Adapters, aka Clean Architecture).
I understand that the user interface uses Service interfaces instead of the actual implementations.
I also understand that if a Service needs something from an external source (e.g. a database... |
I have been trying to come up with a method to "serialize" various objects into various different formats. For example:
class Shape {
public:
virtual std::string_view name() const = 0;
virtual double area() const = 0;
};
class Square : public Shape {
...
};
class Triangle: public Shape {
...
};
Suppose I ha... |
I have javascript script that creates the same div everytime the user clicks enter and then set the event listener to the new input in the new div.
example:
//creates the container, text and input for the new line
function createNewUserInputLine() {
var body = document.body;
var inputLine = document.createEleme... |
How can I tell if my C function is a computable function in computer science?
I am trying to write C code that would be acceptable to computer scientists in the field of the theory of computation.
It looks like anything that can be construed as a mapping from a tuple of natural numbers to a natural number is a computab... |
Background
In the scenario GraphQL Federation was designed for, you have numerous GraphQL microservices in the backend, each with their own Schema Definition Language (SDL).
Theoretically, these services are able to start and run independently and can begin serving GraphQL requests right away. In order to tie these ser... |
I have the following interface:
class IHittable
{
virtual Intersections intersects(const Ray & ray) = 0
}
which will be implemented by various geometric objects(Spheres, Triangles etc).
Now the class World will look like this:
class World
{
public:
Intersection intesects(const Ray & ray)
{
auto int... |
Is it a sign that something is wrong with the code design if you end up with a layer of functions that just forward request to a component? Exposing the component would avoid this but hurts encapsulation.
An example in a C++ like language.
class AnimalManager
{
public:
int GetNumAnimalsOfType(EAnimalType Animal... |
I have a simple app for storing the movies, that exposes REST API. I am using spring-boot. I am using this simple app as an example, however, the question is more about general good practice.
I am using spring-jpa, so i have entity that represents the movie:
@Entity
@Table(name="movie")
public class MovieEntity{...}
I... |
first of all i will explain you what i want to do.
I have a Web application where are multiple rooms like Room1, Room2, Room3…
Currently active users can join in one of these Rooms by clicking on it. I handle this with socket.io rooms. That means, if a user clicks Room1, he will join this room by socket.join(„room1“). ... |
I am working on social platform with a distributed architecture. The platform should offer a chat module, but since the most efficient way to implement a chat is using websockets. I am not sure what part of my architecture should have the websockets server.
Basically, I want my system to have an api gateway component ... |
A couple months ago, Microsoft updated their C# Naming Conventions (https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions). As the developers of C#, I consider Microsoft to be the standard for coding conventions.
They want private and internal fields to be named as _myField. So ... |
I have two micro services built using spring boot,
One micro service is: "payment" Which handles actions related to payments.
Like creating a payment link.
Getting the latest status of payment and storing that information in DB (via polling). There is an UI Screen to which user redirects once payment is done and from ... |
The distinction between a spike and implementation is that the spike is designed to find things out, while the implementation is designed to make something that works.
In a spike you don't necessarily care about completeness, maintainability, correctness or ease of reading. But I'm finding, for some tasks, there is a t... |
I have an API where every time is called there are multiple calls to multiple webservices in the background, sometimes it takes up to 20 seconds to process the request calling up to 10 different web services depending the specific use case.
The API is developed using .NET Core hosted in IIS behind a web balancer, the w... |
I am focusing on learning better design and wondered if this code is good or an anti-pattern? The function Validate() returns true if the data is correct, else it will throw an exception with a message to display in a popup.
Another way could have been to return a string and treat empty string as validated, but I don't... |
Hello we have an async event-driven system (kotlin, spring cloud stream, rabbitmq) where there might be an event FooPayloadArrived, published by an ingress rest-controller.
Processing this FooPayloadArrived and publishing the follow-up result in a subscribe may take some time, let's say 1h.
Being in AWS and using a man... |
I am designing a REST API that has to deal with users and two video uploads associated to each user. So far, I've come up with two different approaches of modeling this:
Video as part of a user resource.
Video as a subresource of a user resource.
Each approach has its (philosophical) advantages and problems: To expla... |
Say I have two object types of the same interface MyObj (I am using python in this project so I will use the same for the explanation)
class Foo(MyObj):
a = [5, 10]
class Bar(MyObj):
a = [[1, 2], [3, 4]]
Now I have this other class to do something with MyObj objects. Doing this is almost exactly the same for ... |
TLDR; I'm architecting an hybrid multi-tenant app that needs to handle customizations request from customers (tenants), I'm trying to decide between modular monolith and microservices pattern, Which is the best way to handle customization reducing development costs? How should we handle customizations, I mean, How can ... |
Challenge:
I am implementing a microservice/app/applet.
Several features will be delivered
As things develop later features rely/depend on earlier Pull-Requests (PR)
Developer resoruces are finite, so a PR is not necessarily merged with main in a time-frame that permits me to commence work on the feature/next.
For in... |
I've always been taught that fatal exceptions (indicating problems that cannot be solved programmaticaly) and boneheaded exceptions (resulting from bugs in my code) should not be caught, should not be handled, should not be ignored, instead they should be allowed to crash the app. The reasoning is that once such an exc... |
I am working on a C++ desktop application using the MVC design-pattern. In a nutshell, it allows to monitor the position of a real robot in a 3D environment and create tasks for it by modifying the virtual 3D environment.
Everything in the 3D scene is a "DataObject" with properties and signals when a property change (a... |
If I have a discriminated union and want to write a function piecewise, the following code works just fine, but is taking advantage of some fairly tricky (at least to me) stuff involving overload groups:
struct A { };
struct B { };
typedef std::variant<A, B> C;
void f(const A & a) { std::cout << "a" << std::endl; }
... |
I am trying to implement a Binary Search Tree in C as a learning exercise. I have the following struct that represents a node.
typedef struct BSTNode {
int data;
struct BSTNode *parent;
struct BSTNode *left;
struct BSTNode *right;
} BSTNode;
BSTNode* create_BinarySearchTree() {
BSTNode *p = malloc(... |
I am looking for a suitable design which uses composition to allow three classes to share some logic.
The problem I am solving is that I have to read 3 different json configuration files from my application, and each file needs to have a different class that allows to filter specific data accordingly, however I need to... |
I'm writing an express/socket.io-powered game server for a web game. I have a central map of game state objects, each representing an ongoing match, like so:
// map of gameId -> game (primary holding place of games)
const activeGames = new Map<string, ActiveGame>();
Each game is an object like so:
{
players: {
... |
I read Bertrand Meyer's paper on design by contract yesterday and it is not very clear for me what is the relationship between DbC and testing, since it appears that without testing I cannot be certain all the assertions were hit at some point.
Consider a square root function that has preconditions defined that verify ... |
Is there a name related to the pattern shown in the code that follows? Or is there writing/thinking on the [design of] code shown that suggests it is an anti-pattern? In general, I'm curious if this is somehow a well known design strategy for non object oriented applications (and, more importantly, why or why not).
I s... |
I work for a consulting company and we're doing a software contract for a big company. Part of what we are doing for them is helping them figure out what they want, which means the requirements are pretty much in continuous update mode. We're busy speccing out version 3 while working on version 2 while fixing bugs in... |
I currently design an API using spring boot. In my service layer, I use Entity Manager for accessing the database. I have provided a method in my service layer below as an example.
public Object getFirstReturnDate(Long vehicle_id, LocalDateTime reservation_date){
String string = "SELECT r.reservation_time from Rese... |
Let's assume I have this API on /api/v2/persons that enables me to create new entries by POSTing this JSON:
{
"name": "me"
}
The API is implemented using Spring Boot and if someone sends this JSON ...
{
"name": "me",
"age": 47
}
... Spring refuses to handle it because it can't map the additional value of age to... |
I have a class (as a protobuf) OrderChange, that represents when an order (imagine Amazon.com) changes:
message OrderChange {
Order old_order = 1;
Order new_order = 2;
}
message Order {
OrderType order_type = 1;
OrderCategory order_category = 2;
OrderStatus order_status = 3;
// many more fields
}
enum Ord... |
Given the often wide variety of layout managers available on any particular UI platform, I was wondering if there is something akin to a "theory of layout completeness" that can be used to describe them. Can we reason about all the possible layouts that can be made using, say, flexbox?
An example where such information... |
i'm trying to learn about requirements in software engineering. At the moment i have a example problem i'm running through, where i'm trying to develop a system that allows calculations. The goal of the excersise is to understand the basic general process of requirements and design.
The system has requirements and a de... |
I've seen many SO questions around auto-generating unit tests, or documenting unit tests, but I'd like to go the reverse direction. What I'd REALLY like is to have folks (devs, tech writers, etc) write documentation with embedded code, then, as part of CI, automatically convert that documentation to runnable code, and ... |
Let's say I have a system that parses network traffic, and generates event of things that happened.
example:
ip1 was talking to ip2
ip2 was talking to ip3
etc
Now let's say that these events are published into event sourcing thing (like kafka for example).
I have another service (service B) that listens to these even... |
A fast food restaurant has an existing sql table of transactions:
old_transactions:
transaction_id
item_description
quantity
price
1
burger patty
1
5
2
bun
1
1
3
ketchup
1
0.25
4
packaging
1
0.50
5
labor to make burger
1
1
We would like to create an abstraction on top of those transactions. For inst... |
In https://nvie.com/posts/a-successful-git-branching-model/, Driessen suggests using the --no-ff flag to make the history of commits for the dev branch clear. This is an easy flag for individuals on a multi-person team to forget to add, and it also has the disadvantage of adding extra commits to the history (commits ... |
I recently asked a question on CodeReview SE where using a binary search was recommended, and the author of the answer proved that it was faster than my implementation. During my research on the topic, I came across a table that shows the complexities of a binary search:
These are the complexities of a binary search −... |
I'm fairly new to strongly typed languages, coming from the "jungle" world of JS and PHP. In my current Typescript project(React-Typescript), i'm struggling with a very fundamental question: Should every piece of code expose its own interface, even if that means having duplicate types across my application?
Simple exam... |
Considering there's a map of string constants, most commonly with a key and a value being equal, e.g. in TypeScript:
const itemTypes = {
FOO_BAR: 'FOO_BAR',
BAZ_QUX: 'BAZ_QUX',
} as const;
They are supposed to be used with a specified domain (item type) and can benefit from being referred as keys on itemTypes, for... |
I am currently a university student working on an extracurricular project where we built a 3D printed SCARA robot that will be remotely controlled. On one end, you have the user that is moving their hand and gathering location based on x,y, and z coordinates. Those coordinates will then be sent to the SCARA robot which... |
I am newbie at these stuff and while I was able to distinguish between role-based vs. policy-based authorization models, I can't seem to understand whether there is one between policy-based vs. permission-based. On a conceptual level, what is the difference between them? Can policy and permission terms be used intercha... |
I have the following requirement to design behavior of a software component for logging sensor, which writes data to SD card a:
Datalogging sensor can write data to a FAT16-formatted SD card that is inserted into the card reader slot. When the board is booted and a valid card is detected, a new file is created and data... |
I have a two dimensional data with one dimension is ordered and another one is categorical, for example, country and city_age:
country
age
city
Italy
2773
Rome
Germany
784
Berlin
USA
397
New York
Suppose this database is bigdata.
Now I want to set age range, for example 500-1500 and then search for coun... |
We are building a backoffice web application where people are making changes to an array of nested objects. Because of totally non relevant business reasons there are things that users cannot change but can still send in. It is assumed that some people might not use the frontend but directly call the backend, so we can... |
Assuming I’ve a class with three methods, startCollection, add, endCollection.
One test case is: if start was not called, add should return an error.
I’ve mocked the persistency storing the state with an memory variant, and test it. All fine.
Now I’ve yet another class: a RestController. It also has 3 methods that call... |
I'm currently working on refactoring a project to use the repository pattern, but I'm currently struggling with how related information should be retrieved.
Let's say I have a Hotels and Rooms. I have 3 use-cases that come up:
Retrieve a hotel with all of its rooms
Retrieve a hotel (without rooms)
Retrieve a room
Now... |
I am wondering if it is an acceptable approach to pass instance variables from one object to an object of another class (saving them as instance variables as well) in order to retain the context that is expressed by those instance variables.
In my case I have a ClassB with a method whose return value is needed to creat... |
I am working on a project where there will be different kinds of accounts that use Auth0 for auth and authz. I want to have it so that an account will query my backend to get back documents that pertain to that user. The issue is I want to be able to have multiple accounts set to "own" each document where the number of... |
When trying to design a factory service in a project where i am using a dependency container i sometime find myself in this situation.
I have an interface, in this example ISettingsLoader. ISettingsLoader defines an interface for any class used to represent a page which displays a series of settings.
interface ISettin... |
Background
I work for a company that provides installation instructions for solar panels on roofs. We also provide an API where external parties can provide roof input and preferences, and return an installation summary, instruction guide, bill of materials, etc.
The biggest hurdle external parties need to go through i... |
In my company, we are using Event Sourcing pattern to implement a storage for all changes to the price of a booking. Across the company, different services might try to append events to a booking identified by a booking code.
We use DynamoDB to store the event and it does support consistent read. The thing is in the ca... |
I have a similaire scenario:
int retrievePrice(string productName) {
string id = restApi.get("productid", productName);
return restApi.get("productprice", id);
}
The restApi could also be a third party. In order to make the test self sufficient, I end up mocking the restApi.
If I directly test this method, I wil... |
I have a class with an attribute that is a dictionary of dataframes, where each dataframe is the input data grouped at different levels of temporal aggregation.
I need to add an option to this class so that when the object is instantiated, the dictionary contains a slightly different grouping of dataframes.
Would it be... |
In my application, I have a class which I call a "Signal" (Think Qt signals if you are familiar with that) that represents a one-to-many connection. Objects can register handlers to the signal which, when "emitted" calls each of the handlers.
This is implemented under the hood as a list of function pointers. Making a... |
I was thinking that a Functional Configuration Audit (FCA) point to the Functional Requirements while the Physical Configuration Audit (PCA) is more related to the non Functional Requirements is this true? does anybody has experience doing those audits?
|
C#10 Has extended the property pattern ability, I think it began since #7
EG:
{ Car: { Interior: pattern } }
Meaning you can do some nice pattern matching even in if statements
if (car_var is Interior leather) { .. }
It's been extended to manage switches etc.
In TS: using filters (maybe not), I would like to write a ... |
Consider your have an enumeration that looks like this:
enum ProcessingType {
CONFABULATION, RETICULATION, SPLICING;
}
And you have a web-service that looks like this:
class WebService {
Service service;
@Mapping("/operation/{processingType}")
void process(@RequestBody Data data, @RequestParameter Pr... |
Backstory:
My new employer has Dynamics CRM on-prem and it is used by all office staff and other colleagues that are consultants. All other employees are a working force out on various construction objects, they do not have access to the CRM.
There's a couple of business processes that have to be exposed to that workf... |
I'm writing a function that needs to get libraries (files) for a Company from a folder path. Thereafter it needs to install those in a repository. While doing this I need to inform the user what is happening. Below is the code.
def run(self):
self.__get_libraries(self.__companies)
for company in sel... |
Im working on an application which essentially fills a giant government/court form.
Lets say i have an an Entity Unemployment and Unemployment has a ... thing "Reason why" and there are 6 possible reasons.
"quit himself", "terminated by employer", "went to jail" etc.
Currently those are modelled as "KeyTexts", which is... |
Tests can be very nicely written down using the given-when-then style. Are there similar styles / templates for describing methods and classes in docstrings?
To clarify: There are many sites which describe the docstring format and give examples. According to them, functions and classes usually start with a one line su... |
I want to implement an authentication system. The purpose of the system is to centralize account management and handle the complexity of account security. Internally, I don't want to implement the actual login by myself. Instead, I want to use Azure AD B2C for user login, forgetting passwords, etc.
Our team has other w... |
So I've implemented the repository pattern in a lot of projects, but there seems to be a bit of a discussion on what is right with this pattern. Previously, I've always added Update or Create methods in side of a (generic) repository to modify the entities. This would always save changes to the context.
Recently I read... |
I've noticed that most AST tree implementations use classes for nodes instead of something like a vector. I want to ask, why do most people use classes? Are there issues to using vectors to make AST trees?
|
I have written some code in Katalon Studio (known as "custom keywords") whose job is to map the rows of a Data File to models for testing. Say goodbye to hardcoded column indices and findTestData("YourDataStoreName") all over test case code!
It is defined to be:
package com.xxx.builders
// imports
public abstract clas... |
I asked this over at SO and didn't get any responses after a couple weeks, so I figured I'd try SE...
TLDR;
How do I update nested objects in MongoDB when data referenced in those nested objects changes?
What are the pitfalls of simply storing IDs within nested objects and having the client look up the correct value t... |
User requirements are considered high-level functional or non-functional requirements have to be understandable by end-users and customers who may not have a technical background. We can use diagrams like use case diagrams to help with illustration of user requirements.
System requirements are more detailed requirement... |
I'm searching for any formal/generic approach to modeling a process distributed in time with functional programming. Here is an example.
Let's implement a very simple notification service. It accepts a "task" that can be unambiguously distinguished to be "done" or "not done". When a "task" is "done", the service notifi... |
I'm wondering, although as I think both options are possible.
Currently, there are two versions for Blazor projects in visual studio 2019.
If you want to connect to a backend DB then there are two project solution options:
a "Hosted Blazor WebAssembly app" project.
a "Blazer server-side" project.
Both can handle conn... |
I'm curious about your thoughts on this subject that we have discussed with the people around me. Especially at the architectural stage, in which layer is the most optimal and efficient way to use the messages to be given to the end user (for example, your update was successful, you had an error while adding a file). W... |
I wonder if there is a naming convention or a best practice to name Java Classes when building AWS Lambda functions with Java for REST API?
For example, if I have a Java project that contains Lambda functions to handle CRUD operations, is it a good practice to name Java classes this way:
PostHandler.java - A Java clas... |
When building REST API with AWS Lambda + Java, do you define all lambda functions in a single AWS SAM template or create a separate project for each CRUD operation?
Given that on AWS, each lambda function runs in its own container, and only one handler class is invoked per HTTP Method. It makes sense to define each Lam... |
I'm doing this homework exercise with simple linked lists in C with nodes having the following structure:
typedef struct lista {
int num;
struct lista * next;
} nodo;
So the exercise asks us to traverse the list and if we find two nodes such that node1->num == P and node2->num == Q, we delete all nodes between... |
My idea is that, if an unsigned 32-bit integer is used for representing angles in a way that 0 is 0°, 231 is 180° and 232−1 is just under 360°, all possible values are used and evenly distributed among all angles. Rising large values would naturally overflow to 0, which corresponds to the equivalence of 360° and 0°. (E... |
Since I met the out keyword in C#, I'm trying to find an equivalent approach in JS.
So, please take a look at the code and leave your opinions of existing cases or suggestions of new ways to implement this.
The working version is inside this sandbox:
https://stackblitz.com/edit/js-out
1 null on fail
const number_1 = tr... |
I am using a REST API that is being developed at my workplace. The documentation clearly states the HTTP request type (POST), the URL endpoint, and the "payload" in curly brackets, i.e., various parameters and expected values. At the bottom of each endpoint section, it details response possibilities as response codes -... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.