instruction
stringlengths
34
36.1k
Good afternoon, I'm getting into microservices - in fact, I've managed to make few full projects based on that architecture - but they weren't really robust, so I couldn't get the full scope of using microservices. I'm struggling with 2 concepts related to scalability and reliability, and I would appreciate a simple ex...
I have a Spring Boot application to implement a RESTful API. One of the GET requests have two query parameters: from and until (of type date). Those parameters are optional, so user-agents can send both, none or just one of them. The query parameters are then used ("down") in the flow to filter data sets by (a typical)...
First off please note, I’m fully aware that Git has historically been terrible at dealing with large binary files and very large repos; there are at least a dozen questions on SO that deal with large dataset performance, but as far as I’ve found, they’re all years old and the answers all more or less predate a number o...
In Little Book of Semaphores: 4.1.6 Finite buffer producer-consumer solution Finite buffer consumer solution 1 items.wait () 2 mutex.wait () 3 event = buffer .get () 4 mutex. signal () 5 spaces . signal () 6 7 event. process () Finite buffer producer solution 1 event = waitForEvent () 2 3 spaces .wait () 4 mutex.wait ()...
From what I understand, an abstract data type is basically some data and what we are allowed to do with that data (ex. a list with a set of data and an attribute size and the functions get(), set(), sort(), insert() and remove(). It's an abstract data type because we do not know what the data inside is going to be or h...
So... Le's say I have 3 tables named: Member Bus AutorizeMember ID Member is referenced to Bus and ID Bus is referenced to AutorizeMember which is also referenced to Member 3 times. Thats is because there are some cases that a member in the Bus (which is the Bus' Owner) can select or not 3 others members who can driv...
I want to build an achievement system that awards certain badges based on conditions, I wonder how to tackle this, if for example, the user has ran 9999 kilometers, if I want to award him a badge when he reaches that 10.0000km, that would mean after each activity, loop all previous activities and take the sum of the di...
We're currently using the Apache Camel Java DSL to structure our application, but I guess this question can mostly apply to any DSL in general. Now, amongst our developers, we are divided on two polar opinions as to how to structure our codebase: Approach 1: Use the DSL as rarely as possible, and stick to using plain J...
I have a function that repeatedly encodes Foos to string. I'm currently deciding between two ways to implement this: Return by value: std::string encode(const Foo& foo); void important_function() { while (1) { Foo foo = get_foo(); std::string encoded = encode(foo); save_to_file(encoded); } } Use outpu...
Suppose I have the following entities in a commerce data model: BaseProduct (PK id, price, name) LineItem (PK id, FK product_id, price, name) Order (PK id, line_items) An Order includes one or many LineItems. A LineItem includes a reference to a BaseProduct, but, and here lies the crux of the question, we don't use ...
I have a configuration problem, from this code, https://github.com/plum-umd/java-sketch. Here, I must set $JAVA_HOME, because: "One possible issue you may encounter while building sketch-frontend is the inconsistent Java version in Maven, e.g., Maven refers to Java 1.6 while the main Java you're using is 1.7 or higher....
We are building a software, which we have companies registering their products. We (the administrator) will have the help desk team that'll be able to help our users (companies) in case of problems. Our platform performs transactions, and with such, we expect user support. What controls should my help desk team have ov...
We have a managers api (/api/managers/-/staff), which will get a list of staff that the currently logged in manager has been granted access to. It is the Managers service. We also have a staff api (api/staff/[StaffGUID]/obs/sessions) that will get staff data. You have to be an authenticated manager to make a call to th...
I've been working on feature_A while another dev works on feature_B. Now, the other dev needs a small functionallity that's implemented in my feature_A, but I've not finished the whole feature itself. How should I share the code to the other dev? Is it against git-flow branching model? Can I simply merge feature_A into...
When there are two feature branches that has some dependencies, and they are work in progress, but some piece of code want to be shared, why shouldn't I merge a feature into another?
We have the following use case to be developing: A web application that shows a data table / data grid with up to 100000 rows and 30-50 columns. Each column is filterable and sortable. The web application is based on Angular and PrimeNG (with PrimeNG Table) and the backend is based on ASP.Net Core WebApi, but i think t...
I'm looking for ways how to accept arguments in the domain model when you want to add items in it. Let's take a look at this example: public class Order { public ICollection<OrderItem> Items { get; set; } // Way 1 public void AddItem(OrderItem item) { // Add } // Way 2 public void A...
I would like to get some help or ideas regarding the usage of JIRA and getting insights from it. I just joined a small company as a junior project manager. In the last several sprints, Developer "X" burned significantly more points than any other team member. Which parameters I can use use to identify the reason for t...
I would like to get some help or ideas to solve my problems, I just join a small company as junior project manager and I faced with 2 challenges sorry for my ignorance but I am new into the agile world. QA has many tickets in each sprint that appear as “Ready for testing”. Some of them are indeed ready, while others -...
I have a C# (WPF) application which consumes a particular 3rd party API/tool (let's call this Tool A). My colleagues and I are trying to decouple that from our application, so that it is possible to switch out Tool A in the future, replacing with another vendor's API/tool. We decided to define a set of interfaces, whic...
I know that this question has been asked before and is the same or at least almost the same but I just want to know: Is it the only method or is there any other way to do it? I have these tables: Person1 and Person2 are referenced to User: At the moment of insereting a new user, it's only posible to inset one ID_Perso...
If you have a very large monolithic database that is not partitioned or sharded, with strong relationships between the tables/data, does it still make sense to use microservices as the application layer?
So my question is more algorithm based rather than code or architectural problem. I have a problem where I am given an array of object like this: [{joinedAt: <Timestamp>, leftAt:<Timestamp> }] now consider this scenario: I have 4 people having a meeting, each have its joinedAt and leftAt value. I want to find max numbe...
So basically I guess I know the role of MVVM, but correct me if I am wrong View: Basically it whats the users sees + it takes user interaction Also View: It shouldn't know what the model is ... but it must know what is the ViewModel is ViewModel: its the Glue code that does the binding + code transformation + Interacti...
Lately I've encountered a similar problem in a few different circumstances, and every time it has required quite a bit of extra code to work around it. The problem I'm talking about is the one where one application or device needs to send something to another application or device (usually a server). The thing being se...
I'm trying to learn about microservices and best practices and came across this scenario and didn't know what was the correct way of approaching it: I have a website that can display widgets (let's say there's 3 types of widgets, widget A, B, and C) specified by a user. Each widget type has a corresponding microservice...
I am using an opencv.js Web Assembly build in the browser. The build comes with a JavaScript interface to call the WASM functions but it does not provide any memory management. For example every time I create a new matrix( mat = new cv.Mat() ), to free up the memory taken by that object, I will have to make sure to cal...
a short question: class ItemActionObject { private final Object moreParameters; private final Object otherDependencies; private final Item item; public ItemActionObject(Item item, Object moreParameters, Object otherDependencies) { this.item = item; this.moreParameters = moreParamete...
I'm a developer and my typical environment is to use is a Linux guest OS running inside VirtualBox on a Windows host. Most software companies don't allow developers to install Linux bare metal on their machines. The Windows host/Linux guest solution is a good compromise. My new workplace is different. They'll let me us...
I've been seeing a lot of this construct throughout my application: def doSomething(): try: # setup some variables try: # do something that could throw an OSError except OSError as err: # log and handle it # do some more things try: # d...
Overview Domain-driven design prescribes modelling a particular domain with classes that contain both state and behaviour. Microsoft attempt to support this methodology in modern C# applications through EF Core, which allows constituting graphs of entity objects from a database. I'm building an application where I mode...
So for e.x I have an entity Payment and a config Payment settings. class Payment { public Payment(PaymentSetting setting, ....other fields){} internal Payment() /*strictly for the ORM**/ //Other properties and behaviour } class PaymentSettings { public Timespan TransactionTimeout {get; private set...
I just have a quick question as I couldn't find any concrete answers on the web. Does having a private static inner class promote loose or tight coupling between it and the outer class in Java? Thanks for your help in advance, appreciate it!!
In Operating System Concepts: 7.5.1 Safe State A state is safe if the system can allocate resources to each process (up to its maximum) in some order and still avoid a deadlock. More formally, a system is in a safe state only if there exists a safe sequence. A sequence of processes <P 1 , P 2 , ..., P n > is a safe se...
Say we have an API that accepts a list of objects. Something like: { "family": "Does", "contact_details": [ { "name": "John", "email": "john@example.com" }, { "name": "Jane", "email": "jane@example.com" } ] } Say you then wante...
In OS books (e.g. Operating System Concepts), there are three strategies of dealing with deadlock between processes or threads: prevent, avoid, and check and recovery. Who performs the strategies? is it always an entity, different from the processes or threads being considered as candidates of deadlock? For example,...
I want to compare the performance gap between the two machines, the main consideration here is memory and CPU. For example, the theoretical calculation peak of the CPU. Theoretical CPU peak = main frequency × number of cores × CPU double-precision floating-point number operations per clock cycle. But this is the theore...
Disclaimer: I'm not sure if this is the right site as this question sits under both software engineering and security domains. Background: Assume you have a financial web application that receives sensitive requests from its users (e.g. money transfers) and you want your application to be able to process sensitive oper...
I'm building a project with C# AspNet.Mvc. I'm using Entity Framework Core. It has Poco which maps in data from DB. On Mvc project itself i've got ViewModels folder where i have models topass between controller and view. But how should i organize models on web to map from POCO entities. So far i was keeping them in the...
I'm working on a microservice system where 8 services share the same data - most notably: auth, forum, portal. Essentially, forum and portal use users from auth, and since I went with the 'AP' approach in CAP Theorem - I duplicate data from users and store it in database of forum and portal whenever it changes - thus r...
Since we live in a world where basically all your web activity is being tracked by some company or your ISP. I was wondering how to 'falsify' the data they collect. For instance by having software go to page A and performed X, Y and Z actions. if user goes to page A and performs B, F and G actions. In this case the rea...
A question from a friend: I have multiple usages for the same code, let's say a vertical HTML card. I change the title and a lot of data based on the react component. it feels unnecessary performance-wise and for readability to use "if statement" multiple times on the same page, so wondering shall I just repeat the cod...
So I'm aware there's some degree of timing-based logic in existing programming languages, like threads and the sleep() function (and derivatives thereof), as well as events / delegates. However, I was curious about the potential of a language, or at least a library / extension of an existing language, that embraces the...
In an OOP design, suppose I have some board type game that has pieces, such as chess, checkers. In you opinion, what properties should pieces of that game board have? imo, I feel like the pieces should only contain its respective rules, e.g. it can move like this, and it can do this. The issue I see with this is that, ...
Operating System Concepts discusses two implementations of a semaphore, by busy waiting in Section 5.5 and by blocking the current process in Section 5.6: Section 5.5 A semaphore S is an integer variable that, apart from initialization, is accessed only through two standard atomic operations: wait() and signal(). The ...
I want to optimize a bike-sharing redistribution system( find the best way for an agent to take bikes from a station that has more bikes than needed and relocate them to a station that needs more bikes) and I don't know what technologies to use. I have details about the path cost and the demand for each station. I woul...
I have a REST API (v1) which routes through to a Java springboot component for which I now need to introduce a number of breaking changes to add new and changed functionality (v2). I understand how I can use a version number in the URL or HTTP headers to signal whether a client is calling for v1 or v2. My question is ...
I come from a Java background, but now I'm supporting a PowerShell code base. In the PowerShell code base there are multiple modules that were written against a certain Azure environment. Now, we have another Azure environment that we need to support, and a lot of code needs to change. We don't want to fork the code...
Here are some discussions about mutex (lock) and binary semaphore from two OS books. Stalling's Operating Systems book says A concept related to the binary semaphore is the mutex . A key difference between the two is that the process that locks the mutex (sets the value to zero) must be the one to unlock it (sets t...
It's a pretty simple question really, how should one properly declare and use a global resource without violating Java's OOP principles? When I'm writing in C, I would declare a struct in global space. This could then be accessed by any function that needs its data; it could be database connection details, or socket in...
I have a program that involves two different data structures, and so I created a class that acts as a generalized data structure that either of the original two can be represented as. (Because the next part of the program ideally only handles a single kind of data structure) I implemented this generalized data structur...
Is a mutex lock always implemented as spin waiting? Can a mutex lock be implemented as block waiting? (Operating System Concepts section 5.4 only mentions the implementation by spin waiting. See below.) (For comparison, a semaphore's waiting can be implemented either by busy spinning in a loop or by being blocked. See...
I am currently doing some exercises with algorithms and I find myself in a huge problem. It seems that everybody understands this type of problem but I have a really hard time figuring it out. For exercise, we have some for loops to look at, and we need to figure out the runtime for that specific algorithm. We got a so...
I'm starting to notice this pattern throughout some of my code: try: some_func() except FirstException as err: # known possible err # log err notify_user(err) except SecondException as err: # known possible err # log err notify_user(err) except Exception as err: # unexpected err to prevent crash ...
Here are some discussions about mutex (lock) and binary semaphore from two OS books. Stalling's Operating Systems book says A concept related to the binary semaphore is the mutex . A key difference between the two is that the process that locks the mutex (sets the value to zero) must be the one to unlock it (sets t...
I'm studying state machines diagrams and was asked to come up with a diagram for a device that turns on and off when a button is pressed... but as with other modern devices nowadays, it can operate either when the battery has charge in it, or when connected to electricity, such as a cellphone device. My question is... ...
I want to synchronize one variable (Node.Value) to two separate sources. Both sources can read or write to their internalValue variable. How do I keep track of the newest value and update appropriately? I need to run this process multiple times a second. The sources are not necessarily databases. I was thinking about t...
At a previous job, we had a lot of excessive issues with versioning of our APIs, to the point where we had whole server farms for our services that were running specific versions for specific applications, split out in case the Mobile Team updated but the Web team did not (there were about 5 such front end teams so 5 s...
Context I'm developing a chess engine of my own, where if anything can be pre-initialized/pre-calculated, should be. This is because speed is the number-1 priority, and every extra second you spend calculating stuff that could've been calculated before-hand, stacks up and ultimately makes you lose a lot of important ti...
I'm doing a website that has a React frontend that calls some RESTful API and I would like to know if this is an MVP pattern. I think that the React application implements the View and the Presenter, while the backend realizes the Model of the website. I think it's not MVC because the view isn't updated by the model di...
The way of running automated tests (specifically, a large number of small, «atomic» unit and regression checks) that I am used to is to maintain a monolithic executable built on top of a test framework that aggregates the individual checks into a test tree and provides «quality of life» features like colourful or machi...
I am looking to understand the difference between the words index and offset. I have never seen "offset" in reference to lists/arrays/etc in programming. I have only seen index. To me, these mean the same thing. But how one is used heavily and one never implies they have different meanings. They might also just have hi...
A transaction has ACID properties, where "I" stands for isolation: Transactions are often executed concurrently (e.g., multiple transactions reading and writing to a table at the same time). Isolation ensures that concurrent execution of transactions leaves the database in the same state that would have been obtained ...
I'm in the process of adding a message broker (ActiveMQ Artemis) to a system currently and while I have my own notions on how I can divide up the namespace, it seems like a good time to get opinions from others on how they like to name their queues and topics. The overall topology I'm after is to support functionality ...
Please allow me to illustrate my question with a simple example. Let's suppose we have a Customer class: class Customer: def __init__(self, name, surname, email): self.name = name self.surname = surname self.email = email And we also have a Bill class that needs info from a Customer object...
Using Vue/Electron to post to rails/Postgres backend. Is there a common design pattern/approach to posting multiple audio file objects BUT in a single post request? My current process (which works, but is very slow) is to convert each audio file's binary data to text, append it to my JSON and then send it all to the se...
Stallings' Operating System book says about condition variable in Solaris, A condition variable is used to wait until a particular condition is true. Condition variables must be used in conjunction with a mutex lock. This implements a monitor of the type illustrated in Figure 6.14 . The primitives are as follow...
I have been developing for many years and have used many OOP languages over the past 30 years. I am still not sure if I have ever used polymorphism. I have searched and read but still don't understand the concept. Is it a feature of OOP or an implementation? Is it a combination of Abstraction, encapsulation, inheritanc...
I've been reading a lot on why one should use messages (w/ event sourcing/CQRS) for microservices communication and I get it. But most of the stuff I read online state that the main reason for using message brokers over direct http REST API communication is the cascade failure effect when a a service is down. Well, tha...
One senior member of my team setup a new git repository for our product we are working on, since we are migrating from SVN to git. Our product consists of different software components that are working more or less completely independent and are also completely different in terms of code. On SVN, these components were ...
I have a executable that starts up some resources, spins a bunch of worker threads and then waits in a loop for the done command. After the done command is received, it does a bunch of clean up and then exits. void run() { /* more initialization code, creation of classes, start worker threads etc. */ while (!d...
I have an application that does some document handling as part of its functionality. I would like to implement a "Drive" emulator that would allow users to navigate and manage documents as if they were on a local drive. In my mind, this would be similar to how a remote session can access a local drive. But I'm not sure...
Here is my UML Diagram: Are the "post answer" and "vote" actions an extension of browsing? Since you have to SELECT / VIEW (?) a question in order to answer or vote. Or can I simply say in my use case text that you must have selected a question as a precondition? Should I also change Browsing to search only? Diagram i...
I have yet to hear an answer from anyone as to why overloading of any type is a sound programing practice. Calling the same function name with an almost infinite number of variations on the surface and under scrutiny screams "hey this is a error looking for a chance to instantiate itself". I'll buy the object oriented...
Our budding (currently internal) API deals with building information models, originates in our main application written in c++. There is a small implementation of it in C# for easy interop with other CAD software exposing .Net APIs (mainly just a class library with de/serialization). This also covers python scripting t...
I am working with a message broker technology, to which events will be published (following an "event carried state transfer" architecture) for consumption by other applications. The vendor library uses a pattern where a message is handed to a Session object defined by the vendor's client library code, which sends it o...
Is it correct that In concurrent programming, a critical section is a sequence of statements which can't be executed by more than one processes/threads at the same time. Atomicity (as "A" in ACID for transactions in database systems) means a sequence of statements must be either executed completely or not at all. I...
My question is about clean code or best practice. I have a big formGroup and in my opinion its more difficult to map the form to an object than to send the form to the backend. best regards
Was introducing default methods to java inevitable? As far as I know multiple class inheritance was not introduced to avoid difficulties with the method signature clash in base classes. So we avoided it with classes and on the other hand we introduce this problem with default methods as we have to override default meth...
I decided to go with Firestore to our new project. The goal is I don't want our server logics and database designs are locked-in by Cloud Function and Firestore, And also long-term maintainability. While I know there will still have some degree of locked-in, My idea is to write the logic in Cloud Functions separately a...
For the designer of a language syntax, what are some reasons to choose a repeated delimiter to escape that delimiter, instead of having a separate escape character to escape that delimiter. A common example would be escaping the character ' in a string delimited by 's. Two common approaches to get the string It isn't. ...
I have 5000+ strings pet-project for CLI and it can do some optional calculations and can output results to CLI or/and to file. Some new modules don't work. Now I catch with GDB some strange segfaults and stack overflows, which I can't fix, though, I found all the places where the bugs are living. So, I see where and w...
For instance, in the case of PostgreSQL, it is entirely acceptable to use a newer client to connect to an older server; but if you do the opposite, using an older client to connect to a newer server, you would get a warning. My gut feeling is that, by off-loading the responsibility of ensuring backward-compatibility to...
Background: Our group of 10+ engineers all share a Git Repository. In the past, someone has checked in binaries that have caused the size of the repository to grow from ~10 MB to ~10GB. These unneeded binaries are slowing downloads considerably. I have found a tool/method for removing the binaries. Plan: My plan is t...
I am trying to create admin dashboard to track sales and inventory. Using React front end and Django rest backend API. Right now I am pulling sales and would like to make some charts. What's the practice here? Do I pull raw data then manipulate data in React? With some package? Do I manipulate in backend? Do I creati a...
I want to create my own little piece of hardware, (not sure what yet, but that's where the coding part comes in..) and I'm stuck at this little question. I have the parts, but not the means.
We are developing a system that runs a certain kind of simulation for our customers: Every simulation runs on it's own server. We typically have a two digit number of simulations running. A client can monitor multiple simulations. A simulation typically runs a few weeks. A new simulation requires manual deployment to...
I am writing a documentation for a programm where a function is defined and it is called three times. I call the definition of the function "function definition". But what is the correct term for the three executions of a function? I have read the term incarnation. However this name only appears, when the function is c...
I am wondering if it is good practice to name function which does the main logic "proceed" + "functionName". I would use that name if there are some checks(if-s, try-catches, etc.) in the beginning of the function and I would like to separate main logic into separate function. Example: private void function() { if...
REST APIs in virtually all languages use methods named Get to get GetById(int id). Is it ok to use this convention for repositories? Let's say I have a Professions repository for the sake of example. Is writing _professionsRepo.Get(profId)intuitive or would most programmers rather see _professionsRepo.GetById(profId) o...
First, the most obvious grouse someone has against this I can think of is the intricacies of an actual method. It's not enough to merely ensure no errors are thrown. Functions usually contain alternate paths borne of if/else constructs. For this, assume I use a declarative syntax that causes the generated/in-memory tes...
I know HATEOAS can be a bit of a heated topic. Some people like it, some people don't. That is not what I want to discuss. What I want to discuss is what technology other than HATEOAS (or some form of telling the client what can be done with an entity) can be used to prevent the client from writing the same logic that ...
I have some experience with WinForms and want to make a GUI for real-time plot of signals and also controlling hardware. I am planning to use WinForms for this and want to avoid WPF. My reasoning is that I don't need the outlook to be good looking but only functionality and performance. In WinForms I have written befor...
I have device interface classes written in c# for electronic variable loads. They are mostly for DC devices. We got a new one that does loading for both AC and DC devices. I also have an interface named IVaraibleLoad that lets me interact with them generically and group them if we are using several in parallel. From th...
Intro Hey, my question is kind of hard to explain so I apologize in advance. Question I'm trying to implement microservices for our ecommerce and I'm having issues on how to respond to a request when the actual logic and data needs to be determined by other ( 2-3 ) services. In order to make it easier to understand, I'...
Im in the process of creating a base class for typed HttpClient services (yes, I'm utilizing IHttpClientFactory). I wrote the process in such a way that for each CRUD method invoked from the service, the first thing said service does is check for and assign an access token to attach to the HttpClient header. Example: p...
I'm trying to implement microservice architecture to our application (basically an ecommerce) and one of the challenges that I can't really find a good answer for (despite being so many similar questions about) is how to: Create an entity in database Publish an event to event-bus at the same time (atomically, so basi...
I am trying to find the best way for a microservice to communicate with GraphQL Basic scenario: Client subscribed to GraphQL via Subscriptions (WebSockets) Client creates an Item using Mutation which will notify all the subscribed clients that the Item was created. There is a case when a Worker microservice would need...
I have experience building RBAC-based authorization mechanisms, and understand the theory behind ACLs (DAC?) though I've never had the need to implement them. A situation was just presented to me that I realize I have never thought about dealing with before, but absolutely should have. I believe OWASP refers to this pr...
Suppose I have an inventory management software that manages an inventory of phones of many subsidiaries of a company. A business requirement for this software is that you can't register a phone with the same IMEI (a serial number) as another. What I find difficult is where this duplicate check logic should be placed. ...