instruction stringlengths 34 36.1k |
|---|
I'm developing a text editor and start to think about key bindings.
Which F key (F1, F2, F11, etc.) should I use in my application, assuming that I want OS X users to be able to use it as well? I don't want to bind keys that are already used in Windows, Mac OS or Linux common distributions.
|
I am writing a new application where the clients want to communicate using files over (S)FTP.
The first use case is that the client puts a file on the FTP server at end of day.
I then process it and upload it line by line to my REST API.
The second use case is that there will be 2 or 3 drops intra-day for error process... |
In my experience, all languages I know have a sort of "positive" type system. What I mean by "positive type system" is that when you are writing the source code, you always specify what types your function/objects accept, like:
function f(SomeType argument) { ... }
But I have never seen something like:
function f(Abst... |
Please help me with the following code refactoring, I spent so much time researching it and there's still no clear answer on how to approach it. Any help is greatly appreciated!
So, given 2 methods (C#):
private void func1()
{
int i1 = 0;
bool b1 = false
foreach (Object item in List<Object>)
{
... |
I was recently part of a TDD development team. At certain point I realized that there is a design mistake instead of Object Oriented Design and Structural design the problems were solved via statuses. Tens of statuses. For a brief moment I thought - Hmm... maybe I can actualy try to do some modeling and reduce the stat... |
I have a set of UUIDs that I want to assign to a set of people. I want to deliver these UUIDs to people in a secure manner, such that everyone knows that I do not know which UUID corresponds to which person. I.e., I want it to be publicly verifiable that the assignment process was random and that the delivery process w... |
I have a stream of documents, each having an ID which is a 64 bit unsigned long given as a (maximum length is 20) string.
Sometimes an ID appears multiple times in the stream. I don't want to process a document if I already processed it, so I'm using Redis to cache last 20M document ID's. If 20M is exceeded, cache can ... |
I am using DDD pattern in login micro service used in employee management software. Here Organization/Company is an Entity and User is one more entity.
What are my aggregates in this case, if i think with project in mind which is login i will have only one aggregate(user aggregate) but if i think as business in my mind... |
I'm trying to understand the following description of implementing the visitor pattern with an internal iterator. It is from the GoF's Design Pattern Elements of Reusable Object-Oriented Software book Page 339 (More context is provided below and in the online version).
The main difference is that an internal iterator ... |
I have to replace an old application (Database, C++ UI) which is mainly for data administration, with on a new application (Same Database, Spring-Boot, Angular).
We want to document how the application (the old and the new) handles every attribute. That is:
Name of the attribute
Type of the attribute
Location in UI
Lo... |
In our organization we sometimes have to create a poc (proof of concept) to either validate or invalidate the way to go. Currently we're having a discussion around how to embed this within our development/testing process in the app and thus the same repo itself. It would be nice that the poc can enter the internal test... |
I've been told on StackOverflow this questions was off-topic so I'm asking here:
From this webpage (ISO/IEC 22275:2018):
This International Standard defines the ECMAScript Specification Suite containing the ECMAScript programming language and its required and optional built-in libraries.
As I understand, ISO releases... |
Is there an idiomatic way to catch an exception when multiple methods may throw?:
try:
someMethod() # raises OSError
someOtherMethod() # raises OSError
except OSError:
handle()
The exception may or may not be caused by the same event internal to the helper functions, so in the current layout it seems imp... |
I'm trying to figure out how to integrate one command that updates multiple Aggregates in different contexts in a video game. The components/considerations for my particular design are DDD, CQRS, Ports and Adapters, Event-Driven Architecture, Aggregate+Event Sourcing, and Entity-Component-System. It's a lot to manage, ... |
There are many ways to secure the REST APIs, from authentication and authorization view point. Below are the two which I know so far:
Using existing token based IAM solutions like Okta, KeyCloak, Auth0, etc.
Pros: Already proven solution, feature rich, easy to start and run
Cons: Difficult to customize as per needs a... |
I have a 'processing' function and a 'serializing' function. Currently the processor returns 4 different types of data structures to be serialized in different ways.
Looking for the best practise on what to do here.
def process(input):
...
return a,b,c,d
def serialize(a,b,c):
...
# Different serialization ... |
To set up the problem, let's imagine we have a downstream service that we need to call for some information. We set up an API endpoint and call another method which will hold our business logic and make the HTTP request. Based off of certain parameters that were sent to this method, we may potentially have to make seve... |
I want the user to be able to provide a custom WHERE statement against a mysql-backed platform... do I need to worry about any possible SQL injection attacks notwithstanding invalid sql? See the pseudo code below.
return sqlExec("select a,b,c from mytable where %s", args[0])
Okay, in all seriousness I can see where th... |
The standard way that types are handled in programming languages that have such a concept, is that they are:
removed entirely at compile time and are just used to determine memory layout, function pointers etc...
left in some form as a sort of tag on a structure in memory, so that you can check if B instanceof A and s... |
I am working on a spring boot maven project in Eclipse IDE. And here is my pom.xml.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/mave... |
I am working on a personal project for more than 6 months now, this project is composed of three distinct parts, simulation (wrapping a software),
database related stuff (store the simulated data in a database) and modelization (a lot of machine learning related stuff)
To manage my config (paths and few constants) I st... |
CI/CD options such as bitbucket pipelines and github actions make use of virtual machines called runners. Changes in source code trigger the runners, which in turn trigger a set of commands. The commands may include instructions to run a test suite. The test suite checks whether source code changes break existing funct... |
I often define variables that will never change, i.e. constants, at the top of a script/module. But recently I've been wondering if it makes sense to define them at the function scope level if they are only used by a single method.
LIST_OF_THINGS = [('a', 1), ('b', 2), ('c', 3)]
def some_op():
for thing in LIS... |
Is there any specific category an ADT must be in? I'm struggling to find out how best to represent objects in the program for example:
As a record:
struct Person {
int age
};
Or as an ADT:
struct Person { int age; };
typedef struct Person* Person;
void Person_SetAge(Person person, int age);
Both represent the s... |
Currently I have an structure of PopUps and I've been thinking to use Chain of Responsibility pattern, but the difference is a popup can back to previous one PopUp and also can go to any other PopUp.
I've been thinking to use chain of responsibility, but I think maybe is not the Ideal once chain of responsibility only ... |
I have a REST API server with its own authentication methods. I need to provide to some third party apps an authentication solution which should be processed on my server, I don't want them to handle the user's credentials.
After some research I found that in order to avoid using a third party solution as Auth0 I may n... |
In his book Implementing Domain-Driven Design Vaughn Vernon suggests to reference other aggregate roots only by identity and not by reference, like this:
// Aggregate Root
class Order(
val customerId: CustomerId // reference by ID
)
He argues that this would prevent accidental modifications of the referenced aggrega... |
Background
Tertiary to this question, I have been building my own imageboard that prevents [for example] duplicate images from being downloaded again and again on behalf of the client. How I do this, is that I keep all files in a database with a key being a hash of the file. The client sees the hash, and first checks i... |
In AWS you can easily create a RESTful API using API Gateway. With a serverless approach, you would have API Gateway integrate with Lambda to handle your endpoint logic. This seems like the most obvious approach, as its very elastic and cost effective, however, looking into architectures for large companies, most of th... |
What is the right software license to use in order to be able to sell my application, have it be open-source, and still be able to accept pull requests?
I am developing a productivity/utility application for Windows. I would like to release that application on the Microsoft Store as a paid application, with a free tria... |
I have been developing control software in C++. My hardware consists of a microcontroller with an integrated a/d converter and an external on board a/d converter. Both of these a/d converters have different features but there are some commonalities (both of them are capable to offer value of
given analog input).
// ana... |
I'm trying to figure out how to structure a 3rd party integration microservice, and how to name the classes accordingly. If you had a classic shopping cart application which processed payments for different credit card vendors(Visa, Mastercard, etc), this would be for a credit card microservice for exactly one vendor.
... |
I have some fairly complex code, that is a chain of API calls. The result of one call is the input of the next.
class PaymentService {
func pay(userId: String) async {
let paymentSource = await thirdPartyService.createPaymentSource() // A
let order = await orderService.createOrder(paymentSource: paymentS... |
We have a microservice that integrates with a third party system via REST API to handle appointment booking for our customer. It takes advantage of the event-driven model. Our microservice emits out an integration event called the AppointmentCreated event post-appointment booking with the third party service.
The Appoi... |
Firstly, this is a really tough topic to do searches for because you get a wealth of information on “code review”, which is different from what I’m referring to here. That normally refers to reviewing new code that is being introduced into the codebase. That’s not what I’m interested in here.
The basic problem: You ... |
In software engineering, often developers will utilize three different states of a signed integer, as a trilean:
This tends to be quite typical:
-1 - Represents something akin to a null pointer, as in it has no initiation or use or meaning
0 - Represents zero or false
1+ - Represents a valid value
In this case of QIO... |
Regarding cryptography and the issue of collisions, I posed a question as to whether it was ever possible to store every single possible combination of a bit array of a particular size, in a bit array that was at least one bit smaller, with apodictic certainty that no collision would occur.
The answer given to me by on... |
I work with Python classes that define properties that return some privately managed data member. When accessing this data in the body of other methods, is it better practice to use the public or private interface?
class A:
def __init__(self):
self._x = something
@property
def x(self):
return self._x... |
So, today I was reading a piece of code I found this function:
Public Function FolderExists(sPath As String) As Boolean
Dim FSO As New FileSystemObject
On Error GoTo errHandler
sPath = Trim$(sPath)
If sPath = vbNullString Then Exit Function
FolderExists = FSO.FolderExists(sPath)
Set FSO = Not... |
I am currently working on a library that provides functionality for interactive terminal applications.
For now, I implemented functionality for reading an arbitrary keypress from the User to the application as well as setting the currently active color.
I want my library to support a broad spectrum of terminals on diff... |
Take the following signature
BigInt* addBigInt(BigInt* arg1, BigInt* arg2);
Traditionally, the safest way to implement this function would be for it not mutate the arguments, and would necessarily need to create a new object to result for the operation. Alternatively, if the aim is to conserve on system memory, arg1 c... |
I am working on a python framework for building a special kind of editors (so they have GUI) and I just split it into backend and a frontend (distinct libraries), s.t. another frontend could be implemented in the future. I started the project with Qt (PySide2) and because there is potential for realtime data processing... |
I am working on low level design of cab booking type of system and feeling stuck at modelling Vehicle in Booking class.I came up with following design.
Class Vehicle
{
}
Class Car extends Vehicle
{
CAR_TYPE type;
}
Classs Bike extends Vehicle
{
}
... |
The book Design Patterns: Elements of Reusable Object-Oriented Software says to use the builder pattern when
The algorithm for creating a complex object should be independent of the
parts that make up the object and how they're assembled.
The construction process must allow different representations for the
object th... |
I think download rates may depend on these 3 factors: the Network Infrastructure (router, VPN, network card, towers), the RAM or cache, the Final Storage (HDD or SDD or whatnot).
So we take this as an example: I have a very slow HDD Drive and very slow RAM but a very fast network adapter & router.
When downloading, for... |
I am brain storming on how to create a type system for a programming language, and what the compiler will do with the typing information. Here is what I have found, followed by the main question, which is if I can represent more complicated "validations" as types somehow.
First, it seems there is a difference between t... |
Suppose we have a code:
for(int i=0;i<n;i++) sum+=i;
We say the time function here is: f(n) = n+1+n = 2n+1. The order of the time function is 1. So, our time complexity becomes O(n).
But, for the following code:
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j*=2)
{
statement;
}
}
For this code our time ... |
I am building a storage engine software that allows concurrent data writing, now I have two different choices here:
Method 1. Background Long-Running Thread
Multiple user threads write to their own WriteBuffer
A background long-running IO thread iterate all write buffers and flush each write buffer one by one. (Need t... |
If you have a big legacy application (big ball of mud), lets call it MudApp.
If you then create a new application to make us of new technology and to make a new good looking frontend because that was impossible in the MudApp. This new application is supposed to the fresh one and with only the most important features of... |
Given a curi like [auth:password_reset_confirm], what do you call the part before the colon and what do you call the part after the colon?
I have a json payload with come CURIs that look like this:
...
"_links": {
"curis": [
{
"name": "auth",
"href": "http://<IP>/documentation/auth/... |
I would like to know what best practices exists out there with regard to micro services, CI/CD, testing and Git workflow, especially the way of working given the constraints that
a) nothing should block a prodfix, and
b) some commits/features need manual testing.
c) PR process
A little more detail.
a) Given the need to... |
Let's suppose i have a viemwodel which requires a lot of different children viewmodels.
An example could be a settings menu: the main viewmodel should be able to load large number of children viewmodels (in the example image there are 3, but they could be an arbitrary number, even up to ~20)
All of the viewmodels are s... |
I have been developing a control software in C++. From the high perspective the control task can be basically divided into several subtasks
calculate unmeasurable physical quantity based on dynamic model of the controlled system (MachineModel)
based on calculated quantity from previous step and reference value of the ... |
I have been reading about inversion of control and dependency injection and I was wondering the following.
Is there a good way to tell when it is okay to initialise an object inside a method body of a class and when it's better to pass it as a constructor dependency?
For instance I was doing refactoring after finishing... |
I was reading an old text book "Beginning C# Object oriented programming" from 2011. The author in one case employs the "use case" to identify classes and then goes to draw a class diagram. In another case he goes through a textual description of a user scenario belonging to a "use case" to do the same thing.
This made... |
within the sequence diagram it is possible to return a value, with return of a method edge, however this is usually done with a simple numeric or string value. Is it possible to return a whole object? For example, I have the task to create a coffee and put 3 sugars in it.
Classes: initiator-Customer, Coffee and Sugar.
... |
My project comprises of serveral bounded context which communicate with each other with RabbitMQ
The front end of the project is written in C# and the backend is in Java.
The RabbitMQ communication happens with JSON payload. The backend of the application defines these payloads as JSON-schema files that are used to aut... |
I am wondering how to deal with nested resources in a REST API. I've seen other questions on the subject here, but I didn't find one that answered my question. More specifically, should POSTing/PUTting of the parent resource should POST/PUT/DELETE the nested resources?
For example, I have a REST API with Persons and th... |
At work there is a given task where a python application is currently running on a server, this application is using a enviorment file, which has username and password information. The current ask is to encrypt the username and password string such that only application is able to decrypt the username/password and use... |
I am newbie to programming and I am confused how to design an entity objects/classes.
For example I wanted to create an animal kingdom in my application.
Do I need to create a single Base Class (animal) for all the entities or should I create a single class and add a property which describes what the object is.
Example... |
I recall a principle that a professor talked about while I was in school (back in the mists of time) that went something along the lines of "A method/function should either orchestrate other functions, or perform small, a specific task", but I can't for the life of me remember what the formal name of that principle is,... |
I have AggregateEntity
class AggregateEntity {
private Enum enitityStatus;
private EntityA entityA;
private EntityB entityB;
private EntityC entityC;
//.. more here
public final void assertThatPolicyIsFulfilled(AgregatePolicy policy) {
List<Violation> result = policy.checkEntityA(entityA... |
I have an interesting and problem I'm facing. I'm trying to maintain a set of metrics independently based off of a time frequency.
Note: This is a simplification of the problem I've omitted pieces of the code the remain brief
I have a simple architecture which looks like so:
public interface INode<TIn, TOut> : IBaseNo... |
I have no idea how to structure this use case... Basically the requirement is that we want to handle tasks.
Let's say we have a class Task with the following fields and functions:
PlannedStartDate of type DateTime
PlannedEndDate of type DateTime
PlannedEffortInSeconds of type Integer
GetPlannedDurationInSeconds() that... |
Is it an anti-pattern or code smell to put "general use" functions (examples below) into a catch-all file named "helpers" or "utils"?
It's a pattern I've seen quite a lot in the JavaScript world, which I've also seen with other languages.
By "general use" functions, I mean functions which abstract away some common, sha... |
How would you engineer this:
You have a legacy application that is a big ball of mud and a monolith. This application is "impossible" to change to look good on mobile devices.
The management is pushing to make it mobile friendly and more graphical appealing and to modernize it. Therefore a new frontend is needed that l... |
I find myself applying a certain pattern again and again and I assume I am not the first one. I am looking for a name.
In the environment I find myself in we get updates to values via an external interface. Based on those updates, we have to produce certain effects. Practically, our effects not only depend on the curre... |
I'm trying to come up with a better way to organize my C# projects on SVN. The .NET solution for my main GUI has about 28 class library projects. These libraries fall into two categories. Some of them are general and could be used in many other places, and others are specific to the project our company is currently wor... |
Assume a rather simplistic model:
class Person{
static List<Person> LivingPersons
String Name
List<Person> Dependents
}
From this it can (hopefully) be seen that a single Person object can be both within the LivingPersons list and within the Dependents list of another Person object. Similarly, if there w... |
We are talking about implementing Domain-Driven Design at my company, which sounds like a great step forward for us. That being said, I am left with a few questions after a couple of days of research. For reference, we are using a model that has: data, business logic, API, UI.
The biggest gap in my understanding is how... |
[I am preparing to solicit proposals for database/project management software design. I know that the quality of the final product will depend on how clearly and completely I can organize and explain the needs of my dept. to perspective consultants.]
What I've done: Started trial accounts with a few free project tracki... |
Let's say our web application handles "orders". An order can be displayed in several different pages of our web app, on each one, in a very different way.
For example: in page A, it shows just very basic information about the order (like it's date and total value). In page B, it shows also information about the user re... |
I'm creating a multi window gui program, in c++ with Qt Widgets. I do have many custom gui elements, which usually are c++ classes inherited from QWidget or other Qt elements. When foo is the main window, it often looks like this:
Foo = new Foo();
Bar1 *widget1(foo);
Bar2 *widget2(widget1);
Bar3 *widget3(widget2);
Bar... |
I am looking for an elegant way to manage workflows and rollback when needed but the system is depending on various external services most steps of these workflows are triggering by external sources (like webhooks).
An example scenario for a subscription system:
User sends a subscription request
The subscription creat... |
Is it a good practice to hit actual database for Integrations test(Not prod but pre prod DB) for Jenkins Night builds?
The reason I am asking this is because our DAO uses procedures to perform simple CRUD operations so it is almost impossible to test operation like INSERTS/UPDATES/DELETE even against in memory H2 d... |
I'm wondering if there is a widely accepted convention for naming base classed in OOP. Does marking a parent class with "Base" indicate that it's abstract or that it's just an extended class? Or in other words, is it better to mark abstract class with the word "base" or classes that have multiple extensions?
For exampl... |
I'm using event driven architecture, to perform realtime signal proccessing and to provide independent metrics.
I decided to use a redis cluster to act a cache and a message bus.
I'm a bit confused on the best route for the architecture. Each node has other nodes which subscribe to it's values. Some of the nodes the ... |
I have a program that uses OMR to scan a photo of a "scoresheet", and give a result. Its functionality is:
Scan one photo
Compare with database for which "template" to use, identify the coordinates for blocks, etc., "correct" and "incorrect" answers (both for which one(s) are correct/incorrect, and the values assigned... |
What is considered good practice for application security wise when returning errors from a backend API?
I have inherited a project with a lot of technical debt, which I intend to improve.
One noticeable problem is that error codes are not informative at all. Sometimes it gives a 500 "error", with no further. Sometimes... |
Backstory
In an effort to store partial and full downloads to file in a clean manner, I had utilized QSettings which stores its key value pairs in the INI format in a single file.
https://doc.qt.io/qt-5/qsettings.html#Format-enum
After a short while of storing the downloaded file's byte array, the INI grew to over a gi... |
TL;DR: What would you look for in a collection of documentation when taking over an app to be run a larger scale than originally designed for?
I've been tasked with writing documentation for an application I've never worked on. It's legacy code that was written by an intern some years ago so it's not very well architec... |
I've run into the following situation multiple times, and in every case have struggled with the naming.
I want a class to force its children to implement a method, but I want the parent class to be able to override this behaviour if needed. For example:
public abstract class ParentClass {
public bool debugOverride... |
I'm a software engineer that primarily writes C code but now and then makes .Net applications for fun. This is a question about the fun part. Over a duration of about 15 years, I have used and expanded my own framework and now I am stuck. I would love feedback from someone who has experience in writing complex applicat... |
Let's have many rows in the SQL database where every record has an image property that holds the path to file in the filesystem. Many database libraries have the ability to set-up hooks that are called right after the row is removed.
Which one of the following patterns is better?
Call hook for every removed row (even ... |
I would like to know what is a more appropriate way to code in Java. Is it generally better to pass entire objects in the method's parameters or just using the fields from the class?
Using the field:
public class Dictionary {
ArrayList<Definition> list;
public Dictionary() {
this.list = new ArrayList... |
A while ago I read an article stating that overhead of an async/await call was around 50ms. More recently I read an article that it was around 5ms. I was having a discussion about whether we should standardize async operations for all DB access and decided to take a crack at measuring it myself. And I ended up adding t... |
I've seen method references in PRs and comments and documentation but it's unclear what the specific symbology means.
E.g. ClassName#myMethod or ClassName::myMethod or what about ClassName::CONSTANT
Is there a distinction in the # and :: notation, does it say whether one method is an instance method, a static method, a... |
Context
While writing a bash script I would like to test every command I write. To do so I create a separate function per command that executes the function. In addition I want to log the output of each command to be able to inspect the results later on. My doubt is about whether I should test the output of the command... |
Context
Let's say I have the API endpoints /api, /api/accounts and /api/accounts/{id}.
As far as I understand, the idea is that a call to /api gives me a list of "base" API calls, among which is /api/accounts. Calling that will give me a list of entities, with each providing a follow-up link to the respective /api/acco... |
I am planning to develop a mobile app. But I don't want my developer team to have copies of my code in their local system (like in the case of git where you can clone the repo to your local system).
What I need
I need the code to be on a remote server.
The developers log in to the server and develop there (So they wil... |
I want to write react native app. The main functionality of the app is location based - I fetch some locations from Yelp api, but how do I tackle new businesses?
My current solution: I fetch location places with this yelp api. I can search for "bars", or "pizza". Then I have some results, coming in the following format... |
tl;dr: correct way to add git to existing website project with dev subdomain on same shared hosting server?
I have some side project websites. They're all on shared hosting. I've never used version control on my side projects, instead I just created a subdomain for development (like dev.myproject.com) and copied update... |
My SmsRecipientDetails class constructor accepts String value as recipient phone number.
I would like to accept number with spaces:
assertDoesNotThrow(() -> new SmsRecipientDetails("123456789 "));
assertDoesNotThrow(() -> new SmsRecipientDetails(" 123456789 "));
assertDoesNotThrow(() -> new SmsRecipientDetails(" 123456... |
I have a legacy service written in a procedural style which I am rewriting. I
want to improve the maintainability first and foremost; the code gets tweaked
often as the business rules change over time. Hence, I want to decouple a lot of
things, encapsulate as much of the logic in their own objects as possible, and
make... |
I need to design a way to notify my user the SPA has updated if they don't refresh their browsers, i.e. if no requests to get index.html is made after the initial load, how do I notify users the javascript or css files have updated on the server? Note, it is not the REST api that my SPA communicate with updates but the... |
I've built an RSVP web application with a React front end, Node.js backend, NGINX webserver, SQL database and hosted on a DigitalOcean Droplet with Ubuntu. The issue is, every time I want to launch the application with different content (i.e. different events, locations, dates, etc.), I need to manually duplicate the c... |
I'm currently in a situation where I have multiple derived class types(just one is shown in the example below) that need to apply some logic before and/or after calling a method implemented in a common base class. I have two scenarios below and was wondering what would be a downside and upside for each approach in this... |
Is it viable to leverage both a graph db and a relational db at the same time for the same data sets? Does it even make sense to approach the solution this way?
Thinking is i use nodes and relationships to demonstrate the connections between entities, and relational db to store the deeper detail about the entity.
For e... |
Some classes have methods that don't match up with procedural data abstraction. Here is an example of a problem hierarchy, the Render() method doesn't seem to be part of an procedural data abstraction (required for ADT) at all.
My question is should the Render() function be inside the class anyway and why?
#include <So... |
I have recently come across a concept of transactions. Seems like they are a crucial feature for production applications, yet I have never heard about them except once in a university. I can't remember a single tutorial on youtube / udemy that actually manipulated with db using transactions.
Maybe if so few people talk... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.