instruction
stringlengths
34
36.1k
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...
I've noticed that text editors and such have a more-than-prefix/suffix-based pattern matching algorithm going on behind the scenes. And StackOverflow's tag matching algorithm does more than just prefix/suffix matching: I am wondering what (one of the possibly many sorts) of data structures are required to implement th...
I've developed a java web app using Vaadin, and using Jelastic/MassiveGrid as the PAAS. However, I need advice on proper architecture for my needs. Desired Outcome: Users land on my homepage where they can read about the app's features, pricing, view the contact page, etc. If they want to login, they click "Login" i...
I develop an application using WinForms/C#. In my software I have a List of objects, let's say List<Item> Items. There is also another List of objects, let's say List<Factor> Factors. Every Item contains multiple Output Factors (information you can extract from the Item). Also, every Item contains multiple Input Fac...
Back story: I work for a startup which was acquired by a large Fortune 500 company. I'm the lead engineer on a project which aims to consolidate duplicate data stored by both companies. Our new corporate overlords have a mature RESTful API (written in Java) exposing all their data which happens to live in a Oracle DB u...
I'm currently building a web application for my enterprise level business internship. This web application will track data from three different sources: a DB2 database, a SQL Dynamic database, and an existing API, and then marry them together. I'm currently working on the SQL Dynamic side, and I was advised to use Enti...
This should be a simple MVVM - reactive architecture question, something that I miss probably. I'll start with a context example: I have a Music Tracks Player application with 2 models Player and Track. The relation between player and track is pretty obvious: the player contains tracks (multiple track can be played si...
I'm not a native English speaker, and i'm new to .net Core. I have a task to port the logic of a WPF app to .Net Core while leaving this app working like previously. The app has approximately 70 Visual Studio assemblies: Say, 40 of them are related to logic and must become cross-platform. Say, about 20 of the logic-re...
So with Model Checking you have a specification and the model checker automatically goes through your program's states and checks if it matches the specification. What I don't understand is where testing fits it. So typically it is described that if Model Checking finds an error, it will generate a test case to demonst...
Let's say that I want to contribute to thislib, which is a Python library that is available as a Git repository. Several applications, such as thislib_app utilize this library, and I want to contribute to the thislib and see how my optimizations work out for thislib_app (we can say that thislib_app is like one big unit...
I wasn't sure if here or SO was the right place to ask this, but here goes anyway. So I want to improve a system that is currently running. It has services and many stand alone apps, but none of these things are properly coordinated. Now I want to build a mini app to prove the improvements to the system should we build...
In C#, what is the difference between Automatic serialization and Customer Serialization? Also what is Reflection? I know this stuff is not simple, if someone can explain in lay man's term, that would be great. I am beginner in all this.
I don't have much experience working with OOP, so I'm trying to understand what is the feature (or features) that would give you a great motive not to write some program in a procedural language, but rather write it in an OOP language instead. I have thought of the following features of OOP and their impact: Doing obj...
I want to have an array that can hold elements of many classes data types, and each of these classes have a method called printInfo(). The way I can do that is by having a parent class called SomeParentClass that have a virtual method called printInfo(), and then I would make the classes data types that can be present ...
I have a situation where I need to model objects that don't share common attributes but represent same logical entity. Now, based on their type they will have different attributes (properties). To keep an example code simple & easy to understand, let's say we have Valid & Invalidvalidation results. When validation resu...
On one hand, the invariants should be protected (To make invalid states impossible early and preferably at compile time rather than run time), and on the other hand, passing domain knowledge out of the domain is wrong. On one hand, the value objects protect our domain invariants at first place, on the other hand using ...
I have heard some developers say they prefer to build their UIs in code behind... I am of the opinion that this leads them to write really bad code... Super large functions, spaghetti code, and mixed responsibilities of functions instead of pure functions. I think it's better to build your UIs in your platforms specifi...
I was reading about "Referential Transparency" that says how to program thinking about purity and determinism. It's said that a function that modifies an outside state is unpure. But what about a function that only read an outside state (such as reading a global variable), is it unpure too?
I'd like an immutable class, or rather a class whose properties are initialised (whether they have public/private setters or not), in the constructor: public class MyClass { public string MyString { get; } public MyClass(string myString) { MyString = myString; } } Nice and simple, works fine. ...
We are currently rewriting our infrastructure from a monolith to a distributed system because the old system didn`t fit the workload anymore. In one part of our distributed system, we have an Entity (from a database perspective) that has N ... events associated. We have a service S that handles access to all Ns and the...