instruction stringlengths 34 36.1k |
|---|
I am part of a project/team that is building a new web app in Azure for the first time, having previously built and developed a traditional three tier ASP.NET web app over a number of years.
We have an external architect/consultant helping with the transition to Azure, and they are proposing an architecture that is pro... |
I'm trying to get a good understanding as to whether there is a best practice or standard regarding keeping values within your code libraries or referencing them from another config file. I don't have a formal background in computer science so apologies if I'm not using appropriate language here. It's probably best f... |
I struggle to understand Roy Fielding’s REST alternative to HTTP cookies, § 6.3.4.2 ‘Cookies’ and § 6.5.4.1 ‘Application State in a Network-Based System’ of his doctoral dissertation Architectural Styles and
the Design of Network-Based Software Architectures. How do you interpret it?
6.3.4.2 Cookies
An example of wher... |
I am reading a lot about patterns and code structure and something that bothers me is BeanValidation's way to handle errors. I like Java and think that BeanValidation is easy to use, but it seems to me that using BeanValidation is kind of an anti pattern.
In one project I have just the normal BeanValidation which I cat... |
We host a dashboard where users can view different reports, each powered by a templated SQL query. The users have an option to "download" those reports as CSV.
Currently the above use case is handled in the following steps,
User views a report and she clicks on download.
The browser makes an API call, and on the serve... |
I have a server running on AWS which serves data, that is not changing too often (think about a CMS system) to multiple clients.
This service is critical for most of the client apps, thus I want to take some load off of it. I wanted to introduce another service between the clients and the server with a (Redis) cache wi... |
We have an existing project that has grown very messy and confusing; our classes are huge and difficult to read.
Our boss wants us to break all of our methods out of the classes and into separate files (for maintainability), so that it would be something like this.
class Foo {
public function bar()
{
i... |
I need to synchronize tables of data between two different systems. This is a multi-master setup; data can get changed in either system. After a synchronization runs I'd like the data in each table to be the same.
I'm having a tough time coming up with an algorithm for sending only incremental changes from one system t... |
I’m pretty sure I’ve made some wrong assumptions in my questions so bear that in mind.
At some point, the methods inside objects that are part of the persistence layer will be called/accessed for say… retrieve some data from the persistence mechanism ( DB, noSQL, txt file, external API etc… ), where this calling is goi... |
The motto of the upcoming question is "I don't know what I don't know".
I would like to know if there are downsides or security risks with an authentication implementation.
Right now, I'm storing a JWT in an HTTP only cookie to send it from the client (React application) to the server (Spring Boot/Kotlin application). ... |
First of all, I had task 1 and it was about rest API, requesting calls using httpclient in order to use the functions of an API. We get an input from a user, either "Online" or "Offline". If it is an "Online", we request calls such as generating tokens, and we display the result on GUI using javafx or swing. If the inp... |
So, I'm binding an InMemoryCachedCarRepositoryDecorator to an ICarRepository, and obviously I should bind it as a singleton, because otherwise it wouldn't work (as intended).
So this got me thinking:
Shouldn't the implementation dictate the scope of the binding?
(It doesn't seem like major DI frameworks support this, a... |
I'm receiving a lot of a data entries from different (IOT) devices. I need to temporarily and persistently store this data until it is polled by the matching clients, after which it will be deleted.
The data looks something like the following:
id=1 device=1 key1=value1 key2=value2
id=2 device=1 ...
id=3 device=2 ...
id... |
I have two classes for making pyqt5 windows. Inside class one I have a button with a function it is connected to.
Class One:
from PyQt5 import QtGui, QtWidgets, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__(... |
Lets think about the most common Aggregate Root example: Order and OrderItems (or OrderLines).
So I want a useCase called UpdateOrderItem. Given a OrderItemID and a complete OrderItemDTO in the request I want to update the OrderItem info. Following the Aggregate root pattern, OrderItems should not be handled alone. So ... |
Hello everyone)) I am working on the react application, where mobx is being used for the state management. Some time ago I have added such class:
class EventLogStore {
private _eventLogRecord: IEventLogRecord[];
get eventLogRecords(): IEventLogRecord {
return this._eventLogRecords;
}
a... |
My architecture looks like:
Each block is an individual service. There may be more upstreams and downstreams added in the future. The upstreams need to send email notifications to users. Each email is specific to a single upstream.
The question: Where should I put the code to call Email Service, in upstreams or downst... |
I asked this question on SO which is related to this.
In this question, I propose exchanging a token from my OIDC provider for a token in my own custom OIDC provider, which becomes the ultimate token directly referencing the database user.
What's the best way to tackle this problem in general - I can't be the first per... |
Question is result of me consuming a service exposed by a colleague, the service is a simple update service, which takes an object/entity as input, does some processing and updates persistence. the service doesn't handle transaction within, expects caller to wrap the service with transaction. As the business logic with... |
I wrote a class that takes a Logger class as one of its arguments:
class QueryHandler:
def __init__(self, query: Query, logger: Logger) -> None:
self.query = query
self.logger = logger
def run(self) -> None:
try:
r = requests.get(self.query.url)
except requests.exc... |
I am trying to calculate the time complexity of the below code snippet
def func()
{
for(i=1; i<=n; i++)
{
for(j=1; j<=n; j=j+i)
{
print("hello")
}
}
}
This is how I calculate -
The first for loop for variable i executes for n times. The inner for loop is dependent on i, the variabl... |
ABI (Application binary interface) defines things like caller and callee saved registers, stack use, register use, end-of-routine stack pop etc.
Is ABI only an agreement between compilers and other software to make sure they don't overwrite each other, or is it also governed by the hardware itself? i.e if we all agree ... |
We are designing a new service that should do mainly 2 things
1. Get data from a queue, call an API (lets call it APIx) which returns and ID and save the data from the queue+ID to the DB
2. Expose the saved data from step 1 to clients through an API
There may be thousands of requests per second with multiple different ... |
By coincidence I stumbled over "The New C Standard" from Derek M. Jones, where he comments this sentence from the C99 standard regarding "storage duration of objects":
There are three storage durations: static, automatic, and allocated.
His comment:
One of the uses of the overworked keyword static is to denote objec... |
A typical introductory example to OOP, classes, and constructors is object Car, with properties such as float fuel, bool is_engine_running, etc etc, and a class and constructor definition might be as follows (I'm using a Java-esque syntax here, but it works in any OOP language):
class Car {
float fuel_remaining;
... |
I have a QT application with a window of OSG written in C++.
I want to implement the app using MVC design. The application allows you to add markers to OSG model and it is using QT to edit the markers.
First, I want to make sure that I understand MVC right.
Model - it's just the data that the View need to view and the... |
I enjoyed the process of writing an integration test for a system that relies on http, by mocking such end-points with Wiremock, and I feel upskilled, having wrestled with Matchers.
Now, Wiremock as a standalone server is very useful for multiple reasons but, although it has neat integration with JUnit, I don't get the... |
Here is what I am specifically doing:
I have a thread-safe queue
One 'write' thread constantly writes to the queue with data that comes from another service
Multiple 'read' threads take from the queue, each thread taking several items at once and doing some processing with them
Once each 'read' thread processes its cu... |
Often one wants to apply a code-formatter, like Black, or JuliaFormatter to a existing code-base.
One where standards have tried to be followed but a few things might have slipped in.
Once you have that you can insist that code matches the format and test that in CI etc.
But how do you get to that state?
The direct sol... |
Martin Fowler states that,
Command module executes validations and consequential logic
which aligns with every CQRS demo app that I've studied.
That is to say: validation -- does this Jedi exist? -- and consequential logic -- if not, create it -- are all responsibilities of the command(s). The logic is not encapsulat... |
I've noticed a certain idea recur in different contexts, but before I start calling it "the sandwich pattern", it would be useful to know (in the spirit of other "Is there a name for this pattern?" questions on this site):
whether it is a recognized concept that already has a better-known name, and
whether there are ... |
I'm working on a simple CRM (Customer Relationship Management) webapp (Flask and Peewee ORM) and I found myself in a situation where I believe that I should have used a design pattern that I may not know yet.
The CRM holds data about customers. I want to offer the ability to interact with the customers, e.g. sending th... |
I have a scenario in which an Entity defines an EntityRepresentation that is created from another end. The EntityRepresentation is a value object that implements some logic that should be performed on the other end after its transmission. In the end, the EntityRepresentation and Entity contains the same data but in the... |
I wrote a software for a customer that shows clients on a map (Google Maps).
I store the clients on a table on the MySQL database (table clients) and show them on the map using markers. Each clients has an id, name, lat, lon, and other satellite fields.
The customer wanted to add a feature to add notes to the map.
I ma... |
I am currently thinking about some design choices regarding exception handling.
My current architecture looks a little like this:
You can see that I have a UI where a try-catch middleware is cathing exceptions like this:
Pseudocode:
catch(CoreUserNotFoundException e)
{
return 'You provided an invalid user id'
}
cat... |
Is there a standard data type which is a struct or a table or a dictionary which will always delete objects that are older than t minutes? for example if I want to make sessions expire after 60 minutes. I don't want to traverse the whole structure of course. I think we can do it with 2 generations. Every hour it makes ... |
I'd like to design an implementation for graphs in C.
I'm wondering what the most efficient approach in terms of both computational power and memory consumption would be.
I've looked at various open-source implementations available online, such as iGraph: https://github.com/igraph/igraph or this short lecture note abou... |
This is example of the problem (sequence ends if last 2 letters are "te")
lasagna nato top operation online nervous usable levitate -> end word ended with "te"
There are around >100K words and the "end" letters are given and you cannot use same word more than once. I tried using going "backward" (find words that end wi... |
I'm thinking of a GUI architecture that works like a finite-state machine where there is a set of possible states and a set of possible inputs--or events.
The thing is, some states transition to the next state solely based on the input, but some hold on to the previous input(s) and transition based on the value of the ... |
To explain the problem imagine you have two entities User and Group. The OO implementation has two classes UserModel and GroupModel.
UserModel should have a method getGroups() (returning instances of GroupModel) to retrieve all Groups belonging to this particular user. Therefore UserModelmust interact with the GroupMo... |
I need a design approach for a feature store which accepts input data in the forms of CSV, EXCEL, JSON etc.
The backend stack we support is Java, Spring boot and oracle DB.
Note :
Each file corresponds to only one single type of object and each of the object doesn't have any relationship with the other objects(that ge... |
I have the following use case and would like to implement it in a thread-safe manner. Think of a Stack Overflow-like web application.
Somebody upvotes a question.
A new event is sent to the message broker. Data sent are {type: "Upvote", userId: "10"}
A background service reads the event.
Reads the current point count ... |
Let's take at random a well-written piece of Rust code:
let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor {
label: Some("Shader"),
flags: wgpu::ShaderFlags::all(),
source: wgpu::ShaderSource::Wgsl(include_str!("shader.wgsl").into()),
});
I'm nowhere near being a Rust expert, but what f... |
There are metrics for class and module cohesion and coupling, but I didn't find anything yet for a single function. Some functions are obviously doing too much, like doThisAndThat (should be doThat(doThis())) or getDataForThis (should be convertForThis(getData())), and it would be very nice if there were an automatic w... |
I'm working on a data science project that involves data ingestion, cleaning and various aggregations and functions of timeseries equipment data primarily using Pandas. I began the project just writing various functions from the ground up, but am now at a point where I need to make critical decisions about the codebase... |
I have a RESTful API service that has three layers: Application/Domain, Infrastructure, and Presentation.
Application/Domain contain my interfaces and models. I currently have three different types of models:
DTO - These are the models my controllers return to the client as well as the models that are passed around al... |
A problem I'm currently solving is that at a glance I want to see the status of various services, including both frontends and backends, across dev, test and prod environments.
That is, I want to see:
Is the service running?
What version of the service is running?
ie. A semvar
Latest commit hash
What features is th... |
i like to think out a function using comments before writing it. I'd like to keep the information in the code as comments somewhere but i don't know where it should be kept. At the moment i keep it at the top of the functions code like this:
int Lattice::Width() const
{
/*
* Description 1
* -------------
... |
I am designing an API whereby some other system can supply an image in their POST. As such this is an API for integration purposes, with no front-end. Postman is used for testing the API.
Below is the DTO for the expected POST body written in C#
public class VideoEventCreateDto
{
public double Confidenc... |
When I buy a house or a car, the product is already completely ready. It's very seldom that an error will be noticed later by the customer.
In software engineering, on the other hand, errors (bugs) are normal and occur frequently. Even in production bugs can be found, so that software receives updates regularly.
Suppos... |
I am trying to implement RBAC to a system but I endup creating an ACL instead due to my low understanding of this archtecture.
What I already have implemented:
Created User model.
Created Groups with different permissions from User model.
Designated each user to each group based on their permissions.
For instance, th... |
Abstract
The case:
Application contains a lot of views with a list of data. Data views (lists of records) have pagination, filtering and sorting options.
The user must be able to select a "sorting property" to sort the shown data by a specific property.
The user-interface contains a selection control (ComboBox) the use... |
I'm working on a 'slideshow'-type presentation (e.g. using LO Impress) which involves me showing people different alternatives for writing some pieces of software code.
We're not talking about large pieces: Some of the changes I suggest are alternative formulations of individual lines; others involve transforming block... |
I have the following classes, which have quite similar method implementations. Only the classes' method inputs and outputs seem to be of different types. When I put it like this, it sounds like a case for inheritance, however, the fact that the inputs and outputs are different and are related to two lambdas, make me wo... |
I have a task that I need to make sure it only runs once in my dockerized environment (managed by k8s), running the post-upgrade script is one example.
Because each dockerized app can run the task and the docker containers may restart, I believe I need to store a state that indicating whether the task has run or not in... |
Consider this code, rather than hardcoding the hour when we execute a certain command I query the CQS engine and asks when it will be executed. Though now we have a high coupling to another command. You consider this ok?
public class CancelInvoiceCommandHandler : ICommandHandler<CancelInvoiceCommand>
{
private read... |
Let say, user A has the name of 'James' and trying to change it to something else like 'John'. It might be stupid to ask this question but how do you apply this change?
I retrieve the new data from database and send back to Frontend to rewrite the data. However, it seems like it could increase network traffics. I was t... |
A client requested that we implement the following authentication/authorisation flow:
User authenticates using OIDC via a IAM (Salesforce in this case).
If user is an external user, then a flag is appended to the JWT payload which indicates we need to query Active Directory for the users' group associations/permission... |
I have a problem with proper API design.
So there's an app where users can track their sport Activities. User can later access and view them. It can be done by making GET /api/activities/{id} request, where id is an id of the activity. Internally I am searching db by user id and activity id, so that another user cannot... |
I like the concept of Extreme Programming (as I understand it), that there should be many smaller functions with descriptive names, instead of fewer, longer ones, even if those functions are only called from one piece of code.
I do this all the time, but it does tend to litter the class definition quite a lot. I alread... |
I am interacting with a 3rd party program that will request 2 user inputs to start running a process. I know what they are going to be and want to preempt them, so that I don't need to enter them every single time.
predict_user_input_1 = 'variable1...'
predict_user_input_2 = 'variable2...'
3rdParty.start() #this... |
I'm following Uncle Bob's clean architecture for my application.
However, I wish my application to be extensible via plugins. More specifically, I want the plugins to be able to add new entities and use cases.
How does one go about adding support for plugins in an application that follows the clean architecture?
|
In my spare time, I like to develop various small libraries and CLI utilities that solve a real problem I have, but are also likely useful to other people with the same use case. When I say small, I mean that the LOC count is modest and the scope is limited - but the program itself is not trivial does solve a real prob... |
I am developing a middleware application where the application workflow is:
handles rest requests
performs some business logic
calls another rest service
I would like to use DDD to model the business logic as it is very expressive.
But as the application mainly serves as a gateway or facade, the aggregate root ends u... |
Consider this hypothetical scenario. I have a user form that has a collection of controls that are made available/unavailable based on certain criteria. One important criterion is product type. On selecting a product type, certain features on the form are made available. These features are also dependent on other crite... |
I am getting confused when objects interact using OOP. Here i'm trying to model the interaction between a vending machine and a coin. The coin is inserted into the vending machine.
The interaction is represented by the functions InsertCoin() and Insert().
The resulting main() is very confusing, how are we to know which... |
Currently, our architecture uses an "API-first" approach in building our product. This product is divided across multiple teams handling different microservices.
The above image succinctly shows our approach. There are JSON Schema files that are shared between all microservices. These JSON schema files are used to aut... |
I am preparing the software architecture for my client project based on APIs REST
The idea is that any data exchange between my client and his partner will be via API REST call
The specification is that my client have a large data store ( SQL database) which must me updated by data got from the partner
My question is ... |
I am making a web system using Asp.Net Core with individual user accounts (Identity), and I was thinking about how I should store the users' personal information in the database.
The system will have different kinds of users. Some are Members, some AdminUsers and some are ExternalResourcePersons (people). Each of the d... |
Lets imagine some vendor code that we want to extend on our project level
protected function getDefaultFormClasses() {
return [
new FormClassA(),
new FormClassB(),
new FormClassC(),
...
new FormClassZ()
]
}
On project level we want exactly what this function will return ... |
Say I have a set of objects from an "old system" that I want to convert to a newer set of corresponding classes. Each specific class has its own way of being converted.
So I have this:
interface OldInterface {}
class OldA implements OldInterface {}
class OldB implements OldInterface {}
interface NewInterface {}
class ... |
I am looking for a method to measure the time difference between:
the time it takes to load and completely reach TTI for example.com/page-B given that example.com/page-A is loaded.
the time it takes to fetch the "main content" of example.com/page-B and replace it in example.com/page-A via Javascript and reach "TTI st... |
Let's say I have
Service A that publishes Message 1 to be processed by Consumer A
The same service A that publishes Message 2 to be processed by Consumer B
I need to make sure that consumer B processes Message 2 only after Message 1 has been fully processed. What is the common or best approach to this kind of situati... |
I have tried to look this up online a lot but have found no concrete explanation that answers my question hence hoping someone can help me answer my question—-
My question revolves around cookies and what cookies are sent to the server everytime I make a HTTP request.
Lets suppose that I have logged into www.facebook.c... |
In a case where we have multiple source of data, we need to :
persist each source of data in its raw form.
process the data source eventually with each other to transform them in a presentable state (into a queryable database).
The first approach I could think of would be to store the data generated by the source usi... |
I am designing the API architecture for my client:
My client actually exchange huge files (csv) with his Partner with MFT ( SFTP )
**Partner ==> MFT ==> Client **
The requirement is to move to API REST exchange mode to replace MFT ( csv file)
**Partner ==> API ==> Client consume GET API **
For example :
The partner... |
We are currently in the process of doing an infrastructure overhaul.
A bit of background of what our business model currently is:
We are an aggregator of bills and payment services for businesses. Utilities, mobiles and much more. We are making it easier for companies to connect to these services by just connecting to ... |
I'm trying to understand and learn how to build microservice messages the best and came up with this task for myself:
Services given:
Accounts Service
Token Service
Email Service
When a user registers the account needs a token for the verification email. The token service will issue tokens with a life time that can ... |
I'd like to use some sort of AWS serverless technology to trigger an event when a clickstream stops receiving clicks. Imagine a website visitor clicking around a site. Within our current solution each click is being sent over http to an AWS API Gateway which uses a Lambda function to push the value into DynamoDB. I'... |
So we have quiet a big TypeScript codebase at work, where each method resides in its own file. Now in a lot of those methods the variables are often declared all together at the top/beginnng of the method.
I was discussing with some principal developers that it would be better to declare them only when they're really n... |
I am trying to put in practice an algorithm for binary searching and compare it with linear searching:
linear search:
public static int linearSearch(ArrayList<Book> books, int searchedId) {
for (int i = 0; i < books.size(); i++) {
int currId = books.get(i).getId();
if (currId == searchedId) {
... |
I was reading this article, which talks about storing location-based information. The author says that while Latitude and Longitude info for the locations can be stored in a SQL database, retrieving and searching through that information using SQL queries can be expensive, even with Latitude and Longitude mapped to the... |
I'm dealing with two categories of machine learning algorithms. For simplicity, let's call them A and B.
There are multiple concrete algorithms in each category, and my goal is to implement all of them. Because of this, my initial plan was to define abstract classes CategoryAAlgorithms and CategoryBAlgorithms, and have... |
We are designing a shopping cart that allows customers to ship to multiple recipients, but we are stuck at the conceptual level of the relationship between items in the cart and recipients.
There are two options to consider:
(a) Assign items (child) to each recipient (parent)
(b) Assign recipients (child) to each item ... |
We are designing a multi-tenant architecture. In our multi-tenant architecture, there are different email templates that are shared across all the tenants.
Email template looks like
subject: {tenantName} welcomes you. body: Hi {userName} welcome to the new platform.(Generic template).
But a tenant can have their own ... |
I have an application which is quite old (7 years back-2014) but well built using JSF, Spring Webflow and Hibernate. This application is critical as being deployed for 50 separate clients each with different box (with tomcat as web server).
Now I want to change the architecture and move to multi tenancy in web module (... |
For our software development process we used to set up 3 environments : integration , QA and master.
Recently it was decided to add a new staging environment that shall mirror the production environment for further testing. Our production environment uses kubernetes, SSL, Load balancing, and others components and conf... |
I just finished my TDD-based REST API. And I would like to use Postman to document it for the frontend team until I realized it has its own test script. Now I'm wondering, is it necessary to double test it?
|
I'm building an automated test suite to integration/feature test my organization's Stripe implementation within a GitLab CI pipeline. We're running Laravel 8 and using phpunit for testing.
Within this suite I'm testing both happy and non-happy paths (i.e. I want to test valid and invalid payment details).
At the moment... |
For fun, I would like to design a mathematical expression evaluator, with variables. It could simplify the entered expressions by factoring them, reducing them to a sum of simple fractions, calculating them, grouping them, etc...
To give an example, if the user enters the following expression:
(in a code format, of co... |
I'm working on a project where I need to do CRUD operations on Book and Library objects. Naturally the relationship between Book and Library is Many to One, like so:
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class LibraryDao {
@Id
@GeneratedValue
Long id;
@OneToMany(mappedB... |
Lets say we have a server getting upto 1000 requests per second, serving them at p99 of 20ms (strong business case for not increasing this latency). The server gc parameters have been carefully tuned for this performance and current latency is already bottlenecked by gc. We want to log structured data related to reques... |
This doubt is about function doing one thing from Chapter 3: Functions of the book named Clean Code
Here Uncle Bob is talking about this function:
public static String renderPageWithSetupsAndTeardowns(
PageData pageData, boolean isSuite) throws Exception{
if (isTestPage(pageData))
includeSetupAndTeardownPages(p... |
I have single page application with an Angular frontend and a Spring REST-backend.
What is the proper way to handle a list of string-based options in the fronted the enduser can select from, which shall all be shown and eventually slightly changes over time?
i.e. gender ('Male', 'Female', 'Unisex') or jobs ('Student', ... |
Suppose I have a Controller that takes a DTO that represents an Order. This DTO has inner DTOs that could potentially have entity IDs and/or entity data that's used to create an entity dynamically from that data, for example, an OrderProduct that has a price, qty, etc.
Before this order can be created, I need to run va... |
I know that we usually inject the dependencies by instantiating them in the constructor of the class we are injecting to. However, in my own experience, I just pass the class of the dependency as a parameter and do not instantiate in the constructor like the code below(I am currently working in Ruby):
class A
def ini... |
As part of a black-box testing activity, I would like to check the executable I'm testing generates a binary file that responds to its specifications given a specific input.
I'm wondering how I can check that.
I have two solutions in mind but each of them has some drawbacks:
Compare bit by bit the output with a binary... |
I have a project where there's an external API which implements throttling. Roughly speaking, I'm allowed to perform N requests per minute. I also have a message queue (Apache Kafka) whose consumers consume API requests: a consumer receives an API URL to call, calls it, then produces another message which is processed ... |
Does there exist some language whose execution model is implemented as a neuron network, or maybe as some other type of a network/grid (e.g. network of finite automata)? That is, specifically, without a central execution supervisor and main loop function, but where the execution point is moving from one node to another... |
Is there any language or language feature where you can re-call the constructor on an instance of a class and is there any reason why you don't want to do this?
For example,
//let's say you have this:
var person = new PersonModel("John", "Doe");
// is it possible to do this:
person.constructor("Jane", "Doe");
Reason:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.