instruction stringlengths 34 36.1k |
|---|
I'm learning how to design a Microservice architecture. For example, here is a simple Microservice architecture:
I'm kind of confused by the Account Service.
As we know, for a web service, normally we need to perform a login first, and then we can get access to some services. For example, we perform a login, and then ... |
I have this code in some part of an application:
long sum1 = new Multiples().ofAny(new long[] { 3, 5 }).until(32768).sum();
long sum2 = new Multiples().ofAll(new long[] { 3, 5 }).until(32768).sum();
long sum3 = new Multiples().of(32).until(4096).sum();
I created it so readers have a clear vision of what's happening, b... |
Java has "checked exceptions", which force the caller of the method to either handle an exception or to rethrow it, e.g.
// requires ParseException to be handled or rethrown
int i = NumberFormat.getIntegerInstance().parse("42").intValue();
Other, more recent languages such as Go and Rust use multiple return values ins... |
I have a 3rd party application. Basically I need to run one instance of that application for a one user. For 10 users I have to run 10 instances. From my API
I want to communicate with a specific client based on API parameters. Please check the attached image.
I have two methods and each have some issues.
1. using mul... |
I'm reading through Mickens' OS notes, and I came across the following depiction of a virtual address space.
I conceptually understand "user mode" of a process' virtual address space. It contains program instructions, stack, heap, static data, etc.
But what about 'kernel mode'? I always thought of kernel instructions ... |
I am working on REST API and it calls another service and fetch the data and return to the UI. So It does not have any direct DB interactions. Recently we added exception handling feature which uses Controller Advice to handle the Application level exceptions. A sample response looks like below:
{
"timestamp":"2021... |
I have written a Command Line Interface, where the user has to construct an object basically by providing input to a bunch of questions. I have a hard time testing these functions as there is too much happening in there. Basically for every input, there is some validation and it will loop forever, print error message, ... |
I am using the AWS SDK for Java V2, and I want to delete a SageMaker endpoint and a SageMaker endpoint config. What is the best way to do this?
For example, I am currently first using the describeEndpoint method to see if the endpoint already exists. I do this by calling describeEndpoint and if I get an exception that ... |
As the question states, is this bad practice?
I have a User aggregate root in the bounded context of Identity for authenticating the user. In this bounded contexts I have fields for the User related to identification of the User e.g. email, salted pw and so on.
I also have a generic subdomain for handling notifications... |
I am enhancing an existing API to provide shipping rates for a b2b web service. This specific endpoint returns a single rate based on matching request parameters such as the service level and package information to choose the best option. We currently support allowing the client pass in a carrier on the request, and ... |
I'm designing a RESTful API and have come across a problem when it comes to designing my routes, specifically the admin routes. My application currently has 2 types of users: regular users and administrators, and as of right now I have the following routes:
Users:
GET /users/current - gets the user object for the curr... |
I keep reading articles analyzing Monitoring and Observability, or having lots and lots of text regarding how the latter is the extension of the first, or how they are complementary, or how tracing is the next step in APM (Application Performance Monitoring/Management), or any other random opinion on the subject. I hon... |
TL;DR: How distributed open-source apps like Scuttlebutt are secured from DoS and hackers who can make custom version of application?
I'm struggle with designing an open-source distributed application architecture. I want to create an application consisting of open source server, client, and provider. Client sends requ... |
In Entity Framework 6 and/or Entity Framework Core 3+, the code-first types generated by the scaffolding (or other code-generation tools, my preference is this T4 script) are mutable classes that do not expose their Entry<T> state.
In web-applications today, current practice is to load the required entities inside t... |
I learnt the concept of abstraction as:
Reducing complexity by hiding unnecessary details.
Does this have a relationship with the abstract keyword in java?
I see that the abstract keyword is being used in methods in classes like this:
public abstract void printName();
|
I used to have a base object with subtypes behaving in all but the same way -- the difference being in their render methods. This base class defined a default render method, overridden by Some subtypes who have their dependencies wired in.
<?php
class SubType1 extends BaseType {
function __constru... |
In redis docs, it is stated that keys command should not be used in production, since it blocks other processes while executing, it is better to use scan iteration over all keys with some batch size.
I've read in docs that redis use hash index, so I assume it can't use it for range queries like scan and keys.
But our s... |
Given is the following package/class diagram of an implementation of java.util.List:
1. Which design principle is (most likely) hurt by the ArrayBasedList class?
The design principle that is hurt by the ArrayBasedList class is the "Use inheritance as a Specialization" because the ArrayBasedList is (extends) a List tha... |
What I've learned so far as a programmer has lead me to think that the easiest way to write large scale software is to use a lot of interfaces - this makes things very easy to isolate and test. In high performance code, the performance loss due to v-table look-ups is often stressed. I often see this mentioned when disc... |
An often quoted disadvantage of the strategy pattern is:
The application must be aware of all the strategies to select the
right one for the right situation
Why is this a disadvantage and what can be done to overcome it?
|
I'm working on a web application with JWT authentication (with token stored in cookie) and an SQL database. Upon loading, the frontend makes a request to the backend to determine whether the user is authenticated and who he is.
In order to make the app more convenient to use, I want to allow users to use most of the fe... |
I've been doing technical studies in web design for a while. I have developed several web pages, however, I have not published any.
This year I plan to publish my first website. I would like to know how should I order the folders and their various files (index.html, scss, js, multimedia, child web pages) in the best an... |
I am building an app wherein a user will be requesting one of three engagement types:
Appointment (no SLA)
Consult (2hr SLA)
Emergency (10mins SLA)
We are considering two different scenarios for submission of the desired request:
Option 1 - At the beginning
Option 2 - In the middle
Option 1:
User opens app with thr... |
I see this word in many places but don't get it.
From the Wikipedia,
In message-oriented middleware solutions, fan-out is a messaging pattern used to model an information exchange that implies the delivery (or spreading) of a message to one or multiple destinations possibly in parallel, and not halting the process tha... |
I am currently developing a huge project in my company with N-Tier Layer architecture using spring boot but I can not sure about the package and class namings. In our project, we have a complex structure. For example, we have to call oracle plsql procedure/function, pure sql, jpa with basic jpa repositories, web servic... |
I have a system with two applications interacting via a message queue. Let's call them Producer and Consumer. Some key context is that this a multi-tenancy scenario.
Producer produces events based on various inputs (user interactions, api, etc...) and Consumer does down stream processing on these. One of our key con... |
I'm new in the team (< 3 weeks) but I believe I am experience enough as a Xamarin dev to know what I'm doing and also experience enough on using Prism library to give some criticism on how things should be done on an existing code base.
On our next sprint, I am planning to give some dev talk and raise some concerns for... |
When someone comments on my question/answer/comment I will see the notification from the inbox, and it also shows under my response tab. Later when the comment is edited, the comment shown under the response tab changes; when the comment is deleted, the comment disappears from response tab as well. And the inbox messag... |
I am writing a functional specification for a project and I wish to express the expected system behaviour in Use Cases.
I have read a bunch of opposing opinions on whether "logging in" should be considered a Use Case or not and my conclusion is that there is no consensus, and that it also depends on the context.
My que... |
Simple summary of a real problem:
I'm making a chess game
The engine that makes the chess do the magic is its own independent code (by design, for easy implementation)
I am now implementing the chess game into a game (Minecraft, but could be any mod-able game)
Problem:
The code that runs the chess has classes like "... |
In an ASP.NET MVC 4 REST API application, we have SQL errors which are occuring during the request.
However, since the requests are big, we are streaming the data back to the client, which means we have already returned the 200 OK response and headers.
So midway in the stream, something bad happens.
How can we indicate... |
This came up at work and left me thinking about the best way to model this:
In Python, we have the built-in list container, which is a mutable sequence. Equality between two lists is defined as equality of all items in the list, in their respective positions.
Now a colleague felt the need to define a type that's a list... |
I'm study UML and I have nobody for verify my solutions so hence I will greatly appreciated if anyone give me some feedback. I'm doing exercises about use cases and sometimes it's hard for me know if I'm on the right track because these exercises are not mathematics in which you have an exact result. These models can v... |
New to golang and is now researching on how to do test in golang. I see that there are popular mocking library like gomock. However, at the same time, I see that large golang open source projects don't use any mocking library at all. For example, geth (ETH miner), wire (dependency injection library) and sendgrid go cli... |
Currently studying about replication and I was wondering:
In Passive replication, we have an agreement stage where the Primary replica manager (RM) waits for ack from the backup RM, wouldn't it be possible to handle byzantine failures whereby doing some sort of consensus algorithm? (we could survive f+1 failures in a s... |
We have a react website that, as part of it's process, loads a dynamically generated javascript file from a third party. It uses some of the scripts in this javascript file to generate values, which the react website then passes to our API in an API call.
Our API then does it's own processing and calls the third party'... |
When providing JavaScript's parseInt with a non-parsable string it returns NaN. I'm trying to understand the reasons for designing a parsing function this way.
When I write a parsing function I usually return null or throw an exception in case the input is not parsable. It seems to me that NaN is unsafe because it allo... |
Currently I am a student learning Machine Learning, and so my observation is from an academic context. It may be different in a business environment.
One thing I find very odd when I see Python code for machine learning is that when you call a typical network class, you send it lots of parameters, which strikes me as a... |
In my country, there is a high number of fraudulent doctor's sick letter as they are manually written on paper. I'm designing a web application to combat this issue and have the whole process electronic.
My current thinking is that when the doctor issues the sick letter on the application, the app generates a unique id... |
I’m trying to model a system with Users, Permissions and Products. The main goal is to have a way of checking if a User has a specific Permission in order to allow or deny other system operations.
So Users will have a list of Permissions and this Permissions will be given to the User when the User buys a specific Produ... |
The DDD literature is quite clear that when a word/term has a different meaning for different users, a Bounded Context should be created to be able to separate the domain models.
I'm facing the situation where two different terms are being used to describe the same concept and I'm having a hard time figuring out how to... |
What Every Computer Scientist Should Know About Floating-point Arithmetic is widely considered absolutely mandatory reading for every programmer. Why is this the case? What aspects of the article make it stand out as still being important to this day?
Upon my reading of it, I found that a lot of is was only concerned w... |
Does a domain object have to be persisted, or does this violate some convention about domain objects?
For example, let's say I'm using an object called AuthenticationState to represent authentication state in the application. This object has a boolean field isLoggedIn. I want to force the user to re-login each time so ... |
Consider the following pseudo-code:
cont = 0
for g = 1,...,m
for h = g,...,m
cont = cont + 1
end for
end for
I'm searching for the explicit map that returns cont in function of g and h. I've tried with
cont = m*(g - 1) + [h - (g - 1)]
but this formula works only in the case m = 2.
obse... |
A commonly repeated best practice is to not reuse local variables. However, when doing multiple small operations on the same variable, I struggle both with coming up with good names for all the variables, and I find that the multiple similar names hurt the readability.
Alternative 1: always create new variables
def cle... |
Sometimes there are functions that return complicated data and cannot be divided any further e.g. in the area of signal processing or when reading and decoding a bytestring to another format. How am I supposed to create stubs (e.g. the bytestring) to be able to assert equality of expected data with the return data with... |
I am not sure if what I'm asking is even possible (or desirable, for that matter), but we were wondering what would be the best way to handle SQL changes to a Database schema, when this schema is shared across multiple apps/teams.
We work for a large corporation where database schemas are shared between different softw... |
I am developing code mainly using Bash, C, Python and Fortran and recently also HTML/CSS+JavaScript. My OS is Ubuntu.
Maybe I am exaggerating, but I figured that I kind of spend more time getting software (Debian and Python packages mainly, sometimes also from source) to be installed properly than actually developing c... |
Most of the answers I see that discuss what the model layer is comprised of, only address stateless MVC, particularly ASP.NET's implementation of it. When working with desktop MVC frameworks such as Cocoa, is application state considered as part of the "Model" layer?
|
Introduction
A customer of ours has embedded products with sensors and actuators. Now they would like to connect this device to the cloud so they can remotely monitor and configure it. It should support:
Periodic data updates (LwM2M read or notify? Depends on how we implement it)
Alerts (e.g. data above threshold) (Lw... |
I'm developing an app with a user management system. There is a database table named user with the following columns:
| Column Name | Column Type |
|-----------------|-------------|
| userId | BIGINT |
| email | TEXT |
| firstName | TEXT |
| lastName | TEXT ... |
In Visual Studio, ASP.NET MVC project template is designed for MVC pattern, but what about ASP.NET Web API project template?
I know that we can create API from MVC project, also we can build MVC app from Web API project.
But what if I use Web API project and return only data, not Views? What is the design pattern behin... |
I work in web development and the team I work on is growing so I see the need to hammer out a more formal Git workflow. We have a process down that is working for now but it's starting to cause more problems than it solves.
Currently, we work off of a dev and master branch. The dev branch is checked out to our dev envi... |
A Makefile is a representation of a depency graph. The files are the vertices, for example somefunctions.h, somefunctions.c and myprogram.c are the "input" vertices (is there a formal word for this?) and somefunctions.o and myprogram are the "output" vertices (again, correct word?).
Then the edges of that graph are som... |
I have a situation as follows, I have a relative path that I want to get for a directory. The directory structure is as follows,
Windows Folder Structure
C:\FileFolder\LowerLevel\ThirdLevel\script.py
C:\FileFolder\FolderOfInterest\filesStuff.txt
Linux Structure
PathAbove/LowerLevel/ThirdLevel/script.py
PathAbove/FileFo... |
I work on small to medium, database driven, line of business applications. What I usually find, especially in older systems, is most of the data lives in the database. By data I mean stuff like a CountryTable, a ZipCodeTable, lots of/one big table for dropdowns.
Recently I inherited a project in which the client has a ... |
So I just started studying Software Engineering because I am really interested in it and my professor in London asked us to create an app which is like Instagram (only theoretically, without the actual implementation of code) and I would like some help on something.
I have started with writing and studying different pa... |
I haven't been able to find a definitive answer online, so I'm hoping that someone with experience can help answer this.
Many MVC tutorials I find online end up using the MVC architectural pattern as the architecture for the entire application. But, I have read conflicting statements from those on this site and other s... |
I have two audio clips:
Source of truth
Recording of user
I want to compare the two, testing if they are similar enough, removing accents, etc. Any idea how I could do this on Android?
To add more detail, I want to record the user reciting some Arabic and then compare it to the correct pronunciation. The idea would b... |
I want to implement a 2-3 tree in C# language, where every leaf has a unique key. The keys are from a given class that implements the IComparable interface (the specific class is unknown, and it's should work for every class which implements the interface).
I want to use two sentinel nodes to represent plus and minus i... |
I am given the following system description :
Consider a hotel
management system to manage a group of 5-stars hotels. If this system is modelled using OOP methodology, and the classes are identified as Hotel, Trip, Room, VIP Room, Regular Room, Suite, Customer, Payment, Cash_Payment, Credit_Debit_Payment, Reservation.... |
Context of the problem:
I have made chess GUI (Java)
The GUI is capable of loading chess puzzles/problems to solve
Of said puzzles, I have gotten my hands on a database which is just shy of a million entries
The problem/question:
How does one most efficiently go about getting a random puzzle from this database?
Obvio... |
I have a project on Azure DevOps that uses an appconfig.
The appconfig holds sensetive data like usernames and passwords and is committed empty to the repo.
I have to deploy the project on two different environments that need two different appconfigs to run.
What would be the best practice in this case?
I'm conflicted ... |
I want to setup my objects to be composed of components that can be added and removed so I have more flexibility in how I set them up.
A simple example would be some object that can have components attached such as:
MoveComponent //lets the object move around
HealthComponent //allows the object to take damage and be de... |
I'm designing an e-commerce application. Main flow is pretty straightforward: customer add items to basket, checkouts the basket (place an order) and waits for delivery.
There are following requirements:
basket is kept on backend
system should handle +5M baskets/orders per day
I know there is no single answer, but I'... |
I've heard often that Subtyping breaks some important and useful properties: many nice innovations developed by pure programming language researchers can't be brought to Java or C++ because of subtyping. They say that the language Rust avoided Subtyping for this reason.
Is such a claim correct?
What are some cool thing... |
I'm working on a multi-threaded program that interfaces with external USB/serial devices via user-space device drivers.
Early in the design stage, I made the decision to split the program into three components: A, B and C.
Component A would possess full responsibility of communication with external devices (this is wh... |
Consider animals being some REST resources. User has animals assigned to him.
The endpoint /api/animals/{animalId}/feed is used to feed a given animal by the authenticated user.
User should not be able to feed animals he does not own. What HTTP status code should be emitted in such a scenario?
400, 401, 403, 404, somet... |
Let's say that there is a simple sequential algorithm that performs a linear search of a unique key in an array:
public class SearchSeq {
public static int search(int[] a, int key) {
for (int i = 0; i < a.length; i++) {
if(a[i] == key)
return i;
}
return -1;
}
public static void main(Str... |
I am trying to process sets of items (also, different sets have different items) in specific RabbitMQ consumers (one for each set of items) that would be created on-demand and are dispatched to the relevant instance (i.e., custom load-balancing depending on different heuristics).
To ensure that a set of items are proce... |
Sorry if this is a basic question, I'm studying for my operating systems class and compiler theory class at the same time and this is confusing me. From what I do understand, virtual memory is larger than RAM and the virtual memory of a process looks like this:
[stack][heap][uninitialized data segment][initialized data... |
I am trying to write an algorithm to accurately calculate exponents (antilogs) for a variable precision floating point library I am working on. The base is not relevant since I can convert between them.
I was able to manually calculate log10() using repetitive application of x^10. This is a digit by digit calculation... |
I need to run arbitrary code snippets in Python and Javascript on a server. It cannot be run in the browser.
I'm thinking of sandboxing the code in an AWS Lambda serveless function. However, I'm unsure of the best ways to disable networking (outside of the AWS returning a response over the network) and other potential ... |
I'm building a real time chat application like Whatsapp. I have a websocket server with node+express, but I'm a bit confused on which flow I should use.
I'm considering sending the image as binary data through the websocket to the server, process it and store it in AWS s3, and then send the URL back to the user.
Anothe... |
Why can't you just use strongly consistent reads for all your DB reads, with retries on 500 responses? According to CAP theorem increasing consistency should probably lower availability, but can't the decreased availability (increased 500 responses) be handled fairly easily using retries? (assuming you are fine with a ... |
One of the most common things I see when discussing pros/cons of microservice vs monolithic architecture is that monolithic applications have, or always trend toward, 'tight coupling.'
To be honest, I'm not seeing why this is true if your developers know how to leverage any standard OO language. If I need a certain par... |
My question relates to semantic versioning (specifically as specified here).
Say I have some feature I introduced in version 1.10.0 and then some time later (let's say the project has advanced to version 1.50.0 for the sake of argument) I discovered a bug with the 1.10.0 version. So my understanding is, we fix that, an... |
Below, I define an IInstantNotification Interface. TextNotification Class and EmailNotification Class inherit from this interface.
public interface IInstantNotification<T> {
List<string> Addresses { get; set; }
string NotificationContent { get; set; }
T NotificationArguments { get; set; }
... |
Our situation
At first, our company had 1 product. Custom hardware with firmware we wrote ourselves.
Now more projects are starting to be added. Many can reuse most of the components of our first product, but of course the business logic is different. Also the hardware could change, and the remote device monitoring int... |
I'm building up an ecommerce app based on microservices and almost every article points out to use async communication.
But I'm facing a situation that I think is better use sync communication.
So, how control inventory using async communication?
Let's say I've a bus with 1k messages for decreasing the quantity of a pr... |
I'm working on a system with a user-facing frontend and with 1-n backend services which I'm trying to design according to the principles of the Twelve-Factor App.
I'm now facing the task of sending emails to the user that contain a link to the frontend. The question is, how do I generate the URLs, or more specifically ... |
I work on a number of code projects, some open source and some not. Many of these projects are intended to be cross-platform, most often running on either Linux (my natural habitat) or Windows and generally relying on CMake to build. Recently, I noticed that a Windows developer on one of the projects checked in .sln ... |
Let's say I have a class like this:
public class Validator {
private HashSet<byte> _validFlags;
public Validator()
{
_validFlags = new HashSet<byte>
{
1, 3, 4, 7, 19, 30, 47//These numbers are chosen for whatever reason and there does
... |
Hi I'm bulding an ML pipeline with PyTorch to support various tasks and am looking for some advice on efficient ways to store processed data.
The main frame work was 3 layers [data prep] -> [data loading] -> [training/inference].
The dataprep module is responsible for taking raw data (medical data in this case) and sto... |
I have a User Model as below, this Model class is in the shared library.
class User {
private long userId;
private String email;
private String userType;
private long departmentId;
// ... other fields and getter setters
}
In my code, I am persisting User Objects. In order to persist User object, I... |
Following the classic 3 layer architecture
domain Model (a list of domain models live there and has no dependencies)
DAL layer - My Repositories lives there with DBContext implementation (Ado.net) Dal return pure entities ( reference domain model)
Service Layer ( Business Layer ) expose methods of repositories ( ref... |
I’ve decided to create my project following a micro service architecture. I have a products service and a reviews service.
The products service essentially stores all information regarding a product whilst the reviews service stores reviews for a product.
I’ve decided to keep these separate from each other as I would ... |
I'm trying to exchange some small data between my two apps. This two apps located at the same PC, so all exchange happens inside this machine. At first, I thought maybe to use sockets for it, cause I had some small experience with it, but then I read some articles that said that it's not the best practice for it, cause... |
Often I need to get some data and process it in some way. For example getting a list of customers from an API and assemble some summary data on them. As an example, getting :
api_result = api.request('customers/get')
for item in api_result:
customer = Customer.fromDict(item)
process_customer(customer)
This w... |
Velocity is a common indicator, that's clear.
What puzzles me is that Velocity on itself is nothing as velocity changes directly with the capacity of the team and people take days off, gets sick, teams grow and shrink ... to get a useful indicator you should be measuring Velocity vs Capacity to get something like:
You... |
I can hardly imagine a software project where the things to do are not somehow collected in a formal/informal document, be it a SRS or a simple note. So I was searching for these requirements documents for some well-known Open Source applications (e.g. Signal, GIMP, VLC, ...). As the Source is open, I guess engineering... |
I need to transfer only 5 byte message over the noizy line and I'd like not to make the message much longer with the data protection redundancy. Let's say I suppose that one extra byte should be enough for protection.
Processing power of the transmitter and the receiver are pretty low: it is 8-bit AVR at 8 MHz on the t... |
I have a relatively simple task where I need some 10 consumers to consume work to be produced into a queue, continuously.
This is my first time implementing this design pattern, so I have been searching the web for different approaches.
The ones I found were:
Threads with Monitor.Pulse/Wait
Blocking Collection
Channel... |
I want to create a aggregation job that executes a big db query and flush it into BigQuery.
My question is should I include only the id of the entities (campaign id, advertiser id, user id) or should I include also the meta data (campaign name, advertiser name, user name).
The upside for metadata storing is that I have... |
The bridge pattern is defined as 'The Bridge pattern decouples an abstraction from its implementation, so that the two can vary independently'. I get that abstraction here doesn't mean abstract class / interface, but its not clear as to what abstraction actually means. But some sources online imply this.
https://source... |
I've been designing an event processor for state machines in C and I'm trying to figure out what's the best way to break down my components in simpler and smaller *.h and *.c files.
Specifically I'm not sure whether it's best to separate declarations and user types from a component in order to use them in multiple othe... |
A few weeks ago, I went on Udemy course on Swift, the instructor mentioned that constants are called let in Swift because it's standard in OOP (JavaScript uses it for example).
I know this may seem like a really stupid question, but I think it is confusing that constants are declared by let. As, let doesn't stand for c... |
So, I have this legacy project I am starting to hump into with my team. This is a AWS Lambda Python application (a bunch of Micro-services that inform various front-ends). So, when I asked how they integrated this with Github I immediately panicked: the answer was they don't.
I've been reading around and found several ... |
I have a solution with multiple projects, lets suppose there's one project with the name Company.Name.Foo.Bar.
If I declare a class inside the project Company.Name.Foo.Bar but with a namespace Company.Name.BlaBla, would that be a bad practice?
The reason why I want to declare a class with a namespace that goes outside ... |
Say you had some (contrived) timeseries data like:
time | 1 | 2 | 3 | 4 | 5 |
temp 1 | 3 | 3 | 4 | 4 | 5 |
temp 2 | 2 | 2 | 2 | 2 | 2 |
...etc
Is there a particular terminology for functions that go across the rows (cumulative) vs the columns (point in time)?
For example, the sum of tem... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.