instruction stringlengths 34 36.1k |
|---|
We are designing a system, in which we need to store amount of SalesTax applied as well as Tax percentage value. We decided that we will keep tax value in separate table (simplified example):
Taxes table:
+----+---------+---------------+------------+------------+
| Id | Area | TaxPercentage | StartDate | EndDate ... |
For example our App have Access Groups feature which may be enabled/disabled for the User.
So we would have multiple checking for feature status in different layers like:
if ($user->access_groups_enabled) {...}
This may be in all kinds of App layers, f.e. checking is needed for sql queries logic (if AG disabled then s... |
Sometimes a class A can have an "associated" class B such that the implementation of B depends on the implementation of A. For example, this can happen when B's objects are to be created by A's objects and are to be "linked" to their creator object.
An example from Python: dictionary view objects are created by certain... |
I'm thinking about "simple" problem. I have database with messages and email adresses to send:
emailAddress string
message string
Sent bool
Is it possible to write a system in which I can be sure whatever happens that email will be sent only once? I don't care if it was received, lets assume that email send operation... |
I am designing a MVP for a simple gamification system for a trampoline park(s).
External company is providing bracelets for customers, then collecting this data in their own web app, where they extract things like "time in air", "number of jumps" etc. in real time from accelerometer readings (x,y,z)
I need to receive t... |
I have a git repository and I would like to add the installation steps required to make the project work locally. The project is a company and private project and users will also be contributors. I'm using GitLab.
But I don't know in what file to write these steps. I have several options in mind such as:
the README.md... |
First bounded context: Requisites
Here we store user's organization requisites (Title, Logo, ID numbers, Bank requisites)
Second bounded context: Bank Integration
Here we have all use cases that somehow connected with integrations with user's banks.
Use case 1: User adds new bank account requisites from UI.
RequisitesA... |
I'm building a multi-tenant system that consists of one (SPA) client, calling multiple API's, all under my control.
User authentication is done with OpenID Connect, I'm sending an ID and access token to the client, the client uses the access token to call the API's.
At this stage, the API's know they receive a request ... |
According to my understanding, in the MVC design the Model can only receive the functions calls from the Controller and not from the View directly.
Is it true that the Model can change or access the View directly?
|
I need to set up newsletter signup for a site.
Initially, I was eyeing services like MailChimp and SendPulse, but I'm not comfortable with their prices and I'm not really keen on sort of giving up control over and giving them access to the mailing list (for both mine and my users' sake).
The downside of not picking suc... |
I have a repository function on my repository layer. I use sequelize as data access. I will write tests for my function.
Here is the logic I want in English:
My function should save a user to database by using the email and password
My function should return an object representation of my created user.
For the logic ... |
I'm modeling the "Domain" Layer of "Clean Architecture" for an application that gets its data from an XML file when starts.
The XML file looks like:
<?xml version="1.0" encoding="UTF-8" ?>
<BluePrint>
<BluePrintVersion>1.0</BluePrintVersion>
<BluePrintMaxMetaData>500</BluePrintMaxMetaData>
<ZoneData>
... |
Why is it that some abstract methods in interface hierarchies are redeclared as abstract further down?
iterator() for example, abstract in Collection is redeclared in Set and List, and again further down the Set hierarchy in NavigableSet.
I'd like to understand why this is done from a design point of view, or if there'... |
I was given an API document that contained this diagram. And I was amazed at how cleanly it presents the flow of data between multiple endpoints by putting the end points in vertical silos. Data event flow moves from top to bottom, going back and forth across the diagram.
Is there a name for this kind of diagram in pa... |
Say, our team owns 3 services, one is responsible for creating persons, other is responsible for creating buildings, and 3rd one is responsible for creating jobs. Also, we have one website, which is connected to all these services. Now, we want to add a functionality on our UI that would take a CSV with fields asking v... |
Doing a code review, I ran into this assertion in a unit test:
assertThatThrownBy(() -> shoppingCartService.payForCart(command))
.isInstanceOfSatisfying(PaymentException.class,
exception -> assertThat(exception.getMessage()).isEqualTo(
"Cannot pay for ids [" + item.getId() +"], status is not WAITING"));
I... |
I'm planning to setup a hybrid encryption procedure in my app. So basically i did encryption for data send from client to server using this method, now i'm confused on how to encrypt data send from server to client. So what i have done so for is that :
I generated a public-private key pair using an asymmetric encryptio... |
I want some advice regarding my architecture and hosting options.
I'm attempting to build an e-commerce site for e-books. It will use nestJS for the backend and ReactJS+Typescript for the frontend.
Postgresql will be the DB. I want to use Elasticsearch to provide search capabilities.
Initially, I thought to host each o... |
I have just been confirmed for an interview and one of the hint questions given by the recruiter was:
"Explain Idempotency and a case when you can't make processing idempotent"
I understand Idempotency but cannot figure out when it can't be used.
|
I face an issue where I want to inject Entity Frameworks DbContext into a service class, in a WPF application. The problem is that the service classes are instantiated and contained by the view models. That could mean a rather long life time for DbContext, if injected directly into the service.
The solution I have com... |
On our product there are many config files (we have many processes)
For "logicical" configuration, we store all configuration in a document based database and then distribute the configuration to different component upon configuration change.
But, We also store configuration on app.config files, and sometimes, these ... |
I'm working on a webapp that is supposed to be "database-driven". Now, the stuff we do is a bit evolved (a little configurator) and I hesitate to re-read the DB on every callback, because I fear data might become inconsistent (several linked tables are involved) and possibly a lot of checking would have to be added to... |
I'm fairly new to web development and I have a bit of a weird question.
I'm currently working on a personal project that may or may not eventually become a real, commercialized product.
In my database, I have a "user" table that stores the user's information, including their username, encrypted password, first name, la... |
I am doing some code review for a project and they have generated a name based UUID using SHA256 as the hashing algorithm.
I found a some Java code that created a Name-based (hashing) UUIDs using SHA-256 in Java
The Java code takes the first 16 bytes from the SHA256 and sets the UUID type to 5 and sets the RFC 4122 var... |
Consider that you've got a POJO that you intend to serialize and send through a socket.
You can use whatever serialization strategy you wish (JSON, XML, protobuf, ..., etc) to serialize the actual POJO into a byte[], then you send it through the socket.
The byte[] arrives on the other end, but in this receiving context... |
I'm expirementing with creating a website as a IT Ticketing system. This website has a top nav and a side nav. I want the content area to change depending on the link clicked. I've managed to get the concept down using just php through isset($_GET['page']) and conditional statements which activates the include command ... |
As of iOS 6, Apple thought Unwind Segues would be added to their layout/views. What this means is, when you're on the 7th view of a stack, you can pop back to any other one. For those of you pure OO fans (like myself), I cringed a little. I cringed even more when I learned these also work with pop-ups.
Why would a mod... |
First, as I know, Entity in DDD is almost same with Value Object except Entity has identity. Every article I have read say same thing that entity id has ORM mapping with any ORM tool. But I don’t want to use ORM mapping in Entity. Instead, I would like to do database operation with Repository Interfaces without mapping... |
I am developing a hobby project where I try to use DI to get testable code. Until now, I found that it improved both the readability, usability, and testability of the code. However, now I have a situtation where I find that the usability suffers a lot and I think there is some key part of DI that I am missing.
In the ... |
I have this project with MVVM and clean architecture well implemented but I've decided to split it into modules. Right now I have:
apimodule
apimodule: with the retrofit dependencies
app: with the data, domain and presentation layers.
I want to modularize it even more:
Create a domain module with the domain models, u... |
I have recently encountered multiple articles with title Everytime a mock returns a mock a fairy dies And I ran into exact same situation while using factory class in my code. I am writing a sample Java code here to explain in detail what I mean.
@RequiredArgsConstructor
class Battle{
private final GunFactory;
pub... |
I'm just not sure as to why JIT (Just-in-time) and AOT (Ahead-of-time) are often presented in contradiction to another.
If we do not care about about portability, it feels to me that a program could very well be AOT compiled and then, at runtime the JIT could be used to re-optimized the hot parts.
What are some known... |
I have displayProjectTable that gets state from reducer projectData and populates itself.
Currently displayProjectTable has a local state that stores focusedRowID. My problem is that I want other components to have the ability to modify the focusedRowID and it's content.
Some examples:
-A component tells displayProjec... |
I have been using a pattern in a lot of places (mainly C#) that I would like to know the name of.
Here is an example of it in C#:
public enum ThingType
{
A,
B,
C
}
public interface IThing
{
ThingType Type
{ get; }
}
public class ThingA : IThing
{
public ThingType Type => ThingType.A;
}
public... |
I would like to run tasks in parallel. At this time, I am using a very simple
worker pool using a single concurrent queue shared by all the threads.
Every task has a non unique "tag" (an integer in my case).
I would like tasks having the same tag not to run in parallel.
At this time, I have implemented it by having a R... |
I'm using a listener pattern where a class A listens for events from various classes B, C, D with the help of a listener interface I
Essentially the structure looks like:
interface I {
void generalCallback();
}
class A implements I {
@Override
public void generalCallback() {
/// Do some stuff
... |
Let's say I have a booking system where I want to fire an aws lambda function to send an email or message to users, 10 minutes before their booking starts. I have looked online and found few solutions.
AWS Lambda + CloudWatch + DynamoDB:
Someone suggested adding the job to dynamodb and setting the TTL to when I want t... |
This is (again) a question of methodology...
Suppose we are testing a service that returns Articles given ids, i.e. List<Article> getArticles(List<Integer> ids);. In addition, the corresponding location will be null if the id is invalid.
Firstly fill the database by the SQL:
INSERT INTO articles VALUES (2001, "aaa"), ... |
What is the best way to send messages from a Contact Us page in a website as a notification email to an administrator ?
So far, this is what I did but I feel like this is not really the proper way.
I created a gmail account that will serve as an email sender
From the contact us page, I fetched the values from the text... |
I don't know if this is the right place to post this sort of question, so feel free to move it.
Lets say that Vendor X is selling a certain software package. There are also other competitors, including Vendor Y, selling similar software packages. My company is leaning toward purchasing the software package from Vendor ... |
The goal within my framework is to provide facades or front-facing functions/APIs so that people can easily interact with my system, as such, in most cases, that goes super well by having static functions that people can just call and have everything sent to them, but I have an issue when it comes to these static funct... |
I'm currently working with a very large system and have been asked to add an additional parameter to a method that's called from over 200 different places directly.
The method signature looks something like this:
public static bool SendMessageAndLog(long id, long userId, string message, string cc="", params Attachment[... |
This is not about the specification of semver itself (which is crystal clear), but rather about the best approach to implement it within a development pipeline when building libraries.
TL;DR: who/what sets the version and deploys the artifacts, and when?
We're planning to opensource some of our internal Maven-based G... |
Oh, abbreviations in code, the bane of every developer.
Consensus seems to be against them, because readability might be affected. But the examples given are often extreme: like "repr" for "represent". I call that extreme, because it is shortening a word not in need of shortening, into something that has a very ambiguo... |
I'm wondering what's the best approach, and its advantages, when specifying parameters for the Web Service methods. Best to explain it through examples.
In my (SOAP) WebService, used by a Xamarin mobile app, I have a WebMethod SubmitForm(int, TransactionData, List<Answer>), where:
int is the ID of the Project and speci... |
We maintain a technical project whose specifications are in a document of few hundred pages. It's a text document (Word), not a Wiki or a Web-based stuff.
The document contains lots of tables with values (strings, numerical, parameter names) . Some tables are huge (hundreds of data), other are quite small.
I'm looking ... |
I'm trying to figure out the best way to "partially" use the validates_uniqueness_of validator for a particular case of problem.
Let's say I have a Book class with multiple comments, with the Comment class having a belongs_to :book. Now let's say I have certain comments which I consider notable, such as "most quotable"... |
I'm trying to find a source of information to explain how to sort a list of items considering their multiple attributes and units. All I can find on the internet is code example on sorting Javascript lists and SQL queries.
The key is that it must compare Price, Probability and Color at the same time, for example. A hig... |
General question
how can I design an interface that can support both
// v1beta1.Deployment
type Deployment struct {
metav1.TypeMeta
metav1.ObjectMeta
Spec v1beta1.DeploymentSpec
Status v1beta1.DeploymentStat
}
type DeploymentInterface interface {
Create(*v1beta1.Deployment) (*v1beta1.Deployment, err... |
I'm curious if there is a pattern or at least a better way to code this situation. For example, say you're writing a rest api for a reporting workflow. You have a User class and a Job class. Each User has a Job, and each Job a JobType. Some actions will be the same for the user but have additional logic based on their ... |
I am making a C++ glfw wrapper for myself to use. I want to have classes like Monitor, Window, Context that would be wrappers for glfw objects like GLFWMonitor* or GLFWWindow*. The problem is that if I want to have a method create_window() in the Window class, it must have access to the underlying raw glfw pointer in M... |
I am working on building a API and SDK for a web service. My question is what is the correct practice for logging. Should the SDK do logging for the API methods? All the SDKs I have seen do not do this so I am just wondering is that the recommended best practice?
|
I'm struggling a bit for a preferred way to organize a sequence of asynchronous tasks that can be applied in parallel. Say, you are parsing data from many files. In my case I'm using javascript and promises, but this could be most any language. (Hence the weird tags as "javascript" and "language-agnostic".
Option A:... |
Given that I want to write a Given/When/Then scenario
When I write a Given/When/Then scenario
Then my Given and When are generally the same thing
I've been trying to practice writing user stories in Given/When/Then but I often end up with something like above; the Given and When are identical. I find that high level s... |
I'm currently writing a small language of my own, and have been considering the difference between the C++ style, where the access modifier applies to a block of members, and the C#/Java style, where the access modifier is specified separately for every member. I'm not going to ask which is better; I realize that's ver... |
I know that in some contexts, best practice would be DDD, CQRS and EventSourcing, but in my case this would be too complicated of two reasons:
My team is beginners, and we want them to be productive as early as possible
The application is really simple, but obviously the complexity may grow in time
This question is a... |
I am trying to determine which is the best arquitecture to my application, I am planning to use python, mysql, angular and flask as an intermediate between python and angular.
I have all the shots of basketball matches of different seasons whith the correspondant player, team, position, etc; and I want to plot them in ... |
My team is building a tenanted primary service, with shared microservices used by that primary to separate common business tasks. We're building a new microservice that is responsible for running a series of business rules against a primary object in our system. Think of it like the Order in a shopping cart, and maybe ... |
Suppose I'm writing C or C++ code which deals with... ok, let's make it citizens in a state. In this state, citizens have numeric id's (not strings - numbers); and for reasons of performance, or compatibility with other software, it is assumed there can be less than 2^32 citizens.
Now, in my code, I have a bunch of fun... |
I want to build a REST API but I have some holes when it comes to the security part. I would like to get my head around how to authenticate the calls to the API.
Therefore, this is my first draft for how the process should be:
User account is created
Token is automatically generated and stored in db, associated to tha... |
Example 1:
Let me assume that I have a base class A. Class B extends Class A (Class B is a derived class).
Can I conclude, Class B doesn't obey single responsibility principle since it uses the concept of inheritance? I.e certain changes happen to Class A will require changes to Class B as well? Hence the responsibili... |
I am curious about these three questions when building a push-based(write fanout) feed system:
How does it handle the unsubscribe logic?
To me, it seems to me that we have two choices: delete or keep the history data from one’s inbox.
If we choose to keep it, does it mean that when processing the timeline read reques... |
The only way I know of is to copy the whole heap by allocating copies of all objects on a new heap and dropping the old one, like couchbase db does for example. Presumably you could also do the same on a subset of the heap to copy less data around each time. Google isn't helping me much, since it only talks about heap ... |
I was playing one of my favorite games from Supercell, and I imagine it’s a rather complicated game, and it stems across the two main mobile platforms.
My question is, do the developers write the game logic twice? I’ve never developed games on iOS or Android applications, so my knowledge on this is limited.
Do companie... |
I am trying to create a good pattern for my application. I want to reduce as much as possible the duplicate code and I want to use generics as much as possible. I have created a pattern for this but I want to know is there anything wrong with the code or if is there any other better pattern already made for this.
Base... |
I run on a daily basis a set of VBA-rich Excel files. Most of them include MS Office application cross-talk, but also employ third-party applications and MySQL. Due to the fact of running those files in a specific order and at a specific time of day I set up an xlsm-based scheduler to run those files and control output... |
I want to code a little program that takes in head tracking data and moves a 3D object accordingly on the screen. To achieve this I found a software called opentrack that has a C++ API. The problem is that any game dev environments I know / have a way to access use C# as the language.
I'm very confortable with C# and u... |
I am creating a rest template to consume REST API secured by OAuth 2.0.
The provider has implemented an expiry for the access token for 5 mins. So Using the rest template, I will be calling the database and sending records via Rest Template.
The records may vary from 10k to 1 million, so I wanted to create a fault pr... |
I'm working on an application which needs to open a database file. There are 2 "versions" of this database: one of them is more general data storage, and the other contains "less" information. That being said, database table structures are different, so I need to issue different queries to get "same" information from e... |
In Java string classes are final, we know that we can't inherit a final class and not able to write on this, then how did we enter a value on a string even its a final class?
|
N.B. Several months after initially asking this question (and not coming up with any satisfactory answers) I am now learning to use HTML Custom Elements / WebComponents. It seems the same question comes up again:
I know I can turn everything in my HTML into a Custom Element... so what do / what don't I turn into a Cus... |
We are creating a new page on our website which will require overall ~5000 LOC.
Now the problems here are:
How to get so many lines reviewed?
When to merge these changes to master for release?
How we currently solve these problems:
We create a temporary Release branch in which everyone will merge their features relat... |
I have to code a gui like this:
It's an homepage with a left menu and a changing right part, on button1 click form1 must be displayed, on button2 click form2 a so on.
Each form has its own button "ok" that would call a controller function which will save data entered by the user in a database (but it is not relevant).... |
Summary
Instead of calling WebApi straight from a Web Forms User Control, I have created JS class which contains functions returning jQuery AJAX requests. The control would instantiate the class and call these functions, which would allow me to separate the code that calls the API from my control.
Is this the best appr... |
Problem
I am working on an application for my personal use. Basically what I require is a 24 hr running cloud application that will get alerted about the new articles posted on provided website links and fetch about heading or specific content from those articles. The info is processed and put together after which post... |
I know that "mvn clean install" cleans everything that has already been built by maven and rebuilds everything as specified by pom.xml. However, if things have already been installed, and I just run "mvn install", does it reinstall things that already been installed? In other words, does it install things twice or does... |
We(in my company) use to save the JWT token in the cookie. The web application is on Spring boot + JSP application. So the flow is, in a successful login service send a JWT token, that token has been saved in the cookie and all the subsequent request to the service the token has been retrieved from the cookie. The curr... |
I've run into a common annoyance where I'll have an event that sends a parameter, but some consumers of the event don't need the parameter at all. So I wrap it in another function that decouples the signature from the actual method call. This adds one more level of thought that a reader needs to parse before understand... |
I'm currently refactoring an older legacy application and use React to rebuild some of the former functionality. This application has a form which has +10 different input fields. The aim is to kind of built a wizard that leads the user through fields, instead of bombarding them with +10 fields at once.
Now, I've thoug... |
If I obtain a release build of a github project from a Maven repository, how can I securely verify that it's the authentic build?
DETAILS
That was my X question. My Y question follows.
Maven's Guide to uploading artifacts to the Central Repository says:
To improve the quality of the Central Repository, we require you ... |
I have recently decided upon a micro service design to merge two Spring Boot applications.
I basically have 2 applications that deliver two entirely different front ends, but share user accounts.
My current structure is (in no particular order):
Application 1
Application 2
Gateway service
Discovery service
The gat... |
I am trying to imagine how Google Chrome automatically updates but have some questions:
Is this against Apple's terms of service? I feel like I've seen somewhere that Chrome for MacOS isn't in the Apple Store because of this. Not sure.
How is it swapping out its runtime?
Is it possible to autoupdate on iOS/iPad?
Basi... |
We're Scrum teams building microservices. Our GitHub repositories are single-branch, each of us integrates his/her code into master several times a day, with no feature branches. Our Jenkins pipelines compile the code, run automatic tests, supply the code to other services for static code scans, and deploy our software... |
I am new to Golang and I've seen it is very common to check for errors all the time.
I am trying to find a way to not have my code polluted with "if error { log... }" or "if error { exit }".
What do you think of a function like:
fun exitIfError(error err) {
if error != nil {
exit(1)
}
}
That body of the functi... |
I have an external process in my program. To interact with it i have a configuration file i can edit. The external process then reads this file periodically and updates its state accordingly.
Now what is a good name for this file, as represented in code?
ExternalProcessApplicationConfigurationFile feels 'static' since ... |
Consider a SimpleCalculator class which contains four methods (Add, Subtract, Multiply, Divide).
I need to create another class ScientificCalculator which needs above methods plus other methods like Sin, tan, cos, log, etc.
Should I reuse the functionality by inheriting from SimpleCalculator or should I think of some o... |
I have a MySQL database with a column Body MEDIUMTEXT. Until now I used to only store the contents into it. There was no update option for the users of the application. Now, I wanted to add an update option to the content(To make it easy, just think it like a stack exchange editing a post scenario).
I know about not o... |
I have mainly three groups of CSV files (each file is divided into several small files): First group of CSV files have 600+ GB in total (MAYBE 200+ GB if in int, cause CSV calculates by char right?), each file has same size of lines, the whole data should be gather line by line together. The application should read som... |
I am working with C++ in a Linux/ Unix environment. I am trying to learn the physical design of large scale projects. In one of my projects, I am using an SDK from a camera manufacturer. They released a new version of this SDK and one of the applications I had built based on the previous version stopped working because... |
For teaching purpose, I would like to create a simple implementation of State Pattern using PHP 7.4.
So, I've tried to create a simple "document state machine" starting with Draft, sending to review and, after three "votes", can be published:
<?php
namespace StatePatternPHP;
interface DocumentManagement {
public ... |
My language is C#.
I have a set of seven classes that all ultimately derive from a single class. The image of the class diagram is posted below. I will frequently need to iterate through collections where the members are all the seven classes intermixed. An example collection might look like this:
Collection: A, D, C, ... |
I have been coding some octave .oct files lately (C++), and for my purposes speed is of the essence.
It seems to me that creating C++ objects (in general) can take some time. I was wondering if there is some way to circumvent this? Maybe to somehow create a statically allocated object the first time the function is ca... |
I am confused about the Open/Closed principle. The principle says "open for extension, closed for modification". My thinking is that if there is a class and if you need to add any new functionality to that class, you can add that functionality by creating a new derived class which is inherited from the base class. So y... |
I'm trying to apply Clean Architecture to a mobile Android App, but I still have some doubts about how to manage API calls.
Currently, the classes are structured like this:
View -> ViewModel -> UseCase -> Repository -> DataSource
It's all well and good when the API calls are about fetching some data from/sending some d... |
I'm writing a python function to replace all the non-alphanumeric characters in the keys of this dictionary with underscores.
To make sure it's working as expected as I don't have a ton of experience in the language, I created a sample dictionary with a few different samples to make sure it worked well enough.
Is thi... |
I am writing a program for Windows, which uses two databases. One is very big (dozens of tables and thousands of records) and comes from another program, but I only download data from it. Second is "mine" and only used by my program (dozen of tables and hundreds of records). I have a repository to keep track of changes... |
I am building a blog system's comment api, and decided to provide the REST api like:
post: /blogs/{blogId}/comments/
put: /blogs/{blogId}/comments/{commentId}
These api accept the same parameter:
public class CommentEditParam {
private String content;
// identify the reply to user's id
private Long replyT... |
Consider two services (bounded contexts by DDD):
Sales
Billing
Sales is responsible for creating orders and Billing for handling payments.
Sales tracks orders and Billing holds payments:
Sales DB Billing DB
+----------+-------+ +------------+----------+-------+
| order_id | paid | | payment... |
Task Description
I need a way to wrap different types of progress bars in a way that an algorithm can update the progress without knowing about the exact implementation. The progress implementation may allow the user to request to cancel the operation and the algorithm can query if it should stop at points where it can... |
A superclass should never be aware of its subclasses.
Or so I thought.
I have a Filter class, which wraps a function and some of its kwargs.
Some other kwargs are callable eg
specific_filter=Filter(some_funct,day='sunday')
you can then use the Filter object like so
resulting_object=specific_filter(some_object)
or
r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.