instruction
stringlengths
34
36.1k
going through the web I always read something like Java Interfaces have no state and no behavior If you look what the common definition of state is then you likely end with what the objects have, Student have a first name, last name, age, etc The thing is I guess since Java 8 with their default methods I can also d...
Ideally, functions should do one thing well, and only one thing. Does the same thing apply to what a module should export? Of course, modules aren't always the same thing as functions, but they often are (at least in my experience). This rule (prefer-default-export) encourages more files that only ever export one thin...
I am prototyping a social network as part of a project I am working on and want to learn the right way to do it as if it were for an industry leading company. I've decided on implementing the social network in a graph database like Neptune or titan db. I also intend to do full text search on posts using a full-text ...
There are 3 branches involved in this question. I have the master branch, I have a bug-fix branch, and I have a refactor branch. This is the timeline: Created bug-fix branch off master to fix a bug. Created refactor branch off master to do some refactoring. bug-fix branch has been merged to master. Now in the refactor...
I really don't know which StackExchange site this belongs on. It didn't seem to match the "on-topic" list of DBA.SE or SO.SE ... so please let me know if I should move it. I also couldn't find a similar question but am happy for this to be a duplicate so I can close it. I have been writing SQL for almost 10 years but I...
My team is developing a web application, where we have in the requirements to display the data in multiple unit which is set by the end user. Where should we write down the unit conversion logic, on front-end side or back-end side. What is the good approach of doing the data conversion? We should perform on the fron...
I don't quite understand, how the following typedef is parsed by a compiler to call code at a specific address. I guess I understand that a function is just a pointer and we're typedefing such a pointer. But what actually happens at compile and run time and where will the arguments get placed? From the SAML10 Family da...
I have an invoice root aggregate that has many invoice line entities, a due date value object and two reminder entities. We're not using event sourcing yet. The post data I receive from the form the user has filled looks like this. I simplified it, the important part is that when I create a NEW invoice I don't have any...
I am developing a microservice platform with Spring. So far I have a few microservices and a service discovery server where all microservices register themselves. I also have an Angular client application, which right now is calling the address and port of one of the services. However, what if the service gets replicat...
I have an application that writes data to database. In case of network breakdowns, the connection to database gets lost & my db queries freezes the whole application. So, in order to make it asynchronous, I've used a message queue mechanism to separate out the "db queries" part with my "core application part". The prob...
I'm creating a simple Dependency Injection library for Unity (no constructors available) and I want to use a generic class that implements a generic call for each class that would inherit it allowing changes and scalability. This would be my generic class // Class with a generic type public abstract class MyGenericClas...
I'm developing a multi culture application with different microservices, The microservices communicate with each others with integrations event, so when a new record is inserted the owner of the data send an integration events on a bus and the other microservices who need that record integrate in their storage. My qu...
Some background information to our actual situation. We are migrating from TFS VC to git. We've a ASP .NET Web API with many different Controller Libraries (>30 assemblies). Many of them are referencing some Core assemblies like our data model. In TFS VC those Core Assemblies where checked in relative to our projects i...
I'm trying to understand containerized apps and databases and I'm trying to understand the microservice architecture using kubernetes. One thing that I couldn't get my mind convinced is the database part. For example I have a Venues database and a Venues REST API application in a container, which also has the database...
Using GitFlow, I created a new class on the develop branch and gave it a property: Public Class Class1 Public Property Property1 As String End Class I committed that change and created a new feature named feature2. In that branch I added a property: Public Class Class1 Public Property Property1 As String Public ...
I'm writing a program in Python that has two different entry points. There's a CLI that processes some data and needs to be installed to run hourly on a server, this populates a database. There's also a web app that has a front end for viewing the data in that database. I'm using sqlalchemy as an ORM for the database t...
The issue I am building a server-side system that handles streams of time-series events from multiple users and I'd like to perform an action after a certain quiet period has elapsed in the event stream of every user. For example, a user emits this stream of data: -[5]------[4]-[3]--[2][1]--> My consumer will handle t...
In this answer to "In C++ why and how are virtual functions slower?", the author mentions below point: "Get the right function address from the vtable into a register (the index where the correct function address is stored is decided at compile-time)." As a follow up of this comment, i have some questions: What is th...
Say I have 500MB of memory to work with, but 100 terabytes of IDs I want to generate. I want these IDs (GUIDs) to be randomly selected and applied to records, so they shouldn't appear in order when selected. Also, I have 1 billion petabytes (in this example) of possible IDs, which is way too many to actually generate. ...
I am trying to design a mail integration to a system but I have to process emails as they come. One of my decisions is based on whether I can be 100% sure that email client always send a plain text version of the message body regardless if the user actually writes it in HTML. For some context: I want to listen to a mai...
As everybody knows, C allows us to write anything we want. There comes one big problem — we are the only who responsible to handle errors that comes from standard library functions and, therefore, write reliable code. The goal is to make writing reliable code easier. And the question is about errors that comes from sta...
I have an application which calls various services to load data(of different entities shown in the web page). Opening the network tab in Chrome can tell me which APIs are being called. Now this can be used by other users to get the data, say calling the same API endpoint in another tab. I do not want the users to be ab...
I have some code equivalent to this: state = True if xyz: state = False try: value = foo() except: handle_exception() state = False if state: bar(value) On the last line it will appear as though value might be referenced before assignment, even though it won't be. This leads to code which isn't ver...
Context We have a team of one active developer and two occasional ones. We are setting up a new project and after reading https://nvie.com/posts/a-successful-git-branching-model I was seduced by the idea of keeping only master and develop branches in the remote git repository and all feature-* branches locally to keep ...
I have implemented algorithm BFS(Breadth First Search) using a neighbors list ADT for scanning a graph and gathering information about it and answer questions. I have function called BFS which implements the algorithm and i can answer questions(like: How many connected components the graph has ? Diameter of the graph ...
Before Kafka, we had RabbitMQ, ActiveMQ etc. Mostly there use to be a something before version, in technology. But What was industry using something similar to Docker and Kubernetes, before they both became prevalent?
Each pod represents single instance of the web application in a node of Kubernetes. Lets say 100 users are signed into a web app like Stackoverflow and connected to Pod1 of NodeA. Pod1 is down now. But Pod2, Pod3.... PodN are alive in NodeA. What happens to the users who have logged in ? How does Kubernetes handle thi...
When using derived types in MPI for communication of data which is not contiguous in memory, the sequence of datatype-displacement pairs defining the derived type seems to be assumed to be the same for each process, but I cannot find any guarantee of this being the case. In C, suppose I had initialized on every process...
In implementing a binary tree in Java, should the node class be a separate class file independent of the BinaryTreeclass, or should it be a default class in the same class file as the BinaryTree class? First Example: Node is in separate class file BinaryTree.java public class BinaryTree { ... } BinaryTreeNode.jav...
Am trying to build a highly available and fault tolerant file drop location in linux server. Please find the current system design below: We got 2 linux servers in secured zone into which several clients from unsecured zone will be dropping files in batch mode using xcom utility. Each client has got different times to...
Is there a design pattern that fits this description? A factory that creates classes that can be disabled and enabled. The users of the class don't know if the functionality is enabled or disabled--they just call methods on the class. What are appropriate names for this kind of factory and class? How do you make this ...
I have built a very basic webcrawler running off my laptop so it has limited memory and limited hard drive space. The way I have it now is I'm using MongoDB to store the links I find on pages. I make sure to sanitize them and remove any unnecessary URL parameters that might cause duplicate pages to be fetched. Every ti...
As I understand with laravel passport, in order for a third party application to consume my api they need to register their application with mine by creating a client. The passport:client artisan command can be used to create clients. When using this command it prompts you for a user id to assign the client to as follo...
I am trying to find out if it is allowed in the UML to change the visibility (access modifier) of an operation when overriding it. For example, in Java it is possible to increase the visibility of an overridden method from protected to public: public class A { protected void doSomething() { } } public class B ...
In Javascript, I have seen a code like: const getSomeMapper = (param1, param2, param3) (param4, param5, param6) => { // uses all these params and returns a promise } interface MainParamInterface { param1: string; param2: string; param3: string; } function entryPoint({param1, param2, param...
I have an invoice aggregate that I create with a lot of data: $invoice = Invoice::create( InvoiceId::generate(), $lines, // Collection of lines InvoiceNumber::create('1'), $address, // Address value object Currency::EUR(), null, $discounts // Collection of discounts for lines and the invoice...
there's an up and running self-serve customer portal built that I'm trying to make a bit better when it comes to displaying proper items for different client types and auto-logging users. Here are a few considerations: Built on ASP.NET MVC (4.7.2) Authentication Mode = Forms Uses custom Membership Provider Uses variou...
I would like to know if it is allowed in the UML to specify a different return type for overloaded operations. This is possible for methods in Java: public class C { public int addOne(int a) { return a + 1; } public float addOne(float f) { return f + 1f; } } My question is whether this...
My team is just starting with BDD, and we are learning to write scenarios in a GIVEN, WHEN, THEN format. This will position us to start to automate our tests (with selenium) at the start of sprint, so that we fail until the application code catches up to satisfy the test(s). We are thinking that the automation of our ...
I got this question on an interview the other day and was clueless to what the best practices are for solving it. It's the issue where you have to transfer money between two systems and want to avoid double counting. The systems are not located in the same hosting environment and each is web accessible through a gate...
I'm developing a web application for academic purposes. What i have to do is a simple website which keeps track of realties along with their respective owners and the tags they are bound to. The application takes data from a MySQL database and must include the following features: List all realties List all realtie...
I am building a new system, which I will call S, that needs to get some data from another system, which I'll name D. System D provides a client and a collection of classes(POJOs) to represent the responses in memory. Instead of using the client directly everywhere, I am writing a sort of adapter which will handle all t...
I'm very, very new to the networking and AWS side of things, but experimenting a bit with some concepts. I was wondering if anyone had suggestions for the following use case. I'm in an experimental capacity at the moment, so these atypical practices have their reasons. Anyway, thanks for any guidance y'all can provide...
I'm currently considering breaking down one of my libraries in some 20 Debian sub-projects. Each part is already pretty much a standalone bit in the existing large library. What I'm wondering is the impact at runtime. Will my software be impacted by the fact that they'll have to load more libraries? I think it won't be...
Is there some sort of pattern for enforcing the calling of a populator method before any of the rest of the interface is used? I say this because it is not generally a good idea to put something that has network calls or something that does large calculations in a constructor. That work needs to be done before the oth...
MethodA calls an MethodB which in turn calls MethodC. There is NO exception handling in MethodB or MethodC. But there is exception handling in MethodA. In MethodC an exception occurs. Now, that exception is bubbling up to MethodA, which handles it appropriately. What is wrong with this? In my mind, at some point a call...
I'm developing a microservice system. I have a discovery service (Eureka) for all my services and an API Gateway (Zuul) to call each service via an URL. My problem: How can I assure that a service call via my API Gateway is high available? If the gateway dies, my services aren't callable anymore. I could start multipl...
The benefits of Behavior Driven Development (BDD) seem to be that non-technical stakeholders are more easily included in the writing of requirements/user stories. In an open-source project, most stakeholders seem to have a technical background, and should thus be able to understand the tests themselves, without a BDD ...
I'm building an API that will be used by the front-end in React and I'm not quite sure how I should send the permissions of each user based on their roles. Some fields can only be edited in some states and by a defined role. It is quite complex and I really don't know how I'll send that information, everything I know i...
So I've seen some C libraries written so that they compile without any changes with a C++ compiler, for example Lua. What are some advantages and disadvantages of doing this? A few basic ones I see are: Advantages: library can be used with any C or C++ project with no extra effort (without using extern "C" for example...
I understand that generally shared libraries are a microservice antipattern, and the disadvantages of shared libraries in a microservice world are well documented. However, I have not been able to find much information on extracting something like core library code into a shared service. What are the advantages and di...
Wikipedia describes a bootstrap compiler to have these properties: An initial core version of the compiler A minimal subset of the language to be used by successive compiler versions Everything I've read online assumes an initial subset version gets bootstrapped, but isn't it possible to bootstrap a recent compiler v...
I'm planning to develop a web application that would run on-premise at the customer. I'm quite unsure about the whole process of setting up the site in a user-friendly way, but mostly disturbed by the SSL configuration. Which formats are a must to support? Should I require the admin to run my Java application with a lo...
I'm writing a simple web application that allows users to login on different levels. Example: admin: may access to everything in read/write manager: some sections are in read/only operator: only few sections available I'm using CakePHP, by the way. As far as I understand there two main approaches to handle such a dif...
I am used to programming java on the server side with ORM frameworks and using abstract classes for CRUD. But now I'm workign on a desktop project without ORM and just the good old JDBC API for database interaction (And I can't). I thought to implement an AbstractDaoCrud to encapsulate basic CRUD operations, but I gue...
If I'm writing a method, in C# for example, I will use a try catch block. Let's say the method adds some numbers but I log exceptions in the catch block. What's the best way to handle an exception causes in the catch block? e.g. the method may have an unrelated exception to the logging in the catch block throwing file...
Caveat: I'm conscious that this question may not be a great fit for stack-exchange platform as maybe 'too broad' but will try & structure it that it helps people in the future I have 2 event steams that represent GPS & Heart Rate sensors over a period of time. Both sensors are non deterministic is when they raise eve...
Say you're using an external library, that includes type declarations, and it has a function like: function foo(x: number) : string { //implementation } Somewhere in our code we're calling this with: function ourFunction() { return foo(1); } or with the return type explicit : function ourFunction() : strin...
I need to simulate & output the human heartrate BPM with real-world like values. I've been looking at a gaussian random approach but don't believe this fits my use case. I'm not concerned about the actual values only that they are uniformed & match the patterns of a monitored heart beat (i.e. increasing/decreasing unif...
Imagine the following scenario: I wish to build a photo-sharing social network app similar to Instagram (iOS only for the sake of conversation), and I want to make sure that users are using only my app to upload the photo. If it's not uploaded from inside of the app, I want to discard that photo. Since anyone can captu...
So lets say I have a SQL query made by a server that fetches up to thousands of records at a time and I need to display those records in a grid(similar to AG Grid) on the client for the user to review. The user then has the ability to flip through the records (the grid is set up for both server side and client side pag...
I'm quite inexperienced in design patterns and while I was studying them I got confused about the application of the Factory pattern. Wouldn't DI decouple the classes more than factory would do it? Or would it be overkill to use DI in some situations? I understand DI as a step beyond Factory in decoupling by implementi...
I am building few sites for my company's client. The sites are mostly the same but could have some customisations. so we decided to create duplicate sites instead of multi-tennant and we decided to use packaging system so we can install them as required by a site. Now my question is if I have a package 1 (events) who a...
I want to create a java program that can find the shortest word ladder between two words. It's been suggested that I use a graph data structure with words as nodes. The idea being that nodes with words that are different by only one character are directly connected. I'm dealing with a text file of possible words that h...
I have an application that is sending messages over a socket from different threads. I create my own wrapper for the socket that enables me to extend functionality. Example - on new SocketConnection() it returns only one instance based on IP and port. So if some other thread tries to create instance of IP 1.1.1.1 and...
I've been learning object-oriented concept from this book, and stuck in a specified concept in the middle of chapter 6. No one could understand my question without brief prologue, so I'm starting with it. The purpose of chapter 6 is teaching how to describe objects by using abstract data descriptions; three criteria ar...
According to "Clean Architecture", should you inject all entity dependencies (should you inject core business logic)? For example, if I have a vector entity, should that entity be injected into all other entities/use cases or should the entities/use cases depend on vector directly? In one way, it makes sense to inject ...
Is there a software pattern (or some recommended guidelines) for how to convert between enum values and discriminated unions? Or more specifically: project a discriminated union onto its enum case? And how do you call the enum case? "enum tag"? "union tag"? Does it even have a standardized name? For example this Swift ...
Suppose you have 2 stored procedure, let's say a GetProducts and a GetProductDetails. Now, the GetProducts returns a list of products with a property that is "calculated" basing on additional calculation (the last time it was purchased, the number of resellers etc). How can I be sure about the correctness of the data ...
I am working with a startup company for a while now. They have been affected by some reckless developers in the past. One area they want a real and immediate improvement is when they assign a task to a developer that requires database read, they want to prevent unwanted fields to be returned by API system. In other wo...
I am developing a system that has a list of projects (verified by mentors) to which a student can provide a solution. Now I am stuck in a situation about how the student will submit their solution for review by our mentors. The student will fork our project repository (problem statement, initial code and tests) and wor...
I read this guide about recommended app architecture for Android. Here is a graphical summery: The role of ViewModel is clear, but I don't understand why we need it if we use Repository. The purpose of ViewModel is to keep the data persistent during the Activity life cycle, but if the Repository anyway exists as long ...
Is there are way we can completely avoid illegal states rather then throwing an IllegalStateException when a method is called when it should not be? For example: public interface Process { void start(); void stop(); } Illegal state would be created if stop() is called before start().
The Problem I would like to create a managing "overseer" class that connects several related object groups together where any particular group is able to be easily swapped for another using C++11 syntax. A secondary goal of finding a good approach to code structure is to make the underlying code run quickly (since it w...
When you use tools like jsdocs, it generates static HTML files and its styles in your codebase based on the comments in your code. Should these files be checked into the Git repository or should they be ignored with .gitignore?
Backstory (You can skip) I am writing a pronunciation library for irregular words. Take something like the following: T1E1s // tee one E one es | tee one E ones 1994-1995// 1994 (minus|dash|to|) 1995 19-mm // 19 dash mmmmmmmmmmmmmm | 19 dash millimeter | 19 dash em em 4x4 // 4 ex 4 | 4 times 4 | 4 by 4 Wha...
I have an algorithm to create a version for an entity and then I save that version against below 2 entity: 1) Variant 2) Category interface IEntityVersion { string GetVersion(); } public class EntityVersion : IEntityVersion { public string GetVersion() { return null; } } public interface IVari...
To write the grammar for Whole Numbers (0,1,2...) in BNF, we may write: Number ::⇒ Digit MoreDigits MoreDigits ::⇒ MoreDigits ::⇒ Number Digit ::⇒ 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 For a number like 37, the parse tree would be: Now here is the part that confuses me. If we replaced the first rule Number ::⇒ Dig...
I remember reading on someone else's post that test code should not be treated as normal code but as small whole programs and that is an idea I really like and would like to refer to when discussing with other engineer colleagues, but is not unanimously shared. Specially I was referring to it when discussing if test sh...
There is a db with tables of genes. And these genes would need to be annotated based on the client's needs. So if a gene matches condition x, then add a new column y and value z to that gene. Every cancer is different, so we supplied every client with a template configuration file where they can insert their queries an...
This is a design question asked during interviews. The requirement is to build a "discount coupon" system that tracks coupons available in an eCommerce site. Something like: Coupon code CDSXGF can be used 100,000 times, gives a discount of 2% Coupon code HFSECF can be used 500,000 times, gives a discount of 10% Addin...
I'm trying to write a chess engine, Min-Maxing works. Now I wanted to implement Alpha-Beta-Pruning, but despite reading about it and watching videos, I must have a severe misunderstanding somewhere. For Min-Maxing, I build the complete search tree, and evaluate only the nodes at the deepest depth. Then go upwards, and...
I hope this is the correct SE site for this kind of question. My team is currently developing an application which IMO needs access control beyond RBAC. Users can have access rights to entities based on several factors e.g. the administrator of a company is implicitly granted admin access to subsidiaries. To allow abs...
For a complex service that my team and several others maintain, two of my team's applications are called when processing one incoming request. The flow is as follows: an upstream system invokes an HTTP endpoint of our application A, then several other applications managed by other teams are called, one of them publishi...
I have a system, which stores different objects in DB. Each such object has properties. Some of them are relevant for all objects (like Name, Description), but some are specific to each object and depend on its type. Now I need to create a web method, that will retrieve that objects and their properties as set of POCOs...
I am working with an existing numerical model implemented in C++, and I don't have much of a background in software design. This model reads in many (~100) of structured text files, performs numerous calculations, and then spits out an answer. The current organization of the program is as follows: Main function create...
My users will be businesses with a small number of accounts each: e.g. Business #1 with 3 users, Business #2 with 5 users, etc. I am trying to determine the best way to organise the relation (on Postgresql, hosted on AWS) for each business client: for e.g. each business will have their own sets of customers, logs, prod...
A few years ago, now, we had a chap working with us who introduced the following topology for Mercurial... The main repository server obviously holds the primary repositories, as you'd expect, but the the required repo is cloned to a local repository, and from there into one or more working folders. I've never seen th...
I'm struggling with a decision about how to design a web-API where I create new "things". We roughly follow the API guidelines of Zalando, which do provide a nice starting point for web-APIs (https://opensource.zalando.com/restful-api-guidelines/). But there's no guidance on how to handle creating new resources, which ...
I have been investigating using RabbitMQ for a publish/subscribe pattern across micro-services where aysnc calls are appropriate but I am having trouble understanding some concepts and could not find any info in the manual. I'll outline a basic example of how I wish to use it below. I have a core service for user manag...
In a new Java project I plan to use an extra layer above Hibernate entities. So there would be a CustomerEntity and CustomerDomain. The reason for that is that the CustomerDomain can contain extra data fields from other sources like SOA or other DB. (Maybe DTO is better here than Domain.) In the pilot solution both the...
I would like to build a microservices architecture to handle the following scenario: I have a building. The building has some kinds of devices. And the devices can be used by the users. In the system, the administrator can add a user and allow the user to use selected devices in the building. I have user service, devic...
Imagine there's a boolean status variable that is either running or stopped. This variable is running by default and comes together with a deactivator function. When a client calls the deactivator function, the status changes to stopped. Calling the deactivator function returns a cancel function, which, when called, re...
I have a pretty general question about the design of Angular web applications. I'm a big fan of writing services. Sometimes I write services that have only utility methods that don't require state at all (think mathematical functions and the like). I feel that even in that case writing injectable services for the utili...
Traditional switch blocks have one scope, so the following throws a compiler error "A local variable or function named 'message' is already defined in this scope": switch(value) { case 1: string message = "Val: 1"; break; case 2: string message = "Val: 2"; break; } As Eric Lipp...
So I have started reading some books and articles on architecture. They all state (put a little simply) that you should never let your view access the model directly, when using a Model-View-ViewModel (MVVM) pattern. Instead there should be a view model for each model. One of the ideas is, as I understand it, that for...
Currently I am trying to setup a relationship between user groups and roles. I am trying to satisfy: Multiple roles apply to single group multiple groups can have same role multiple groups with single role. I have a Group Table with RoleID and GroupName and a Role table with RoleID and RoleName. I am able to sat...
A quick search of this stackexchange shows that in general composition is generally considered more flexible than inheritance but as always it depends on the project etc and there are times when inheritance is the better choice. I want to make a 3D chess game where each piece has a mesh, possibly different animations a...
I am developing a desktop application that will be run at each station at a call center. It listens for an incoming call, and whenever a call arrives, there are about 30 different classes that need to run various operations. Some of these operations are synchronous, such as setting a flag because they want to log onl...
Is there a way to generate a single use token for password recovery, without using a database? This is because, I have an application that doesn't have a database, and doesn't store or has access to the login database. I use a Web Service to login the users, and store everything I need on a session. So there is no need...