instruction stringlengths 34 36.1k |
|---|
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... |
Here is the situation. System A sends the notification as it completes the work items to System B. System A does not know how many items the project consists of. It's just a pass-through system. System B knows the number of items. Once sys B receives the notification for the last item, it has to wait for the final auth... |
I was reading some C++ object-oriented programming notes that mentioned that we should avoid wrapping functions in classes if it is not required, since wrapping 'things' in classes would reduce efficiency.
Is it true that wrapping functions in classes reduces efficiency? What other 'things' could reduce efficiency when... |
After we have developed new features in a sprint the users must be trained for using these features. How does this happen in Scrum? Which role should give the training and how should it be reflected in the backlog?
Is it a developer (team) task or is it a product owner task or someone else's task?
Is it a story in the... |
I'm looking for design patterns to model (java) objects that are partially stored in a database and partially stored some other external source. In my case the external data is a whole lot of files which are read into memory and parsed into objects at application startup. The database contains the part of the data tha... |
I have some projects that share code.
This is my folder structure:
Workspace
+-- Libs
+-- Project_A
+-- Project_B
+-- Project_C
Project_A, Project_B and Project_C use code from directory Libs. I'm trying to find a way to put them into a repository, here is my options:
Put Workspace into one repository.
Make one repos... |
In the company I work with, we have a 3-layer architecture in our micro-services and the flow is like this:
Repository/DAO (entity) => Service (entity) => Controller (dto)
At the Controller level we map our entities to DTOs,
Now I am working on a search feature, and I need to perform a query with Spring Data JPA / Que... |
Context
I've been searching the internet to see if I could find any other information or posts about what I'm trying to achieve, but I had no luck. I don't know if there's a specific term or whatever for my problem, so I'm going to try my best to explain it below. I'm sorry if it all sounds pretty vague, it probably is... |
I have a simple class which looks like this:
class SpecialList {
private List<Integer> varList;
SpecialList() {
varList = new ArrayList<>();
}
void addVar(int i) {
varList.add(i);
}
boolean isVarListSizeFive() {
if (varList.length() == 5) {
return true;
... |
I would like to get some experienced advice about the handling of helper objects. Consider the following situation where we want to build a connector to a third party system. The connector shall translate business objects/entities of our domain into entities of that system and transfer them via HTTP:
abstract class Bas... |
I have a question regarding software design/architecture.
Are there any best practices or design patterns regarding the usage of classes with the same purpose from different libraries?
Let's imagine this simple project P which uses two libraries A and B. A and B both have a class to deal with 3D-Positions (this questio... |
I have question regarding Linux kernel , as far as I understand, to make Linux compatible with different machines and hardware , different device driver is added to the Linux .
I want to ask how much feasible is to add tons of device driver to Linux kernel , suppose after 30 -40 years the size of Linux kernel will be ... |
I have an SQL database in Azure that is ~4.5 TB / 150 million rows worth of data. Users will need to query this database for large sets of data. Right now, I am having users submit their requests through a web application hosted on an Azure VM.
How can I serve the rows pulled from the Azure SQL database directly to the... |
The environment is like this. An attendant is sitting on a chair operating a computer with a piece of software. She can type some text on this piece of software, so that a panel far away speaks that text.
An attendant that type in her terminal some random text so that a panel can "speaks" that random text. Who is the ... |
I need to create a program with the purpose of cross-referencing personal info from a spreadsheet(s), to check for conflicts of interest between clients of 3 different law firms. All of this client data will originate from 3 different spreadsheets using the same template for naming/columns.
I plan to write this in Pyth... |
I need clarification on something from someone more experienced to see if I am on right course with this.
Following Microsoft's eShopOnContainers microservices approach I got interested in building some small exercise microservices oriented system. But everywhere I look I see same examples using Customers, Products, Or... |
I need to add a priority column to an orders database to sort them, which will vary depending on what has already been done (actions taken). The other catch is: there are two different roles that will have both shared and exclusive actions so the priority changes depending on who is viewing the order list.
Profile 1
Ap... |
I've read various posts that polymorphism should be used instead of isinstance, and I agree that makes sense when the use of isinstance is checking the subtypes of a class to determine what to do. However, is the use of isinstance acceptable when checking the type of an object in order to do something unrelated to the ... |
Our codebase is old and very large. Over the years, many developers have worked on the code and frequently refered to the same concept inconsistently.
For example, we have a "number that uniquely identifies the study" or "Study ID". This is refered to as studyNum, examId, Exam, StudyNo, StudyID, the odd StudyUID or jus... |
From my understanding a facade is a class with the sole purpose of simplifying the use of a specific system/module behavior (its methods). It should not contain any relevant logic of the underlying system, just centralize and simplify its use.
My questions is: how to create a facade (ie. simplify and centralize) of a s... |
I have a small doubt regarding the software versioning, I know that there are many ways to do it, but the most common is with numbers and with a length of 3 to 4 digits, I know what each of the numbers mean in this method, my doubts are two but they go hand in hand (I clarify so that I do not cross out the question of ... |
I am implementing quora like application in which I have Post(question, answers, comments, likes/dislikes) as one microservice and User details as another microservice. I need user details in the post microservice. I need to relate user details with questions, answers, comments and also likes and dislikes? How can I do... |
I have a Java application that needs to generate mathematically-defined 3D shapes for a voxel world (Minecraft specifically, but that's not important to the discussion). These include sphere, ovoid, ellipsoid, cone, capsule, and others, and there are two distinct applications that I have for them. Currently I have a ... |
Suppose I have a program.c that needs element_123 to do some operations, and element_123 can be accessed by including agent.h
/*program.c*/
#include "agent.h"
uint32_t element_123 = 0;
agent_get_element_123(&element_123);
uint32_t data = element_123 + some_data;
/*do operations...*/
element_123 may be implemented b... |
I'm working on a project that has two separate versions of the API, v1, and v2 because they wanted to migrate from Javascript to Typescript. Both versions use the same database.
Recently I'm having some trouble as one part of the migrations are in the v1, and the most recent updates are on version v2. I would like to h... |
I use GitFlow as a workflow for versionning for less than 1 month. I've just finished to develop a feature branch which has been merged to develop/. Now, I'm starting a release branch from develop. The release branch will be tested. If tests show bugs, fix will be implemented in the release branch. At the end of that t... |
I have 1000 lines in a text file. I want to read them into some data structure[DS].
After reading them, I will be randomly picking 50 lines from the DS (using a Random Number Generator). Next time 50 more & 50 more the time after that. Each time I use 50 lines from the DS, I want to delete them from the DS. So after th... |
We know one of the philosophy behind the microservice architecture is availability. So suppose we have a project that has 6 services working together. One of them is an authentication service that responsible for creating users and giving tokens and validating them. So other microservices have to communicate with auth_... |
I am reading the book The Pragmatic Programmer and read about the Tracer Code and Prototyping, but I don't understood when to use Tracer Code instead of Prototyping.
As I understood about Tracer Code, I try to hit the target implementing a code that the customer can test in practice and provide me feedback in real time... |
After working through several tutorials and reading various responses on this site, I believe the Abstract Factory pattern would work well for a current project. I am seeking the opinions of those wiser than I to see if I am understanding the pattern correctly.
For my example I'll use a car as the concrete product. I u... |
I'm learning OOP so I decided to start a new project, a chess tournament manager.
Here you can read about chess tournaments https://en.m.wikipedia.org/wiki/Chess_tournament
Basically the user will be able to add players to the tournament, remove them, register the results of the games, change them, pair new rounds, so ... |
I am curious if the following example of testing a class with protected methods is fine.
For example, say you have the following class Foo that has method a() of return type Bar:
class Foo {
protected Bar a() { ... }
// ... other stuff
}
And the following test class TestFoo (using JUnit):
// Question: is... |
I'm building a pipeline that scrapes data on entities, to keep things generic, let's call them Widgets. Data on Widgets is currently unorganized and spread across various sources, including source code, spreadsheets, and issue/project tracking software like JIRA. The pipeline will run at some cadence and regularly upda... |
I am trying to do a computer program that can distinguish the functional and non-functional requirements written in Arabic languages from the Linguistic structure, so I am I look for the things that distinguish each of them in terms of writing. I wouldn't rely entirely on the structure difference, but it will be suppor... |
Pretty much all documentation on microservices I came across explain just one tiny part of some complex system. I am trying to understand big picture. So my question is: Has anyone expirienced in practice multi level AMQP Event Buses across solution when using microservices? Something like shown in the picture?
Or is ... |
TLDR: project scope has crept beyond my capabilities and I need an early exit strategy (in both parties' best interest)
Early last year I took on a gig to develop a web application for a financial advisor. The client had built a mega Excel spreadsheet over a decade of consulting. The client had a vision to automate as ... |
The problem is the following, suppose we have this functions:
from PIL import Image
from magiclibrary import perform_some_operation, stack_images
def load_image(path: str):
if isfile(path):
img = Image.open(path)
perform_some_operation(img)
return img
else:
throw FileNotFoundEx... |
A few days ago I had a conversation with a Civil Engineer with a background in Pascal and BASIC, and we talked about programming in Python. When I was talking, I used the term "code" to refer to a Python program, and he told me that he didn't know what "code" was, that the correct term was "algorithm", and that "code" ... |
It could sound trivial, maybe it is.
I have a new feature branch (say newfeaturebranch, branched from develop), but during the development a new bug is found and fixed in develop.
The bug is found to affect the development of the new feature. How to deal with this situation?
I assumed it would be bad practice to merge ... |
Some parts in our project's codebase implement the repository pattern in a different way from
what we usually do
Here's the example
public class Repository : IRepository
{
public Repository(AppDbContext dbContext, Mapper mapper)
{
_dbContext = dbContext;
_mapper = mapper;
}
public IQueryable<... |
I have a requirement where I need to add some rate-limiting functionality to an existing web application. The application reads transactions from a queue (TXN queue) and processes them in realtime. Each transaction has a unique id, a group id (a certain number of transactions belong to a particular group id), and the t... |
There are plenty of tutorials on the internet on how to build a server that handles its clients through the creation of separate threads, but there is no tutorials (at least I couldn't find any) on how to build a client that receives data from a separate thread and processes it on the main thread.
I have tried the foll... |
I would like to know how manage a type of pull requests. One of my reviewers ask me for a lot and a lot of changes (3 or 4 days doing changes), all related with possible improvements in the code that I thought it is too much and it ends up in a "perfect" and "smart" code. It is difficult to discuss with a person who tr... |
I'm studying DDD at the same time that I'm reading some Khalil Stemmler posts and I'm a little confused about who should initialize the VO: the entity it is related to or the useCase that uses that entity. A simple example:
Let's assume that we are developing an internal purchase system for a company that has suppliers... |
I found in the catalog of Refactoring by Martin Fowler, with Kent Beck book that they mention Extract Function refactoring.
It is a good practice to wrap your related code into local functions to make easy the readability and maintenance of code?
I always thought that local functions were created to avoid writing mult... |
I am trying to build a static program analyzer for a proprietary progamming language for a school project, and am currently trying to implement the parser from scratch.
I was wondering, what are the pros and cons of
Parsing in 2 passses (tokenization followed by parsing to create an AST) VS
Parsing in 1 pass (tokeniza... |
We have a project that loads metric data from various etls and services into an AWS SQS queue, where that data is processed and inserted into a metrics database, also running on AWS RDS.
When we initially designed the database schema, we chose postgres and enforced things like referential integrity via foreign keys. We... |
I've created two separate binary tree classes, with some shared functions/variables and some that are not shared. So I have tried to abstract away the similarities in a base BinaryTree class.
class BinaryTree{
public:
BinaryTree(std::vector<int> &vec);
BinaryTree *left;
BinaryTree *right;
std::vector<int> dataVector;
... |
We have a few developers who are slower than the typical agile expectation. They get fewer tickets completed in a given sprint. But on the upside, their work is more correct and higher quality.
Is this expected in an agile team, where you always get a few that is slower?
|
I have a role that combines the role of product owner with a role of software architect. I have final say for both product and technical decisions:
The Product owner role is similar as in scrum: I get requirement from my customers; I manage the product backlog, decide the priorities, decide which feature/requirement... |
A very straightforward question.
When I think about many of the member functions I create for my classes, many of them can be made static without affecting any functionality whatsoever.
If I do so; are there any practical benefits [or drawbacks] I can expect in terms of memory or performance?
|
in the code base of my job, we use clean architecture standards. So we have controllers, use cases, etc. To name them, we follow this template: {name}{type}, where type is one of the following values: Adaptor, UseCase, Controller, DataAccess, Presenter, and so on. name is a descriptive name of what that type does. For ... |
This question is a continuation of a question originally posted here.
I'm trying my hand at creating a Snake clone with JavaFX. One of the
requirements for the game is to have a sort of powerup food, which
increases the velocity of the snake.
For my game loop, I'm using a Timeline with a single KeyFrame,
which acts as... |
I have an application made up of multiple processes/workers/services which need to send messages to each other that represent units of "enqueued tasks" to be done. I am trying to find the best pattern to use for the type of communication these workers need to perform.
These are the requirements:
Communication is async... |
I'm trying to understand how do controller and presenters work in clean architecture projects and could use some help. Specifically about generating multiple outputs from the use case.
In the Clean Architecture book there is an image that shows different outputs and a single controller for the same use case: Financial ... |
I am a home, amateur developer for 25 years and I just had a bright idea regarding comments. Like all such novel bright ideas, someone has probably already done it and there is probably a consensus on its brightness.
I wrote a complex (to me at least) line of code and wanted to clearly comment it so that I can still un... |
I've been trying to refactor some existing code which is in essence a giant nested procedural call inside what should otherwise be an object oriented architecture. The entry point to the relevant code is a static function, which iteslf calls other static functions calling other static functions etc. totaling to a few t... |
I have a service which is triggered by messages from three queues (which are populated by different topics), and writes the processed results to another system (say DB service) synchronously. The incoming messages are of type insertion, update and deletion of data for the customers of our system. So ordering of the han... |
I am looking for a way to technically describe the behavior of the internal components of the implemented system. I need to be able to describe all the components and the behavior between them:
Internal component structure
Public interface available for other components
Principles of internal behavior based on busines... |
In a program there is an abstraction from an person to a shape. This abstraction is so that collision detection can be performed. Here is my original class hierarchy:
namespace Graphics
{
class Shape {
public:
virtual ~Shape() = default;
virtual void Draw() = 0;
virtual bool CheckCollision(float sample_x,... |
The scenario is the following:
For a project, such as Spring Security available on github, the following is accomplished:
forked and cloned
git remote add upstream URL-Remote-Repository
git fetch upstream
In master branch git merge upstream/master
It for the first time and all work fine.
A new branch is created to fi... |
Currently I'm working on a project that will interact with a database. Based on my research, I would like to develop a repository class which responsability is to write/extract entities to/from a database, as mentioned in Ivar Jacobson's book "Object-oriented Software Engineering: A Use Case Driven Approach" and furthe... |
I have a Repository service that should be Transient. It is used in many applications.
I have a new application that's a Console App, and current guidance suggests implementing my business logic in Worker Services and adding them to the Generic Host with AddHostedService<MyService>() calls.
One of those Worker Services... |
My current color distance formula is a modified version of Euclidian distance (eDist) because with eDist I was noticing weird issues where blue could be used instead of green in some situations when green would have made more sense. So my formula is:
dR^2 + dG^2 + dB^2 + dHue^1.5
*d means "delta" or "difference"
*dHue ... |
Disclaimer: This is a rather broad topic and there is probably no clear right/wrong. Still I would like to exchange experiences with experts of huge projects to learn and improve work between teams.
Situation
We have three teams
Team A and B are developing rather independently
They both depend on a common library deve... |
Let's say I have a controller called MessageReceiverController which is a controller of an API that other services can call and include messages in the requests.
For each of the messages the controller receives, it will process it and then send it to API_A. If response from API_A is successful, it will send the message... |
Consider you have the following code:
class UserContainer
{
List<User> user;
//some methods to get specific users, for example users, which are higher than 1,70meters
}
The User have a lot of different responsibility and features, so in the example the user is our god-class. There a lot of methods which are us... |
This is more specific to spring boot projects and applications whose main USP is its APIs. Now that we can simply create a JAR file deploy it anywhere, what is the point of WARs? Is there a specific use cases where we require a WAR type file? In a normal maven project, or a normal java project, yes sure. But in Spring ... |
Let's suppose we have a table of products, similar to this one:
ProductId
ProductFriendlyName
ProductPrice
84
Coke can
2
When a specific condition applies (the actual condition isn't really important: it could be "on every thursday", "when it is raining in Paris"), the price can be modified.
ConditionId... |
Based on the string "key", I want to get the latest and previous values assigned without using the Switch case.
I need some mapper method that it get the key value as input and map the values for different Data objects and return a list of latest and previous values without using the switch case.
switch(key) {
... |
So my current app process works like this:
Client communicates with my API to get certain information
My API needs information from a third-party API and uses these to create a response for the client
API sends response back to client
However, in order to access the third-party API I have to provide a basic authentic... |
Correct me if I am wrong, but regarding file I/O and concurrency, I understand that it makes no sense to read 2 files concurrently, since the data bus cannot be used simultaneously. This means that trying to read 2 files concurrently will, at best, have the same performance as sequential reading, and worst on average, ... |
I am tasked with making a program that will roughly have the same steps as a program that a former has written. The program that I'm trying to imitate doesn't seem to be open for extension, otherwise I wouldn't be writing another similar program. Below are the steps in the written program with the corresponding technol... |
The title really says it all, I want to have all the readable memory of another process in a buffer. I understand that I will have to use ReadProcessMemory(), but If I'm correct I can't just use one call to ReadProcessMemory() starting from address 0 for example, because there would be addresses that are non readable i... |
Say I have a have request payload
PUT /user
{
email: "invalid"
...
}
In the backend there is a email regex, which I cannot modify. Currently the behavior is to output:
{
"error": "'email' fails to pass regex '<some_regex_here>'`
}
Should I go with existing behavior or change the output response to
{
"error": ... |
If I have a list of objects that need to have an operation performed on each, is there a best practice in abstracting the loop or not?
Looping over list and call
def func(item):
some_op(item)
some_other_op(item)
for item in items:
func(item)
Call method and loop internally
def func(items):
fo... |
Imagine having the entity Counter and a use case that creates it. Moreover the business logic requires that every time a counter gets created a background task that increases the counter every 1s must be started too, should terms like "scheduling" appear in a use case?
class Counter{constructor(public id: String, publi... |
I'm looking for something that might be described as a "Scaffold design pattern".
I'm in the process of resurrecting an old piece of working but very buggy code that implements a Finite State Automaton in Java - you provide it with a model defined in XML and then you can throw events at it and query the resulting state... |
I know various forms of this question have come up before, but none of them quite seem to answer in a way that I can apply to / understand in relation to what I regularly see others doing. Specifically, when dealing with a Spring / Springboot / Seam project, what benefit is there to having a separate implementation and... |
What best practices do large software companies recommend when introducing a breaking-change to their software development process? Put another way, how do you best communicate these changes to fellow developers?
For example:
compiler bump / switch
library upgrade
dependency introduction
|
We develop web-applications using a javascript frontend framework (ReactJS), to retrieve the data to show, the user's browser calls an authenticated REST API which is our backend (Kotlin+Spring), the backend then connects to the relational database to retrieve the data (see the sequence diagram).
Our customer doesn't ... |
I have a function that was written because several methods used the same sequence of code so an abstraction was useful. The function takes a string representing the path to a registry key and then a list of 3-tuple containing attributes to update the key.
This function is subsequently called updateKeyAttributes:
_ROOT_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.