instruction
stringlengths
34
36.1k
I want to wrap a C library, libcookie, in C++. Setting The library has an object-like structure like so struct Cookie; typedef struct Cookie COOKIE; int CookieGetTemperature(COOKIE*); // ... COOKIE* CookieGetBest(); // Meant as reference So I want to wrap it with something like the following: struct ObjCookie { C...
I am having such a hard time with OOP and databases. Both in C++ with SQL and even more so with Node.js and MongoDB. For this question I will use Node/Mongo. Let's say we have a user object. Over time user objects can get pretty big.. class User { constructor(){ this.name = ''; this.id = ''; this.c...
I'm building at a Build and Deployment pipeline and looking for clarification on a couple points. In addition, I'm trying to implement Trunk Based Development with short-lived branches. The process I have thus far: Local development is done on the main branch. Developer, before pushing to remote, rebases on remote ma...
First, let me explain what I mean by inversion of control and tell, don't ask in this context. I have 4 classes MailController, UserData, Subscription and MailService. MailController is a consumer of object MailService. Inversion of control here means two things: passing in required arguments into each method on the o...
We have all heard of Don't Repeat Yourself and Write Everything Twice, but I've never understood why anyone would prefer the latter of those. Obviously you can go overkill with DRY, with the code ending up unreadable and hard to debug. But why would you want to strive to write more code than is required to perform a ta...
Consider that when working on an Application which is modelled using DDD and implemented using Onion Architecture, you come along a following business case: The Application, as one of its features, allows you to write Movie Scripts. When working with a given Movie Script, you have Characters, to which you can assign Ac...
I am creating a vectorized reinforcement learning environment. It handles multiple instances of a board game in synchron. Up until now, the state of the environment was a specific representation of the board. However, the need arose for running tests with different board representations and later it might expand to inc...
What's the best practice around updating information received from the request? Update all the columns with the values received in the request object? What if there are columns that should be updated when posted by admin and not by the regular user? We have a lot of such situations. Should the backend check what attr...
I have a set of array, containing a large number of objects (products), which has lately grown so large, searching in it takes about a minute, which is considered too long, since one search is expected at every minute. I'm looking for a way to reformat the engine for a more modern/faster one. The objects does have a un...
I've got a 2D map, on which entities interact. Should an entity's position be kept on the map object, or on the entity object itself, or both? Why? What does decide where a property is kept? What questions am I supposed to ask myself when deciding that? Some use cases are: checking what entities are on a given tile (p...
In my current project we try to use DDD as development process and foundation of our architecture. For the REST-Interfaces it has been decided, that JSON:API is our way to go. Since DDD, REST and JSON:API are all rather new concepts for us, I might have some major missconceptions about them. In the example from jsonapi...
Those textboxes, datepickers, textareas, etc... or DB fields. Does anyone know the etymology of it? Why those are "fields"? Is it because a field is an open space area that has no trees growing on it thus representing a textbox with no data in it? I can get why a mouse controller is called this way - it looks like a mo...
Something which has always confused me is this. I keep hearing about how these big, old corporations which were around in the 1950s (for example) and early on started using COBOL-coded business logic on IBM mainframes, which are apparently unable to "migrate to something modern", even though they want to and it's expen...
I read a lot about using ongoing numbers vs UUIDs as the primary key and had an idea how it might be possible to combine both and profit from their advantages, without their disadvantages. The table would have an id column that is auto-incremented and another column that contains a random string [A-Za-z0-9]. A blog art...
I was watching youtube and squinted at the text in the video and wondered what happens when I switch from 720p to 1080p. Does the streaming service, Youtube and or any other, just have the files in different resolution at the time of creation and then ping the client to see how fast the connection is before deciding ...
I started to write a function which had a pointer to a vector as a parameter so that it could modify that vector to output results (as the actual return value was an error code), when I started to think about the memory behind that. Edit: Adding a new example here to make this clearer - I think I mostly have the idea f...
What's the name of the relationship opposite to "inherits"? Subclass inherits from superclass Superclass ______ subclass
I am working on processing of documents and storing their hash in Redis to identify duplicate records and some system files. Recently we migrated to MongoDB from SQL Server as our primary database. So now does it make sense to manage both Redis and MongoDB? as we can also run MongoDB in memory?
I am getting worried I have some terrible design pattern here in JS/Node.js/MongoDB. It seems to that to create an object, I need an object that looks like that object. This includes data that comes from the user or data that comes from the database. It is just a lot of duplication, but I have not figured another way a...
Hello to everyone and thank you for any suggestion. I have a family of subclasses of Track (Track is abstract). Every concrete Track has a different number and types of fields (attributes) that extend the basic abstract track-fields. Then I have a family of file-types that implement some methods (saveRow() etc..). Ever...
I am using some C# pseudo to illustrate here. Below, you will see a Service and a Client (in the context of using DI). The service has a required property that will need to be initialized by the Client. Typically, the client would instantiate an object, and pass any required data through the constructor. Using DI, howe...
I have a web application like this: An angular frontend for client and a spring MVC backend for admin panel. A angular web application requests a JWT token from tomcat/spring MVC. The angular application the uses the token as Bearer for HTTP requests. But now a requirement has come up: The user will use that token ...
I need some advice on the scale-up issue. we have a java application currently it works as below the current system is using the Thread Per Request Model. each client connection (long-running and streaming data from us) will create a new thread in the thread pool and a java internal blocked queue. the disruptor work t...
I'm implementing the validation layer for a certain method on a controller, namely I need to check if certain image ids passed do really belong to the user making a request. In order to do that I need to retrieve the userId from the jwt and then execute a DB query. The problem is that I need to know that userId, unfort...
I have a small project that has 6 service classes and a main class. Since they are service classes and does not store any state in it, I declared one static method in each one: class Main calls A.foo1(param) A calls (in static foo1 method) B.foo2(param2) B calls (in static foo2 method) C.foo3(param3) and so on... Rec...
I have recently inherited a codebase which has a weird problem and I am trying to search for an extensible solution that can solve my issue. Consider I have a model class that is used as a model to populate data in the UI which looks something like this. public class Person { public string FirstName { get; set; } ...
Is it usually recommended to define default values for Boolean arguments? I mean, is it usually recommended to define a function like this someFunction(a, b, x) { // a and b are strings, x is true or false ... } or like this? someFunction(a, b, x = false) { // a and b are strings, x is true or false ... } ...
Hi I am very new to using DTOs, and I am starting to understand it slowly, but there are still some missing puzzles for me. I understand the use of DTOs in the way of decoupling the persistence data model from the data model (representation) offered to the consumers. Also, that the aim beneath DTOs is to gather in a si...
I am writing a c# program where I need to print a lot of small barcodes in a 100x100 grid on a piece of paper. I then scan/photograph the paper and read the barcodes again. Each barcode only need to contain a simple ID code so that I know which which code I am reading and hence where it is on the paper. So a barcode on...
I know that Inline CSS styling gets so much hate from many developers, and I understand that some of this hate is justified by the following facts: Inline styles increase page size as they don't get cashed like CSS files do. But isn't the difference in size minor in most practical cases ? It's hard to maintain inline ...
Typically in any application, the way a user (human) is authenticated is using a username/id and a password, whereas programmatic or api based access is authenticated using API keys (based on system designs that I have seen online). Other than one reason that usernames and passwords work for humans because they're easy...
What is the best way to create dynamic user roles that can have toggleable permissions? I am currently creating my very first website which has a react front end with redux toolkit and redux saga and my back end is Django rest framework. Companies will be able to have their own pages on the website, the owner can then ...
I was trying to understand the use of multi-methods recently and saw several claims that they solve the Expression Problem. However, I ended concluding that it is not the multi-methods that solve it, but the open methods, which usually accompany the multi-methods. Open methods being the methods that are defined outside...
What I need I need a suitable and scalable solution to manage data flow between the classes in my C++ program. Why I need it Upon new feature requests, I'm continually adding new classes to the program. I initially registered callback functions to classes and injected a dependency to the class via an interface: Now, a...
I'm working on a Swift-project (an iOS-app) where a webview is used to show an HTML-document. This document is manipulated by some JS, which is compiled and minified from TypeScript. There's also SASS being compiled to CSS. There's obviously quite some building going on here. There's also quite a bit of package managem...
We have a battery manager implementation which uses a fuel gauge driver and a charger driver. Currently both of these drivers are hard-references to the fuel gauge and charger driver we currently support. Now for new projects, another fuel gauge and another charger have been selected. We would like to keep the logic of...
Should I restrict my backend API (api.cool-domain.com) to be only accessible by my frontend (cool-domain.com)? Seems like it will provide some amount of additional security, I am just asking is it worth the hassle, because we all know about hundreds of public apis without such CORS restrictions.
We all know Joel Spolsky's famous article to never rewrite working code. How about if we don't consider overall program but a module within? Module can be e.g.: payment handling microservice in e-commerce application data access layer (inline SQL to ORM) front-end layer (MVC to Angular) Are there circumstances that j...
I have noticed that JavaScript and PHP and Python do not support function overloading. Do all dynamically typed languages not support function overloading? If the answer is yes, then why is that?
I have multiple WPF applications running different programs some of them are interconnected so one might have to start another at some stage. I need a way to communicate and share large amounts of information fast between them. So far i have tested using gRPC and using one application as a service to talk to a client b...
We have set of common types (mostly structs, scalars, string IDs) that are used across different packages in a project written in Golang. Currently we define them in a package named "models" in the root of the project. It was made to reduce cohesion of different packages and to avoid circular dependencies. Is it consid...
In our team we are currently discussing which technology makes more sense for an upcoming feature - HTTP polling vs WebSocket. To give some context: We are developing a TV streaming application (server and mobile clients). We currently have about 60 TV channels. On some channels we need to prohibit the user from seeki...
I'm working on some tooling that will help speed up the process of setting up a new computer for new developers. I want the user to be able to execute many tasks either as one task or grouped together with other tasks. For example, setting up the server might consist of the tasks A, B, C and D. Let's say that A is inst...
I'm having an issue with dependencies in a C# app that I'm creating. I have an assembly for my authentication process, and a separate assembly for starting up the main program once authentication is complete. My issue is where to put the interfaces between these two systems. The main program assembly doesn't need to kn...
We are developing a serverless application (AWS API Gateway, Lambda, and Dynamo) keeping users and groups in the same microservice as they are being stored in the same DynamoDB table. REST endpoints for the users look like this: /user/invites /user/:userId/save /user/:userId/activate Is the a good idea to have endpoin...
With threads you could use Semaphore, mutex, ManualResetEvent, etc... to sync a shared data, how do you accomplish the same thing with tasks? Essentially, if I have shared data between different tasks that run on the thread pool with Task.run() or that resume on the thread pool on a random thread after an async event,...
So, let's say you've got a function foobar() which can function with a variable number of parameters inputted into it, and has different behavior for each of them. How do you get this to function properly in Python? Are you forced to name every possible combination of parameters something different? For instance, let's...
I'm kind of new to this "separate your methods from models" (yes I was one of those developers). From what I understand I have to separate everything into models, services and factories. A factory creates stuff (where every "new" keyword of your project should be) which is straight forward, but a service takes somethin...
After studying some basics about n-layer architecture, I face to a new proyect where my database is an ERP and the way to connect with it is via API calls. I can perform queries to obtain data but the only way to insert and update is using the API. I have to write two applications, a website and a web service. Obviousl...
We have 1 frontend developer and 2 backend developers and 1 QA. QA is responsible for writing the end-to-end tests using Cypress. FE developer writes the unit tests. Backend developers write the unit tests in the backend repo while QA writes the microservice integration and e2e tests. I'd like for QA and developers to ...
tl;dr: Is it a unit test or an integration test, to ensure that the inputs to a mocked dependency were correct? More details: Suppose I'm given a requirement like this: Create a function that returns the current temperature somewhere on Earth, given the latitude and longitude of that place. Signature has to be int get...
I am setting up a Github repository for a project that will have multiple Microservices. I have created a sub-directory for each microservice under One Repository. ProjectRepository \Services \MicroService1 \MicroService2 \MicroService3 \OtherThings Every MicroService will be develop...
I am building a REST API for warehouse inventory picking. I have a very shallow understanding of REST, so to me that just == stateless and try to make your URL mappings nouns instead of verbs. The picking process looks like this: Scan QR on a the shipping instruction sheet which contains an order number along with al...
My Nodejs microservices currently running on Kubernetes are communicating over REST. Does the request-reply model of NATS, which replier needs to return (large data ~ 500kb currently single endpoint response), cause performance increase? Some benchmarks say it's 10 times faster [1], but I got a bad result on a little t...
I've created a service application that import orders from an SQL database. Right now I'm manually entering the data into the database, but in release a 3rd party application will export orders to the database. For now, while in testing, I'd like to have a test software to simulate orders coming in and out of the data...
I need to make an UC diagram for a project of mine, but I don't know when to use include or extend. My actor (a Professor) can choose one of his students and do some operations (ex: see his grades), now from the diagrams I saw, my see student's grades use case should include select student , but in my app you first nee...
I'm starting to define how issues should be handled in GitLab. Most specifically whether the author should be editing the original issue to keep it up to date or use only comments. Let's say that you start working on a feature. The first thing you do is add a first analysis and design. Now one of the collaborators spot...
I'm currently building an API and a web app for an internal warehouse system using NET Core. I have the core entity structure, that goes like this: "Material" has many "MaterialSubtypes" has many "MaterialClasses" has many "Packs". Now, I need to create a list, representing a single sale. It can include lots of packs o...
Let's say that I have a list of financial transactions that I need to read in from the file. I want to make the best guess I can at what account should be credited/debited based on the transaction memo compared to past transactions. For example, if Wal-Mart was used with 'Shopping' then if a transaction that gets read ...
Is there a canonical definition of SPA which would exclude the software architecture model described below? I'm working on an app with a new web-architecture model (new to me, at any rate) which has features that differentiate it from a Single Page Application (SPA) as the term is conventionally understood. Since the m...
The application I'm currently working on is deeply coupled to the UI framework in use (Qt at the moment). I would like to separate the UI-specific code from the rest as much as possible, with the goal of creating a library for use with other toolkits in the near future. I have already started this work but I am struggl...
I have a design dilemma for a DB I'm creating for an e-commerce platform I want to develop. I have 3 different actors interacting with the website: Customer Manager Supplier Those 3 actors have the same table structure: email, username, address... My initial design for the DB was to create a single table (StoreUser),...
This question was completely reedited to be fully in line with the SE guidelines and builds on top of already given comments. I'll try to introduce some vocabulary to better describe the generic terms I use in my concrete problem setting: Source - A source is basically just a data object with associated jobs. There are...
I have a composite object (I will call it A) that has fixed number of sons (I will call them A1 and A2) All of them have an Accept(Visitor) method. I have a GUI, A is the main window that consists of many sub-windows (a.k.a A1 and A2). The visitors will be visitors for when a user clicks a button to start a new operati...
First actually I don't think Git is a specific involved tool here, it can be any other Source/Version Control tool (TFS, SVN, ...). The point here is how to deal with the scenario in which I have multiple projects, each project may reference other projects but managed by different teams. If we can include all the refer...
I have an ASP .NET web application dashboard that is used to send notifications to several .NET desktop clients. The current implementation is that the web app writes the new notification to a database and the clients poll this database every 30 seconds and look for notifications with flags marked as 'unread'. This isn...
Whenever I do temporary fix I want it to really be temporary. However, there is no way to come back to it later, as the fix might be a part of a bigger issue. Let's imagine that we have for some reason incomplete data in DB. When we fetch it, we get an exception. Temporary fix would be something like: if I didn't recei...
As far as I know, circular dependencies are something to be avoided, yet I find myself often in a situation where I've got some Object, and an ObjectManager, that is supposed to "oversee" all the Objects, and provide methods to aggregate these Object's and so on. Example: Object that has a position and can move itself...
I'm backend developer working on a very backend heavy application. So most of the business logic is writen in the backend. In our project we are considering a full rewrite of the frontend. Currently the frontend code is extremely messy and refactoring stuff takes forever. There are no tests. I'm not a frontend develope...
I'm very interested in the topic of parsers, especially in the topic of parser combinators like Superpower. The problem with them is that the grammars that they can work with are a bit limited. For instance, they can't handle left-recursion nor ambiguities. That's why I got into the tracks of GLL (Generalized LL). The ...
I am writing an API function using DRF where I want the API execution to stop if it fails in any of the steps and return an appropriate response. So I created a custom exception which takes an error code, and an error message like below. class CustomException(Exception): def __init__(self, status, msg): self.status...
I am using AWS CodeCommit with CodePipeline. I have two totally separate AWS accounts, one for test and one for production, identical Code Pipelines setup in each account, each with a corresponding CodeCommit repo. a local code repo on my dev machine. This allows me to push from the local repo to either the test ...
I've got an object with a complex hierarchy, something like: Document Paragraphs Paragraph Words Word and I need to implement a dirty flag on the Document object. In general, there can be a huge number of Paragraphs and Words, and paragraphs and words have many properties that can be changed. So I'...
What are the pros and cons of using agile/iterative approach in ETL/ELT (Extract Transform Load or Extract Load Transform) data warehouses/data lakes/lakehouses systems development? I often find that many business analysts / project managers tend to plan ingesting all data first, then building all semantic data and ot...
I have workflow where I have complex command handlers encapsulated inside aggregate. These handlers emit some events, and then further logic based on result of these events can emit more events. Sample pseudocode of architecture: public class ExampleAggregate : Aggregate { public void Execute(CommandA c) { ...
I'm trying to improve the performance of our server. We have 1 server with around 25 tenants, each tenant has it's own application instance and database. There are no performance issues, until, each instance starts it's cron job every 10 minutes. Everytime this happens the CPU spikes to 90%, we would like to fix this. ...
I have several global variables that I need to store in a database. These variables rarely change, but when they do, all installed instances of the application must updated to those changes, which is why I think the central database is the appropriate place for them. The variables are not linked to any "concept" in the...
I'm developing a new application that allows the user to do many writes. Therefore, it is very inefficient that we use our server-side to handle every write request by users. Should we allow users to write to the database directly, without going through a server process? we're using Firebase so we can write security ru...
In "MVP Passive" where a view doesn't know about it's presenter the view just raises events observed by the presenter, the presenter knows the view and its controls how should view and presenter properly function/communicate with each other? I.e through methods, disposing of view/presenter, interpresenter, other view...
I work in the SAP industry where web-based UIs and RESTful APIs are a rather new thing, meaning some teams (like ours) don't have much experience in designing such systems. Recently there's been a dicussion that revolved about whether our API should be an abstract representation of the resource or client-specific by pr...
SQL Server documentation uses this notation, which is very easy to understand and consume. Is this a BNF Syntax Diagram? Or is this a different type of notation? Source: SQL server documentation page with the original diagram
I have been reading some old design books (SSADM, JSD.etc) on software engineering that deal mainly with a procedural view of creating systems. I was just wondering if we still use these old techniques e.g. splitting into subsystems and modularization even though programming languages at the moment is mainly object bas...
I'm working with services and I found out there are at least 3 ways to use them inside controllers... Statically: Like helper, Text::uppercase('foo') Instancing it: $text = new Text(); $text->uppercase('foo'); Injecting with reflection through parameters: public function(Text $text) { $text->uppercase('foo'); } In...
Question In the context of an MVC, desktop architecture, is there a canonical solution or a design pattern / best practice to give access to an immutable value class to multiple components at different levels of nesting? Use case examples: User settings: Some controllers or views need to access the user settings so th...
Given the same application written with multi-threading and async IO, will async IO use less power on a computer?
I am designing a test for an existing static method: public static boolean hasPermissions(String username, int pageid) { PermissionsService s = new PermissionsService(); int[] pages = s.getPages(username); for (int i = 0; i < pages.length; i++) { if (pages[i] == pageid) return true; }...
Sorry if this sounds like a stupid question I’m very new to this. So my question is; within modern computers memory address space is a byte long, so what would happen to the rest of the address space if left unused as some data types like booleans use 1 bit of space. I understand slack space within other block devices,...
I'm working in a team that won't approve my pull requests until the entire Jira ticket is all included in the pull request. Sometimes the Jira ticket has a huge scope that would otherwise be a dozen different pull requests. They consider my code wrong until it's 100% complete with every single additional feature. This ...
I've been working on a project that communicates with a service which sends very complicated REST responses. Current "best practice" on this team is that we use POJO DTOs to handle all data transferring. If we have a GET endpoint, it returns a POJO DTO, if it's a PUT endpoint, we only accept data that fits a DTO etc. T...
I have a server application that runs in an infinite loop, only reacting to SIGINT. It is put inside a screen process. If I have to make any changes (reload configuration, add new plugins, etc) I simply restart the whole process so the changes are picked up during initialization. I'd love to refactor the application so...
After years of (amateur, dirty) personal API development I finally decided to follow some best practices. My problem: the API may have problems, say, retrieving some data. It will gracefully handle the problem but needs to pass that information back to the requester (a JS front of mine, if that matters). My question: s...
In Kotlin or Java we have many different types: integer, byte, double, long, float, string, character, etc. But one can use an integer instead of byte, and a double instead of an integer. Why we need all those different type? Why we can't just have a double, and forget about integer, byte, float, etc.?
I am working with a very large SQL database through a frontend reactjs application with a node server intermediary using an ORM for query sanitation. However due to the size of the DB it takes some time to search through, sometimes up to 15-25 seconds which makes my react app incredibly slow for the initial load. I h...
My application provides the following resource: GET /user/:id/orders As commonly used, this returns a list of all the user's orders. Now, a client wants to check if a user has any orders at all without actually getting the complete list. My current approach looks like this: GET /user/:id/orders/exist But it looks kin...
In standard POSIX locale strftime(buf, size, "%c", time) will format the date and time in an order that has confused me a number of times because it has month and day precede the time, but year follow at the end. Example (from ccpreference): Sun Oct 17 04:41:13 2010. Since this appears to be a POSIX specification, the ...
We have a microservice whose multiple instances are running for High Availablity and Scaling. But although we have multipe stateless microservice there are some tasks which needs to be singleton. For example, let's say we have to fetch emails from multiple email Ids and do some work on those emails. Now since I would l...
We are using git flow as a branching model, and we have a feature ticket that conceptually is a pretty small feature in the software management tool, in this case Jira. The thing is that the code on the feature seems to be big enough to have it all in one PR, and we can't divide the ticket in the software management to...
I am creating a bank software system. In this system, there are 3 account types: Savings, Checking, CD. Each account from any type has an ID, apr, and amount, and we can withdraw from it. So I can have an abstract class Account, that contains ID, apr, amount variables, and withdraw(int amount) method. But, we can depos...
Consider the following GUI screen (Java Swing) with a list of persons where the user can select a person and delete it. According to MVC, the view observes (observer pattern) the model and updates itself. Business logic and domain data in MVC goes to model (as far as I am aware of). My question is, should the model be...
As a beginner to web applications and front end stuff, I'm really confused about if it's good practice to use the Django template system and its admin interface in commercial applications. As far as I know, the modern approach for web apps is to modularize them between a back end and a front end. It seems that this mod...