instruction stringlengths 34 36.1k |
|---|
Will the following design prove hard to scale in the long run:
class A {
private static volatile boolean someFlag;
public void setSomeFlag(boolean newFlag) {
someFlag = newFlag;
}
public boolean getSomeFlag() {
return someFlag;
}
}
I want to do this in a project because, in my cas... |
One question im struggling with is how to make linear, cross-service operations/transactions in a distributed system.
For example, I have two services: Orders and Payments. How would the Orders service call Payments, while not allowing intra-service coupling?
As I understand the Orders service would emit an event like ... |
For multi-tenant systems, Vaughn Vernon suggests the tenant id should be on the domain entities. This doesn't seem right to me. The tenant id has no business meaning (with the exception of an aggregate in the context of identity/access control). To me, it seem like the tenant id is an application or infrastructure leve... |
Until recently I used to think that it was preferred to reference objects by pointers or references than to keep objects in some sort of a central, authoritative array or dictionary and only keep indices or keys of members of such an array.
However, recently I started reading something opposite. I started reading that ... |
Scenario
Let's say that there is an entity in my domain called Shop. As a shop owner (user), I am able to create rewards that customer users will be able to exchange.
It also could be possible to have some kind of reward creation policy (eg. a maximum number of rewards that as store owner I can create: if that value is... |
So my question is if my thread A has acquired access to a synchronized method S1() can it acquire access to another synchronized method S2() or a normal method.
|
Say I have a three PRs going into the next release. Each PR is a bug fix and all have been approved for the next release. If the current version is 2.3.1, should the next version be 2.3.2 (count all three bugs as one patch increment) or 2.3.4 (one increment for each bug).
I have read the semver spec, but could find no... |
I have a class that contains insurance benefits. There are many values, such as coverage level percentages, maximums, deductibles, etc. Most of the time, I only need a handful of display friendly properties, which are aggregates of all of the other properties. Other times, I need the values to perform more in-depth cal... |
I build multi-document software, each document has its own history list, and every action performed on the document appears in the document's history.
So far everything is fine, the question begins because there are settings that need to be changed globally, such as to create a global 'style' that can be used in some d... |
During the design of a small app I ended up with two possible design alternatives that both would work but, somehow, I feel one could be better than the other in terms of following OOP Principles, avoiding code smells, etc.
The scenario here would be having an object embedded in a parent class, for example:
class Balan... |
Every example of the visitor pattern that I see uses abstract classes. One of the major drawbacks of the visitor pattern is the fact that each visitor must implement a .visit method for every acceptor it wants to visit. Another drawback is now every acceptor must implement .accept But why not use interfaces? Does this ... |
I'm using DDD and a CQRS/Event Sourcing architecture so my domain logic is separated in a microservice (e.g: command service) and the read side is in another microservice (e.g: query service).
We often struggle with domain experts when defining requirements. Unfortunately the Product Owner is too aware of the technical... |
I have a problem figuring out the relations between some of my database tables.
The scenario for this buisiness case is a b2b buissnes.
I have 3 tables:
users
companies
distributors.
A Company has multiple users (1 to many)
A Company has mutltiple distributors (Many to Many)
A Distributor has multiple companies (M... |
Background:
I'm asking this question as a UI test engineer.
We have a small software team using TFVC on a TFS repository.
We use the mantis bug tracking system to follow up on issues.
Here's the situation:
While manually testing a program, I found a bug and reported it to the devs.
A few days later, a dev has let me kn... |
question
Can an actor "talk" directly with an object of the system in a sequence?
example
For an homework I need to model a "tracking service" for some shipping company.
The functional requisites for the system are:
Allow user to receive information about shipping of specific product starting from a shipping code( if ... |
I have an unpleasant discussion with a colleague who said using session in Java Web Application to validate authenticated users with cookies from Web browser after users logged in is problematic (unsecured mostly and he claimed no one has used this way anymore since 2013).
His idea is to store user's credentials in the... |
I'm new to microservices, and from my understanding, DDD says for microservices to be built around business domains. This means good microservices would be like AppointmentScheduler and SendNotification in the context of a meeting booking system.
In this example, both of these microservices will require access to user ... |
I was wondering - too many microservices usually cause testing and devops overheads + it makes the system more complex.
My service is something that handles a large load (from a data stream). It needs some database data from time to time.
There will be also a seperated process that needs to keep feeding the database wi... |
I'm working on building a multi tenant application which relies on redis as a cache. I'm currently researching a feasible way to achieve multi tenancy with redis. I see that redis enterprise offers multi tenant support, however I'm looking to take advantage of AWS ElasticCache which doesn't offer redis enterprise versi... |
For a ASP.NET Core application, I'm using a library which performs calculations using objects that have a similar interface but their constructors use different inputs. The inputs are market prices and volatilities.
public class Base
{
public virtual double Method1();
public virtual double Method2();
}
public... |
I'm writing a wrapper for XML elements that allows a developer to easily parse attributes from the XML. The wrapper has no state other than the object being wrapped.
I am considering the following implementation (simplified for this example) which includes an overload for the == operator.
class XmlWrapper
{
protect... |
I've seen this approach several times, both in async and multithreaded code. A counter is used to track asynchronous behavior or thread behavior - whenever a new action is started, the counter is incremented. When it's finished, the counter is decremented.
While this is happening, another process is only able to proc... |
I'm practicing problems and found this weird one. I can't figure out the best way to solve it.
You are given a 2D matrix size n*n with only 1's and 0's, you have to find the longest sequence of 1's either column-wise or row-wise.
I'm pretty stuck on this problem. I was trying to use a divide and conquer technique to sp... |
Let's assume we have a required attribute foo for an API call. This can have valid values of 1 and 2 which denote some valid option in the system.
Since this field accepts an integer, if we provide other integers like 3, 4, 5 we get a 406 code with a message like foo cannot be XXXX in response header.
Now, XXXX is ano... |
We’re working on a new service – this service will potentially be called directly from applications on user devices. These applications will be developed and supported by multiple development teams from all over the organisation, all depending on the data we provide.
We’re keen to identify which applications are sendin... |
Are there any best practices around how specific to make events that are generated administratively, say to clean up after one-off operational issues?
For example: Say you have a credit card processing application. Payments are authorized (which deducts from the available balance) then posted (which deducts from the cu... |
I am having a debate with someone at work, think I know the answer, but I would like to hear what other people think. If anything, this will confirm that I am right, or show me a better way to approach what I am working on.
In this situation, I am acting in the role of Scrum Master as the business analyst on the projec... |
I am trying to create an example project Web API to see how "clean" I can remake the Delphi(Pascal) API we are developing on my job.
I have created a solution which as of now contains 3 different projects.
WebApi (the main interface to the application logic)
ObjectLibrary (Models)
DataAccess (Repository style data acc... |
I'm looking for a solution for this, buffering messages in an array and send them after web-socket reconnect. I can check the socket client and push messages to an array when connection is lost and send them after reconnect, But how i can find which message was sent to show a check icon on client side? A solution seems... |
I am building my own analytics platform, which I want to work like this...
A JS script in each of my webpages collects data about users' clicking behaviours and sends that data to a PHP (or other convenient language) script on my server. This server-side script receives the data from the first AJAX request and stores... |
In the exercice i´m developing bellow, i´m applying the chain of responsibility pattern. The pattern works correctly but i don´t think it's the best approach. I think the rule design pattern should be a better fit but there´s no much good examples about it using python.
My questions for you are:
Do you think this cou... |
My project is moving from TFS version controlling to GitLab. This is how we used to go about TFS:
Each production release will be a version branch. For example, 2.0 for release 1, 2.1 for next and 2.2 for next (Sub branching to 2.2.x was also there to track). If at any point I wanted to check exactly what code was depl... |
When we are working on a big project of C or CPP, we are getting some warning. Therefore, we try to remove that warning because when we see compiler warnings that they make us feel dirty. When we search about specific warning, We get some solution to disable specific warnings.
So, I have a question, Is it really good i... |
With the below pseudo code? Am I breaking any SOLID principles?
interface i_pet
string get_name()
string get_species()
color get_fur_color()
end interface
interface i_cat implements i_pet
end interface
interface i_fish implements i_pet
bool get_is_fresh_water()
end interface
class cat implements i_cat
str... |
From my experience, sql code changes almost always tend to be NOT incremental: someone creates a new stored procedure, or modifies an entire embedded sql query for optimization purposes, or creates a brand new table. When I receive one of these code review requests, I could not find any way except understanding the ent... |
I am trying to split down user stories for a brand new system. This system will record weight readings from a balance connected to a serial port.
Due to regulatory data integrity requirements - the data must be attributed to the user who produced it. The business cannot possibly use the software without meeting this re... |
By "more object-oriented", I mean, it appears to me testing frameworks like TestNG and JUnit could encourage testers to write implementations of Test and TestSuite interfaces. The current approach using @Testannotations often leads to huge classes with lots of methods and lots of boilerplate code.
A more "OO" way cou... |
I am working on a Symfony 4 rest API application which will be use by multiple client(about 20 different clients). Each client has his specific needs so I have to fork the web application for each client in order to implement the specific needs. For example, the PriceController which manage the pricing policy will have... |
Sometimes it is a good idea to have a guard block:
https://softwareengineering.stackexchange.com/a/157413
https://en.wikipedia.org/wiki/Guard_(computer_science)
Guard block guards against special cases.
GetFiletype(Ext)
{
; Guard block
If (!Ext || Ext != "txt" && Ext != "md")
Return "Not supported fil... |
In our history, when we did a new release (deployment) any user who was "logged in" was logged out and that was obviously not ideal. Then I switched platform from a custom stack to a cloud provider and a "managed" platform which seems to have solved the problem. AFAIK a user can stay logged in during a deployment and t... |
I develop in an environment where we tend to do a lot of A/B testing. I am curious to learn from others on how A/B testing code is managed in your code base?
Do you mix your A/B testing code with your control code (existing functionality). If you do so, how do you ensure the code base from becoming unmaintainable?
Is t... |
We have a system where multiple consumers get messages out of a queue (currently implemented with a database). The messages have an order field. All messages of one particular order should be processed synchronous. Meaning that 2 messages of the same order should never be processed at the same time by different consume... |
In postgresql I have a table with a list of cities. One row for city. Around 15000 rows. A column is CITY_NAME, now I have to add an english translation of the city name. The problem is that only 10 cities out of 15000 have an english translation.
I was thinking about two solutions:
Add a new column CITY_NAME_ENG with... |
I am doing the Ransom Note algorithm in Hackerrank. The thing is I am not using maps and all the tests pass except for three which execution time takes a lot more. (Kotlin language)
I have two approaches:
1 - Recursively
fun checkMagazine(magazine: Array<String>, note: Array<String>): Unit {
controlWords(magazine,... |
I'm preparing a session on our product's HLD (High-Level Design) for newbies.
It's a microservices-based system that includes several self-managed open-source projects & other managed services (e.g. Kafka, Redis, etc.)
I want to address those services in my presentation in a unified manner - services that are not inter... |
Recently, I've been building a search page where the user can input their search criteria and the server side will use a scoring and sorting algorithm to return the 'best' results first. The current flow is like so:
User inputs their search criteria.
Server-side code (PHP) builds a query to fetch all the results that ... |
I have been developing a library with the help of another library.
So what I have set up here is two classes sub-classing the library's classes for additional functionality. The problem comes in when I want to be able to use the classes interchangeably in another class.
So I want to be able to pass these graphics into... |
Its easy to steal internal hdd, which do not generate sound signals to aware the owner while removing and allows Thief to copy the data.
Is there any way by which these thieves acts can be traced.
|
I have the following pair of functions used for searching upwards for a configuration file:
(defn has-config? [path]
contains? (set (.list path)) "my-config")
(defn find-config-path [path]
(cond
(has-config? path) path
(= "/" path) (throw (Exception. "File not found"))
:else (recur(.getParentFile path)... |
Background
I am starting a new project, and I want custom IOT sensors for an app I am writing. I want to keep everything as simplistic as possible so the IOT devices wont be running any major software or anything, I want them to be as simple as send and receive curl statements(I know they will have to have something bu... |
I have a general organization problem with my code. I'm modeling DNA, and I've created a Nucleobase struct to store the "letter" of the DNA. For ease of use, I would prefer the following functionality for fluent creation of objects, equality checking, and testing purposes:
Nucleobase newInstance = Nucleobase.A;
and
i... |
Suppose I have a Player that wants to build a Tower in the Board of a tabletop game.
My first approach to this would have been something like:
function onConfirm() {
player.consumeResources();
board.addTower();
}
Meaning this event knows the interfaces of player and board so it has some level of coupling.
If the o... |
So I have been working on my mobile app for a while and it is live and in production.
Because we released the app prematurely and are continuously improving current features and making them more thorough it means at every version there's a high change that database schemas will change.
The problem that I have is:
ho... |
We have a system that allows our clients to coordinate people (shoppers) so that they can delivery groceries within 45 minutes from the order creation.
Each client has a set of stores where the orders are processed by the shoppers
and each shopper has an schedule that specifies in which store and at what times he/she w... |
As part of a game engine I am writing in cython, one of the challenges I am facing is creating a consistent interface for error handling that works at the C and python levels of my code. I am interested in maintaining two interfaces to the engine; one that operates at the C-level on structs with no involvement of the p... |
I guess the argument for pre-commit hooks that lint and run unit tests would be that every single commit is clean.
The argument against them is that they take a lot of time to run, which can add up if you commit often.
The same would go for pre-push hooks except they presumably occur less often. Also, if you have con... |
I have a web app - it's more complicated than a todo list but for simplicity sake let us assume it is a todo list. The user has the choice to sign up and create an account thus allowing them to store all their todos to a database. The user also has the option to test out the app as a guest. If they are acting as a gue... |
Are stored procedures considered bad practice in a microservice architecture?
Here are my thoughts:
most books on microservices recommend one database per microservice.
Stored procedures typically work on a monolithic database.
again most microservice architecture books state that they should be autonomous and loosely... |
Let's say I have an which is loosely can be represented as:
public class AnObject{
public AnObject(String name, String value, UUID id) {
this.name = Objects.requireNonNull(name);
this.value = value;
this.id = id;
}
final String name;
String value;... |
A real (but simplified) example from the program that I'm currently working on.
We have an abstract Request class and two classes that extend it: FooRequest and BarRequest. They both have dao's used to get instances of the two requests from the databases: FooRequestDao and BarRequestDao. All across the code base curren... |
Just wanted to know if cyclic dependency is something that one should avoid in microservice design.
For example, let's say we have a simple web store that sells fruit.
It could have:
Account Service - where all information about accounts is stored
Order Service - where all the information about orders is stored
Fruit ... |
My understanding is that the dependency inversion principle does not apply to entities, because entities basically are your application - it generally doesn't make sense to swap out a different implementation of, for example, Student.
However, one of my coworkers brought up a point. We work for an umbrella company that... |
I'm a backend developer working on a webpage, building the CSS part. I like to write as less code as possible and reuse them throughout the site, a lot of pages.
I want to be able to reuse some CSS code. For example, if i have this code:
.box1{
background: blue;
height: 200px;
align-items: center;
}
and i ... |
I am writing a semi-complex piece of scientific software. We offer our end users many configuration options for each job and allow users to specify configurations only partially, with reasonable/safe defaults inferred for the other values.
Sometimes the inferred defaults combine pathologically with the specified option... |
Scenario
I have a Customer and a CustomerSettings object. When I create a customer I also need to create their CustomerSettings object. These settings can dictate the customer experience immediately following Customer creation. After the CustomerSettings have been created there appears to be no reason for synchronizati... |
Essentially, I have a web application and a console application. The web application allows users to configure what will be processed, which is just a big information processor. From the web UI, a user creates a configuration that is added to a queue of configurations for processing.
When the user saves a configuration... |
Recently I have been refactoring state shape in a fairly large redux application, and I have found that one of the obstacles to doing to is that the tests for my reducers clearly have a lot of "knowledge" about the "shape" of the state tree.
There are lots of tests that look like this:
const nextState = reduce(startSta... |
I am porting an event-driven architecture to a container environment (Docker) and I wonder how to take advantage of replication while using pub-sub: if I just increment replicas I end up with many process doing the same elaboration and I don't think is a good way to go. I thought to replace pub-sub with producer-consum... |
We have a solution called 'MySolution'. We have another solution which tests this solution called 'MyTests' which tests 'MySolution'.
When in debug mode, 'MyTests' reference 'Mysolution' with a path to local DLLs.
When in release mode, 'MyTests' reference 'Mysolution' via NuGet.
Only when feature branches of 'MySolutio... |
I'm trying to practise following SOLID principles.
I'm a bit puzzled about following example (which is a remodel/artificial example based on actual code, which i cannot post here):
public class Driver{
ICar car;
public Driver(ICar car){
this.car = car;
}
public void Drive(){
car.Drive(t... |
Say you have a ecommerce app, and have an API call to create an order.
OrderService.create(...);
Order creation is a complicated process, many things will happen as a result of this call:
shopping cart items will be used to create an order and order details
email sent to customer
inventory levels adjusted
billing and ... |
In Onion Architecture, we have repository layer which conducts Crud Operations (simple insert, delete, update). (Applying Entity Framework with database)
Onion Architecture
Additionally , we have Service Layer which conducts complex business logic.
Questions
(1) Should DBContext leak into Service layer? What if we want... |
I am currently working on a project where I need to implement a cache with limited size.
The most common eviction policy seems to be Least recently used (LRU), that simply discards the least recently used items first.
However, my cache will manage elements that have different size. Therefore, in some cases, the algorit... |
I have a question regarding kanban board and handling defects that are found in testing. The case is this:
User story moves through "Development'' and goes to "Testing'' column on board. Defect is found in the period of testing. Where should that US be held now?
a) In the same column and flagged but with new status -... |
I'm trying to figure out how it's possible to robustly code against EF Core in a large, multi-tiered codebase. We have been experiencing several issues, and most of the example project architectures online are very simplistic and don't provide much insight.
The most common questions we come up against are the following... |
Our start-up is currently build this way:
Engineering Team which contains the following resources:
Director of Engineering
Mobile, front-end and back-end developers
Quality Assurance
Infrastructure engineer
Product Owner (PO)
Product Team:
Director of Product
Product designers
Business Analyst
Product Manager
Oth... |
Despite various ways to scrub sensitive data in volatile memory (see Survive DSE or Zeroing buffers), programs tend to perform transparent memory copies (such as a Garbage Collection). The newly generated duplicates are no longer referenced and then they're exposed to memory attacks, thus the above mentioned solutions ... |
I have developed a Windows Service to prevent user from using the camera on group of computers. However, I am trying to find a way to ensure the service is never deleted. I tried CanStop in .NET property but the service was still deletable sc delete , not to mention that registery is another way of doing so.
I know it... |
I have an application (written in Go) with a lot of GPS location information. Each record consists of a latitude and longitude plus somewhere around 50 fields of various pieces of meta data, some of it is small nested data structures.
The full data set is well over 1 billion records and growing steadily. They are kept... |
I'm prototyping out an application here where I'm using domain-driven design to identify the domain(s) of the application and I've ended up with something that - at least so far - feels like a fairly decent architecture where each bounded context in my domain is structured as its own hexagonal application. Data flows b... |
There's a software library / application / framework which currently uses "simple version numbers". So it's currently at (say) version 135 and releases are made in irregular intervals whenever "there's enough for a new release". The next release would be 136 in this scheme.
I want to switch this to use semantic versi... |
I'm designing the Authorization part of the AAA module of a business software suite.
Requirements:
There are Users and Groups, and you can assign Permissions to any of those.
You can Grant or Deny a permission. When there is a conflict, Deny wins. Deny is also the default permission.
Client sends a request with a Op... |
I describe a very very simple scenario. I try to develop a system where many machines can help another one (server). I tried RabbitMQ and Redis, but both don't fulfil all requirements.
I have 1-server and n-clients. The server has several tasks to solve with n-subtasks. A task is called A, B, ... and each has 5 (subtas... |
I am building a Point of sales software with Sql Server 2008-R2. I am now confused about how to handle multiple items with prices change.
Let us say price of Pepsi is $2.0 on 10-09-2019 but today it's price is change to $2.50. and may be in coming days it's price will again change and will come back on $2.00.
So at the... |
The two concepts seem equal to me, but I'm not really sure I understand encoding well enough to confirm that this is the case.
|
I'm building a very security conscious application. (All applications should be security conscious, but this one may contain a lot of red data).
Assuming that I will use a Vue/React JavaScript Single Page App that will authenticate with Google for user sign in:
There will be a Sign In With Google button on the page.
... |
If you go to www.htmlbasictutor.ca/character-encoding.htm you will find the following description of character encoding.
Character encoding tells the browser and validator what set of characters to use when converting the bits to characters.
That's all fine and good - but if we were talking about python instead of htm... |
I am trying to understand principle of Unit testing, Purpose, and Moq. We have
complicated Service Call.
The Service Call encompasses numerous Repositories and Services, with dependencies and parameters. We are mocking each method per below. By the time we are done mocking, it seems like people are faking whole test,... |
I wanted to use some function from javascript module in one of my component. Should I pass it in props when making the component or should I just use Imports in component itself to get the javascript function?
Example of Passing in Svelte component:
Proxy.js
var Proxy = {
test: function() {
.....
}
}
e... |
I try to build a very small object database, not for production only to learn a bit in my spare time.
I've got a data structure that saves my data in blocks of a specific size und combine them when more data is needed.
But now my problem is when I do it this way I would need one file per object type I want to save (the... |
I recently wanted to copy my putty config from one laptop to another.
I figured there would be a directory somewhere which stored the IP addresses etc as some form of text file. I was surprised to learn that that information is stored in the registry and so I had to export a registry key.
I'm curious as to why the de... |
After quite some time thinking about it, and testing both methods, I'm really struggling with choosing the right manner to commit my transactions.
To shape the context, we are in the context of Domain Driven Design combined with CQRS.
As Eric Evan states, a transaction should only change 1 aggregate. This is kind of co... |
I have 7 different .NET Core applications (solutions). All supporting a different workflow such as customer request, request for change and much more. However, they do share a similar goal (that is to automate intern processes).
I expect that in 2 years there would be 20+ applications as we keep automating more process... |
I am developing a CAN-BUS reader (logger) with an ESP32 microcontroller.
This sample uses RTOS and several task to send and receive CAN-BUS messages.
https://github.com/espressif/esp-idf/tree/master/examples/peripherals/can/can_self_test
In my application I mostly only want to receive CAN-BUS messages. There will be po... |
API Gateways are great. They can produce a nice unified view of a sea of micro-services living behind them. However, on large scale projects, what patterns can be adapted to allow a single API Gateway to sit over dozens or hundreds of micro-services?
Example
I have an endpoint on my gateway: https://mysite/api/books... |
We have many clients which, upon start up, request a specific resource on the server using an HTTP API (not RESTful). This resource is - currently, identical for all clients.
Naturally, since the client is requesting data from the server via HTTP, a GET is used.
Incidentally, we wish to log the access of this resource ... |
First of all, I'm aware that in python nothing is really private but let's assume that we can stick to using the leading underscore to indicate that something is private.
I have a module consisting of a bunch of private pure functions (marked with an underscore) and a single public one. We can think in the public one a... |
Suppose I have a message broker that allows consumers to specify a batch size. What are the advantages and disadvantages of consuming events in batches compared to consume them one by one?
The obvious advantage I could think of is increased speed. As a drawback, higher delay, which will be more noticeable the lower the... |
I don't know too terrible much about the CPU, but I know it processes assembly instructions and that Windows can say that it is at anywhere from 1-100% usage. How is it possible for a program to use less than 100% of the CPU? Wouldn't an instruction being executed cause it to be at "100%" usage?
Is it implemented in so... |
I'm new to this community, I'm glad I found this and so I can ask questions like this one (as per https://meta.stackexchange.com/questions/68384/whats-the-difference-between-stack-overflow-and-software-engineering-se-previo).
The problem is simple, how do I fetch the data in an app's home screen if I do offline-first t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.