instruction
stringlengths
34
36.1k
In dynamo paper, it says that in production most of the users set N = 3, R = 2 and W = 2. The common (N,R,W) configuration used by several instances of Dynamo is (3,2,2). These values are chosen to meet the necessary levels of performance, durability, consistency, and availability SLAs. In most production system, N =...
I have three projects: WebAPI, Services and Repository. WebAPI has a reference to Services and Services has reference to Repository. Now I need to add a Unity Container for Services and Repositories but in WebAPI it's doesn't allow to add a reference to Repository. How can I change this in order to obtain the desired...
I have written a C# service using MVC (No view). The program starts execution and processes some data from database and stores some aggregated data and works just fine in VB whenever i run it. What i have an issue with is deploying it to production. Whenever i prepare an installation and run it on production server a...
I have written a spring boot rest API application with OAuth.I have integrated swagger UI for API documentation. I want the API endpoints on swagger UI to be accessible without an access token. This is my swagger config : package com.XXX; import org.springframework.context.annotation.Bean; import org.s...
I'm a software developer in a 7-8 developers team. We've been doing code reviews for quite some time now and code quality has improved over time. However I recently noticed that some developers are being asked for more code reviews than the others. I'm afraid that's because of their flexible attitude. In my view, this ...
Is there a way of committing code transformations or refactorings in git, perhaps as metadata for an actual commit, so that code editing tools can apply the change as a conceptual transformation instead of a whole lot of text changes? To illustrate, suppose that a class has a public property FOO. Someone might rename ...
We currently have a big code base from which we can generate 5 differents softwares. The code base is composed of around 20 submodules which are used (or not) by each software. Keeping a semver for each software will probably lead to a nightmare. We're gonna end with a ton of tags and branches on our git repository. I'...
I have been working on an n-tier monolith application for a couple of years, and want to build a plan to transform this big ball of mud to a more maintainable system. I came across Software Architecture Patterns by Mark Richards, where he explains different software architecture patterns, including Microkernel and Micr...
We have a situation where the business has a range of datasets which end users contribute to. The business needs flexibility in adjusting or rather extending these datasets, and also publishing new ones. As part of that process, there is an important (and often complex) "flow" through the dataset which means only some...
When you want to send your own types over WCF, you have to add lots of [ServiceKnownType(typeof(MyFirstConcreteType))] to the interface definition of your contract. You cannot use [ServiceKnownType(typeof(IMyInterface))] instead though that will compile, and then fail at runtime. Also when defining MyExtendedFirstConcr...
Background: We have the code for a 20 year old MMOG that some people still play, and we have the rights to opensource it. Currently, the server isn't terribly authoritative, i.e. the client is the one that registers hits/kills, etc. The server checks certain things, but if we opensourced it would be easy enough to simp...
I'm a newbie coder. I find it troublesome to declare a variable in 1 function and not be able to access it in other functions. I have to make many of my variables global just to get my code to work. But a lot of people say that the global state is evil. I don't understand the purpose of having limited scope, anyway. Sc...
We are using Spring Integration DB polling which polls a table every second and executes some logic based on result. My questions are: What are some good practices we can implement to account for DB load? The query currently is just simple select, is there anything we can do to improve it (indexes, different query, et...
So I have a function which is like a constructor for my structure: MyStructure* CreateMyStructure(...) { MyStructure *my_structure; double *data; int *colind, *rowptrs; data = malloc(sizeof(double)*N); if (data == NULL) { return(NULL); } colind = malloc(sizeof(int)*N); if (colind == NULL) ...
I have a mail server setup with Postfix and Dovecot, and an application server setup with node.js. I have user credentials stored in my application server, and I want to use the same credentials for accessing the mail server. As I understand it, I should be able to use LDAP with Dovecot, handling authentication on a re...
What do I pass in for the existing arguments that have no value, undefined or null? Existing function foo(a, b) is called like foo(1) and foo(23, "hi"). After adding a new parameter, it's foo(a, b, c) and I want to change foo(1) to be foo(1, undefined, 3.2) or foo(1, null, 3.2). Does null 'looking better' override the...
I want to sell web app to be hosted internally and share source code with that specific client but not to be redistributed(commercially or non-commercially) to outside the office. They can edit and improve their source but I don't want them to resell it or part of it to other parties, neither the source code or as a s...
Until recently I was a huge fan of global variables because they are simple and allow building solutions to problems quickly. At one point I had to make a slight change to my application: it needed to fetch data from multiple sources. I had a couple of simple global functions like RetrieveUser(id string) and FindUserBy...
The use case: I am working on a microservice based architecture and I am wondering how I am supposed to debug a microservice (with my IDE attached to it) on my local machine where I develop it. The problem: Until today I just had a few microservices (~4-7) for a whole web platform and in order to debug a single platfor...
I do not understand how you think about it:https://wiki.php.net/rfc/nullable_types when It is widely confirmed, that using nulls is bad practice Where am I wrong? thanks. I'm not criticizing !. I do not understand the motivations
We support multiple umbraco websites for a client. We have our local dev env, staging and live for each of them. Some time ago we started building and deploying all the websites with appveyor. Everyone pushes to feature branches and all of these get deployed to staging for testing. We don't have an env for release tes...
I have a project that has a public API and an internal code. The public part is published on MavenCentral. I thought about making a package each, but everything from the 'internal' package that needs to be accessed from the 'api' package needs to be public -- therefore available from the end-user POV. Currently, what i...
I have a situation where a DB field is storing an enumeration value whose underlying type is int, so I'm getting back values like 0, 1, and 2, which should represent MyEnum.Foo, MyEnum.Bar, and MyEnum.Baz. I am calling a repository which returns DTOs in order to get a DTO which contains this value. My question is, wh...
Restructuring some code, and the way I built it up over time has portions that look something like this: s.replace("ABW"," Aruba "); s.replace("AFG"," Afghanistan "); s.replace("AGO"," Angola "); s.replace("AIA"," Anguilla "); s.replace("ALA"," Åland Islands "); s.replace("ALB"," Albania "); s.replace("AND"," Andorra "...
hello I am new here and I am not a software enginner I am a junior only and I saw always this : ** Agile/Scrum** I understand that is but my question is how could I implement that in a project real like example a system web/website about a company/etc? I was looking for a example in google but I look theory only. som...
How to define overall monitoring of event-driven architecture? Each component talk to other component via events. Consumer(s) react to events within minutes to days based on use case. Each component performs some work, updates the database and generates events. Event consumer then performs some work and updates the dat...
I'm creating a Functional Specification Document (FSD) for a project. I'm pretty confused as to where I should specify error messages? Do they belong in the FSD, or are they part of the Technical Specification (TSD)? I've read these articles to help me get started with making FSDs: How to Write a Good Functional Speci...
I'm fairly new to both microservices and shared in-memory databases like Redis. I'm wondering though if it would be a good idea to combine the two to address the challenges of data duplication, sharing and ownership in a microservice oriented architecture. Wouldn't it be a great solution to have microservices who nee...
I'm developing a small multiplayer game. It'll be served by one websockets server and consumed by multiple consumers. As such I need to be cautious about concurrency errors. The general software architecture I've come up with is: Encapsulate all game state into the highest-level Game class and don't allow other thread...
I am thinking how to change password for user entity in my OOD Spring application. What seems to me to be the easiest way: Ask repository for particular user account entity Encode plain password with password encoder outside of the entity Set encoded password back to entity Ask repository to save the user entity Is ...
I'm working on learning Haskell, and one of the simple exercises I put myself through to this end is writing a function that deduplicates a list, removing all of the duplicate elements of a list such that every element in the output list is both unique and present in the original list. My inelegant code for doing this ...
A few years ago I designed a class which had two properties. The two classes ChildA and ChildB had a rich protocol with many properties and methods, but were only distantly related in my model. They both descend from a class DatabaseEntity, which stores a GUID ID. However, there are several different base classes in ...
I have to make changes in a class which has many members, which are set by a function which implements some algorithm, and then are read by some other function which implements some other algorithm. class Clazz{ private int[] someArray1; private string[] someOtherArray2; . . . . private Dat...
Motivation; I want to report on all the possible problems at once instead of having to peel the onion of every possible problem over and over. It also makes testing much easier because I can have one test for success and one test that handles any/all failures. Much like you do form validation on the client sid...
Assume we have a software module A that implements a function F. Another module B implements the same function as F'. There are a number of ways to get rid of the duplicate code: Let A use F' from B. Let B use F from A. Put F into its own module C and let both A and B use it. All of these options generate additional ...
A frequent pattern in my Haskell code is element-wise recursion for transformation of a list with some carried state generated using the data in the list. Usually, this looks something like this: doSomething :: (SomeA a, SomeB b) => [a] -> [b] doSomething xs = doSomethingWithState xs [] where doSomethingWit...
First of all, I would like to tell you guys to understand my English skill even if it's miserable to read it. I'm really trying to learn English nowadays. - I'm currently developing a web community that might have 2k ~ 3.5k visiting users per day. and the web server is running on top of NodeJS + Express. and I'm using ...
Suppose we have a publicly declared function Result ComputeResult(Foo foo); whose implementation is complex and requires some temporary data structures. I might break the implementation down into steps to improve comprehension: Result ComputeResult(Foo foo) { Result result; std::map<Bar, Baz> bar_to_baz; std::v...
I've been always wondering why the Abstract Factory Pattern is actually called abstract? I don't understand what is abstract about it? It somehow does not fit in the image of abstract classes that I think about when I hear the word abstract so I was looking for it in many articles but guess what... there wasn't anythin...
I often find myself needing to implement a class which is an enumeration/collection of something. Consider for this thread the contrived example of IniFileContent which is an enumeration/collection of lines. The reason this class must exist in my codebase is that I want to avoid business logic being spread all over the...
So, we have a dashboard page where a lot of different values are aggregated and presented. These values are calculated based on roughly 500k data points and presents different index values based on surveys. To calculate a certain index we need to aggregate all data points (these are divided by question number and user ...
So I have a ticket booking system. I have ticket booking request on api, from my application we call payment service. If failed on first attempt we proceed by adding message on queue for handling payment later. And proceed with issuing ticket to customer. From queue we retry payment with payment api 10 times in 10 minu...
Normally we have some code that is common for many (if not all) derived classes. An example would be a generic repository (where I could have a generic Add, Remove, Count, Max, Load etc, or a generic model (example, a common business rule to get a unique value for a new entity based on property type, or a generic save ...
So am in the process of developing a new application and am welling to adopt a micro-services based architecture (am new to that). The problem is that the application will be exposed to the final end-users via a web based GUI (web app) that consumes those micro-services (REST APIs) , so am wondering 'is it worth it t...
I have a scientific code that has a parameters.txt file. This file contains 50+ parameters that have default values associated with them. The user has to change the parameters to fit the particular simulation they want to run. Here is a specific case: there are about 7 options for creating a lattice of sites and assig...
Is it fair to assume that all or most operations in modern software like mouse movements, keyboard events, working with a browser and its controls, playing a game etc. come down to arithmetic/logical operations and data movements? I've come to this conclusion after looking at the Instructions Set of modern processors: ...
I've been reading about how ASP.NET Web API looks up the locations of controllers in assemblies, and ways to dynamically add a new assembly to look in. So far this has all been fine, except I've noticed a few random references to how the controller cache will ignore loading any controller that lives in a dynamic assemb...
I want to build a browser extension that can read/write from the database that is behind my web app. However, I don't really understand how that would work conceptually and what the best practices are? Should/can the extension communicate directly with the database? Is there some layer in between that I'm missing?
I have a Java method with a void type of return that checks a condition. It do something in case of true and other thing in case of false, typical if / else structure, but is possible use only the if block with a empty return in the end and omit the else block placing its contents with one less level of indentation. I ...
Let's say I have Doors that are managed by a DoorService. The DoorService is in charge of opening, closing and locking the doors that are stored on the database. public interface DoorService { void open(Door door) throws DoorLockedException, DoorAlreadyOpenedException; void close(Door door) throws DoorAlreadyC...
We are implementing a system where a user can purchase 'credits' to be spent on two items. I am hoping for suggestions on how to implement such a system. We have two ways of spending credits: ItemA and ItemB. When purchasing credits the user can purchase credits in bulk which reduces the cost of a credit, for example (...
I'm retrieving values from 3 tables in database and trying to make them match. I was wondering how I could manage cache in an elegant way. I can't change the database structure even though one of the tables is absurd. Currently I'm loading my tables from DB into cache, one cache per parameter, and then try to find exi...
I'd want to deploy my Python code and relevant static files such that only a copy of a folder is needed. That is, all the paths inside are relative. The release is to a web server, which calls scripts in a subprocess. Naturally, everything works in my environment in PyCharm. Problems arise when I subprocess Python and ...
In my iOS project I have a set of custom textfields, e.g. for password entry. As an example, such textfields can contain additional views and logic - for example, show or hide a password with a press of a button. Since this logic is not used anywhere outside the textField, I have an idea to create a PasswordTextFieldC...
The application is an API. Users can post data to the API, which is then transformed to a domain object. I am wondering where to apply the domain rules, in the domain object. Let's make it more clear with a real-world example: Users input a calculation, with a Name and a CalculationScript. For ease of use, they are all...
I'm structuring a RBAC in a Web system. My database tables looks like: actions id name resources id name permissions id action_id resource_id roles id name permission_role permission_id role_id users id role_id is_super_admin The roles are dynamics (users can CRUD them) so if I seed "super admin" role it ...
Formal methods can be used to specify, prove and generate code for an application. This is less prone to errors - thus mostly used in safety/critical programs. Why don't we use it more often for everyday programming, or in web applications, etc... ? References : Formal methods B Method Hoare Logic
I asked a similar question to this on SO, but after re-reading it this morning, I realized it wasn't clear what I'm asking. So I narrowed down my problem and realized it was about a pattern instead of a coding problem. I found this question, but it's related to C# and Tasks, but it's along the same lines. Suppose I'm ...
I'm implementing a simple rendering system for a game engine. In my engine I have renderable entities that have a Model component (I'm using inheritance as opposed to a ECS for my engine for now, but encapsulating common behaviour into components will make things easier when/if I want to transistion to a component base...
I got a question in examination asking to draw an Use case diagram using UML 2.5. However I can't figure out what are the changes in UML 2.5 and 2.0 in Use case diagrams.
This is a problem I've faced in many languages over the years (js, go, c, f#, haskell, python, ...), but I haven't found a general approach to solving this yet. Learning about consistency models in databases made me realise all my approaches so far are failing in different ways, usually I end up with a ton of accidenta...
I have a couple of pieces of functionality that are similar but not quite the same. They both involve converting a type that I own to other types that are owned by a third party library, so out of my control. I am relatively inexperienced at using design patterns properly and it is something I am trying to get better a...
Firstly this is not about how to store password for access to the application itself. That is handled using .Net Identity. Authentication is handled using JWT. So it is a web application. The problem is to be able to store and retrieve passwords as safely as possible for the users of the system. One user (a company wit...
Say I have one website created with the LAMP stack and another with the MEAN stack. I want to create a program which estimates the entropy of a password so that I can add a password strength meter to the sign up pages on both sites. I do not want to write the same same program in both PHP and Javasript. What is the bes...
I'm working on a windows service. Code of windows service is very simple but it has a strange manner! In windows service I should call a WebApi each 20 seconds and save the result in a SQL Database I'm using autofac to creat instance of HttpClient at Program.cs // HttpClient builder.Register(ctx => { var httpClien...
I have a complex app on the Javascript/PHP/SQL stack which manages different domain objects. The Javascript layer contains classes which manage the data on the client side. I am currently baking a bunch of data into the page render by PHP, in the data-* attributes, then reading it back into my javascript class hierarch...
I have a requirement to have a component that will check input against some rules in a strict order. The order of the rules is defined by the business. To keep example code simple, I'll try to define an analogy. Let's say business defines order of some int values. You'll be given sequence of int numbers and requirement...
I'm designing a software platform in automation that is responsible of many different tasks like: Core functions Driver interface for machines UDP listener for machine messages from PLC UDP listener for other software components messages (other port) Internal control Web Service used by external components of platform...
I've just joined a project that a developper has been working on solo for 15 years. This is the first time he's had someone collaborate on a project. I've just convinced him we need version control on the project to collaborate effectively as it was entirely unversioned before (manual copies of code versions). I've set...
I'm tasked with investigating the different approaches for multitenancy. Currently I'm expanding my demo application to use the database per tenant approach. Now where I'm getting unsure is that in a single database server application you're able to create multiple database structures with their own schemas and now I'm...
I had a conversation with a colleague about tests. They want to be able to access a db that is only accessed by tests. The db is created in memory and deleted after tests are done. My colleague wants to be able to access the db so that if an unexpected thing happens, they can check the db. I feel that tests should be a...
Working on a DDD application where I need to persist state. Here's a very simple example: public interface IRoot { public int Id { get; } void UpdateValue(int value); } public interface IState { int Id { get; } int CurrentValue { get; } } public class AggregateRoot : IRoot { private State _state; inter...
I'm looking for a clustering algorithm (ideally density based) that allows me to specify the maximum number of clusters (but not the exact number). All points must be assigned to a cluster, so I can't just ignore the smallest/least dense clusters. Can anyone suggest an algorithm that may be suitable for this for this p...
I am trying to understand Big O notation better to be able to reason about it in a much clearer way and therefore, need some feedback on my analysis given below for problem: Merge k-sorted linked lists into one. Claim #1: var merge2Lists = function(list1, list2) { if (!list1) { return list2; ...
I'm porting my JavaFX application to a web based version, which I'm new to. In my web app the user can search the server database for records. At present I've chosen to present the records in a Bootstrap "accordion". Rows contain basic information, and the row contents is populated with a form, which is generated from ...
Let's say an Orders service knows only about the CustomerId from Customer service. When the user places an order, the CustomerId gets transferred from the composite UI along with the OredrDto. The question is: In an event-based microservice environment, how can Order service make sure that the CustomerId is valid and e...
Background: In a project where I work as a developer we did not use a functional specification at first. We relied solely on technical documentation, issues in Jira and mockups/detailed design for accepted views. This worked quite a long time but lead to some problems: Introducing new team members and bringing them ...
I'm working on refactoring an older project of mine to follow the Clean Architecture paradigm (and loving it so far) and one of my components is causing me a bit of confusion in relation to whether or not it should exist as a UseCase. Simple Example For instance, the requirement is there is a contact information screen...
I am often confrontated with helper or util classes in Java or whatever kind of language. So I was asking myself if this is some kind of Anti Pattern and the existence of these kind of classes is just a lack of missings in the design and architecture of a Software. Often these classes are confined using just static me...
The problem I have is this: I have a list of items. Each item has multiple properties. I have a view where I display all items and I have a view where I display the items based on values in properties. Now, I would like to allow the user to sort the items (drag-drop). When users sorts the items in the view that display...
Is there a best practice for something like this? (Example in C++) class A { public: int usefulParameter; std::vector<B*> bContainer; }; class B { public: void needsUsefulParameter(int u); }; Are there any good ways for objects of class B to access fields from class A, even though they ...
When a data structure (for example, a queue) is implemented using an OOP language, some members of the data structure need to be private (for example, the number of items in the queue). A queue can also be implemented in a procedural language using a struct and a set of functions that operate on the struct. However, i...
In conjunction with Unit Tests and Dependency Injection I (and my primary coworker) are exploring Repositories. However we cannot come to a solid plan of action for implementation. In a basic scenario we have a Repository that encapsulates a single context and one or more entities. The public methods of that Repository...
So I'm writing a program that runs quite a few different tests. Which tests are ran varies based on which UI elements are selected by the user. For example, on one form I have 7 radio buttons and 6 check boxes. For each variation, anywhere from 2-5 different tests are ran. The user is able to select any combination (wi...
I am currently researching best practices for data contracts between components in our system. Right now we've stuck to using Word documents and JIRA tickets when the contract changes. The data changes quite frequently (adding new features, deprecating and removing old features, etc..) and several new contracts have to...
Everything is in the title, is the usage of flip function a smell for bad design ? I'm coming from a JavaScript universe and used to work with lodash/fp or ramda. Recently, I've written some stuff where two list of completly different types have to work together to create another list. I've tried to extract some stuff ...
I am new to git and am currently trying to learn as much as I can about it. I think the concept of it is fantastic and extremely valuable to any developer's workflow. I am a data scientist who programs in R, and due to the nature of my work, I work on several projects simultaneously for several people/departments. I fi...
In Doctrine, assuming I want to implement different types of vehicles. Maybe a car, a plane, a bicycle and so on ... all these vehicles have many different properties but also very common things like they are all made of a material. So if i want to get this material ... should i implement a abstract class Vehicle with ...
I'd like to deploy my code to a web server as a package. There Python is subprocessed and scripts are executed. These scripts use data files. But in case a file is needed and it doesn't exist, it should be created. I intend to use pkg_resources for managing those files inside the package, but it comes with limitations....
I'm learning to use the MVC pattern to design my PHP's software. I always use ajax to send requests to my controllers so often I've a code structure like this: <?php if(isset($_POST['action']) && $_POST['action'] == 'something'){ // code goes here } ?> I've readed various articles about the MVC pattern and all seems t...
We use spring 4.3 and spring boot version 1.5 in our java based web application. For (product) analytics purposes we want to read the metadata of our product which is persisted in an RDBMS store (Oracle). Our application uses spring framework to define services that access the database through hibernate (jpa). These se...
I have quite simple class hierarchy: public class Base { //... public virtual void AssignFrom(Base baseObj) { //DoSomeStuff } } public class DerivedA : Base { //... public override void AssignFrom(Base derivedObj) //Wish Method would be: //public override void AssignFrom(Deriv...
When writing a switch statement that only ever has to deal with a known set of values (imagine an implicit enumeration), I find myself wondering what should be the last entry in the construct. I'm always considering the same 3 approaches, but I'd really like to just stick with the one that makes the most sense and neve...
My team is going to be using Visual Studio Team Services for an upcoming project. The Agile tools let me organize User Stories and Tasks hierarchically like this: Epic > Feature > User Story > Task/Bug Let's say that I am designing a Student Org (club) management system for high school students and advisers. Students ...
Is there a reason why Python developers (both maintainers of Python itself and authors of modules) tend to pass special strings as arguments to functions instead of defining symbols for the same purpose? Rather than make other developers look up or guess the special values allowed for some arguments, why not define sy...
Along the lines of How to Simulate Control-Flow without using Control-Flow Primitives, I am wondering how to simulate return from a function. Given an example setup like this: console.log(a(10)) function a(a) { var x = b(a) var y = c(a) return x + y } function b(a) { return a * 2 } function c(a) { return a...
I am wondering about how range queries work, and the standard solution is to use B+trees. However, I am a fan of tries as a general data structure and would like to know if they (or variations of them) can do all the things B+trees can do. That is, if they can support fast range/between queries on-par with B+trees, and...
I know that JavaScript doesn't explicitly allow you to have a member variable of an object as private, but you can do that implicitly by using closures. But is there an object-oriented language that doesn't allow you to have private member variables at all (not explicitly and not implicitly)?
I have known about the Flynn taxonomy for a while (SIMD, MIMD, etc.), as well as models of concurrency (actor model, petri nets, etc.). However I am wondering now how they overlap and interrelate. If some of the concurrency models can be encapsulated in some of the Flynn taxonomy models somehow, or vice versa.
From what I can remember the Control-Flow Graphs for which I have seen images have mostly been of single functions. So basically just statements with perhaps looping. But I am wondering what a control-flow graph would look like for a function, which may reference nested functions, which may reference other nested funct...