instruction
stringlengths
34
36.1k
I am trying to list the times in which it is useful to run some code in a separate process. Does the following short list cover it? Speed: the obvious one. Multiprocess/distributed parallism Worker process, vs GUI process for responsiveness of UI etc Security: No shared-memory space decreases attack vectors Part of...
If there's a large contribution to a library X licensed under Apache v2.0 from user A and user A decides to create a "friendly" fork of the contributions he/she made in library X to a new library Y licensed under MIT license. Both Apache v2.0 and MIT are commerical permissive license. But would that be legally okay? ...
I am working in a php project, and our 3rd party dependencies are managed with packagist via composer.json. Pretty standard stuff. Sometimes we run into a situation where a given plugin has some issue, such that we would like to continue to use the plugin but the issue makes it a liability or just straight up unusable....
I'm trying to implement parts of the ASME BPVC's design rules. It's a very, very old code that has been grown over a hundred years or so. As such, it covers lots of different load cases, lots of different component configurations, and has different paths depending on the presence of certain design criteria. Most things...
I have posted the same question to StackOverflow and Stackexchange and both got downvoted to oblivion as "too broad". So maybe this will be a better place for it. I am working on a rendering engine with my own C# bindings for OpenGL and I have a couple of questions when it comes to OpenGL's constructs and OOP concepts....
I need help with an abstract factory pattern design.I have and calculation engine which calculates for different channels like captive, captiveTemplate or Headquarter and in the future different channel can be added. Attached is the drawing on how I am setting up the pattern: The problem is some items are calculated ...
For example, I have managers who are responsible for contracts. These contracts belong to a department. So what I have done is this: manager(1) belongs to a department(1) department(1) contains contracts(0..*) In this situation, is it necessary to also include the following relation: manager(1) manipulates contracts(0....
What would be considered better, cleaner code from the following options? The code basically sends a file through a Socket using an OutputStream that encrypts it. The code does not look that basic when read but it does not need to be understood at a technical level, this is not the point of the question. The comments t...
I'm developing a software library that I began during my PhD and used in my thesis. I've since started a research position and, as an experiment, I wanted to try rewriting parts to see if I could simplify it. This turned out to be way more successful than I expected. I rewrote years of work in a matter of weeks, and th...
I have these two little programs: C #include <stdio.h> int main() { if (5) { printf("true\n"); } else { printf("false\n"); } return 0; } Java class type_system { public static void main(String args[]) { if (5) { System.out.println("true"); } else ...
I would like to know if there are best practices for this situation: a website with its source code in version control (e.g. git). code makes references to specific assets like images, that can't be included in version control due to their size. How to have in sync the code and images but keeping them outside the git...
I was faced with this question recently for the different types of heap memory available in Java. I couldn't find much information online. Are there different types of heap memory available in Java ?
On my first programming courses I was told I should use a set whenever I need to do things like remove duplicates of something. E.g.: to remove all duplicates from a vector, iterate through said vector and add each element to a set, then you're left with unique occurrences. However, I could also do that by adding each ...
Behavior-Driven Development (BDD) can be described as in this blog post as follows: Behaviour-driven development (BDD) takes the position that you can turn an idea for a requirement into implemented, tested, production-ready code simply and effectively, as long as the requirement is specific enough that everyone knows...
I want to draw a DFD to show data in a multi server (about 10 servers) process, how the data files are passed around between servers, including schedule. I googled and got a DFD style named "Gane and Sarson" but "datastore" in this concept does not represent servers well. ( http://dia-installer.de/shapes/Gane_and_Sarso...
I'm training the new iOS developer who will replace me. However, the majority of views in the project is created with code (using a library to make Autolayout more concise). There is no storyboard in the project and the process of starting the app is also in code (AppDelegate). This makes the handover more troublesome ...
Today I saw something like this: ... public class SomeClass { public static final int A_CONSTANT = SomeOtherClass.ANOTHER_CONSTANT; ... Does this make sense? What is it good for? I wouldn't do it but I am just wondering since I didn't find anything about it
I fail to infer the exact point of historical introduction of STL into actual C++ standard library from the wikipedia article: https://en.wikipedia.org/wiki/Standard_Template_Library It appears to me that C++11 was somehow significant for this STL, as it was becoming a part of C++ Standard Library. But I find another p...
I'd like to ask about the history of programming languages - specifically, the role of hardware in language development over the past 20-30 years. I have been reading about the history of Python, and the ABC project. It seems to me that there were lots of lessons learned about language structure, abstraction to a more ...
Given array of integers I am trying to design the fastest algorithm that swaps the elements such that at the end : all negative elements are on the left and then the positive elements, for example, final output might me [-5,-1,-3,10,11,2], Of course, direct sorting with n*lgn gives the desired answer but I am looking f...
I want to create an Android application with cloud-based functionality. It would entail a (rather simple) loyalty program for consumers and retailers; so, just managing user accounts and some associated data such as collected points. My question: is it feasible to base it on some ready-made solution such as Amazon AWS ...
When it comes to laying out tables in transact SQL databases, like SQL-Server and Sybase, the classic approach to relational modelling is well established. (The authority being Halpin's book) Establish your use cases Establish your entities Determine the attributes of the entities Determine the relationship between th...
Suppose we have a sorted array of unique elements, A[n]. I am trying to find the lower bound for finding a specific element x in the array. I suspect the lower bound to be log_2(n+1). I tried to use a decision tree to solve this, and indeed we know between 2 elements which is greater, which gives 2 for the base of loga...
When providing a "credits" page or similar licensing information page listing any libraries distributed with your project, should you include builds tools such as Babel and Webpack?
I have a portfolio website and i'm planning on allowing comments as a sort of "guestbook" feature. What are some things i should consider before starting? I don't want to get screwed over by a malicious user. Here's some of my thoughts Comment needs to be approved before appearing on the website Insert comment onto w...
Consider the following (python) code x = [1, 2, 3, 4] y = 2 + 3 z = x[0] + y Here, I can substitute the expressions for x and y verbatim in the expression for z, possibly by surrounding then in some grouping syntax: y = [1, 2, 3, 4][0] + (2 + 3) Not all languages have this feature. Consider the following equivalent ...
What should we do for user stories for technical debt in Pivotal Tracker? Should we consider these as features (giving points) or as chores (giving no points, thus lowering velocity)? I am confused what should be considered as a chore: Duplication of Code - It's clear that if we have put same code in multiple places, ...
We are beginning development of an Angular 2 application. Our back-end will be using ASP.NET Core WebAPI. Although my subject calls out authentication, this also applies to any API service that is-but-kinda-isn't required for the client-side app to function. Specifically, authentication, logging, etc. Right now we ha...
PEP-8 clearly states which parts of your code should have documentation: Write docstrings for all public modules, functions, classes, and methods. Docstrings are not necessary for non-public methods, but you should have a comment that describes what the method does. This comment should appear after the def line. (em...
Recently I've received the following requirement which is being quite hard to implement. The system is a Windows Forms financial system and the requirement is as follows: When the system is opened in the last day of the month, it should ask whether or not an admin user wants to generate the next months billets. It tu...
Suppose I have low level classes A, B, and C that are independent of each other. The functions in them take some input and does some computation and returns some output. Now suppose I want to create an executable where it read in some data and output some statistics with the flow of input->A.func1->B.func1->C.func1->o...
So I wrote a system for my job and now I want to write it from scratch so that I have my own copyrighted version in addition to what I've done for my boss, which does not belong to me of course (pay for hire). The problem is it is very hard not to follow the logic/algo flow from some parts of the code. Some methods wil...
I told my boss that for our next application, we will be creating rest services that follows the microservices architecture. The design I had was somewhat like this: all functions related to users - 1 rest service all functions related to payment - 1 rest service all functions related to audit log - 1 rest service all ...
Which structure of writing code is better and why? if (!file_exists('file.txt')) { throw new Exception(); } else { //operations } or if (!file_exists('file.txt')) { throw new Exception(); } //operations ? I did not find this in PSR documentation.
I tried to find an approach to implement form builder plugin but I still not getting any idea how to execute it. I don't get below things. How can I add dynamic controls to dynamic form with drag and drop functionality. (i.e using jquery or any web form control) How to store or manage dynamically created form.(database...
I have my multi module maven project with the following structure: + parent - pom.xml + model - persistents - dao - model stuff... - pom.xml + service - services - services stuff... - pom.xml + utils - exceptions - pom.xml In utils module I have some custom exceptions. The point is tha...
I am building a personal app to store my notes in. It is not a new concept, of course, but it is giving me a great project to learn Node.JS together with trying out a graph database: Neo4j. What I am having issues with, is coming up with a good data model for my app. Requirements: A note contains content in the form o...
C# 7 has a nice new language feature: The Deconstructor. It is possible to use it for value tuples for instance. However, I can also create my own deconstructors for my own classes. Why would I do that? My classes have properties. So individual items can be accessed anyway.
Say we have 4 services, A through D, which communicate (for the most part) through some sort of asynchronous event-driven system. When a new entity is created in A, B & C receive that event. B creates an entity of its own based on that event, and C makes a synchronous call to D to perform an action. Finally D receives ...
I am writing a repository class with entity framework. One of the method is an update method, which simply updates an entity. The controller does not need the entity. However, from a testing perspective, it may be useful to just return the entity. Than I easily have something to assert. It may be even more useful to re...
I have this URL: /api/pallets/list Which returns a JSON array that looks like this: [{ palletId: 333, code: 'J050000081', grower: { growerId: 35, name: 'Grower Of Blueberries Inc' }, species: { speciesId: 1, name: 'Blueberries' }, caliber: { ...
I'm embedded engineer, and one of my field of work is building embedded systems based on STM32 microcontrollers. ST provides its own HAL with names of functions like HAL_Delay(), HAL_UART_Receive() etc. They use two-space indentation, all brackets on new line and other ST-specific codestyle features. Also, it is very ...
The absence of a datum in XML can be expressed either by omitting the element (minOccurs="0" in schema) or by setting it to xsi:nil="true" (nillable=true in schema). Using minOccurs=0 seem altogether cleaner and more consistent, and it doesn't require the XML to reference the XSD namespace. So what is the benefit of n...
I am working in a project we we use DDD and now we want to implement localisation for some fields. Example: <?php class Product { private $id; private $name; public function __construct($id, $name) { $this->id = $id; $this->name = $name; } } I have a service to create this pro...
Is it considered an anti pattern to hardcode SQL into an application like this: public List<int> getPersonIDs() { List<int> listPersonIDs = new List<int>(); using (SqlConnection connection = new SqlConnection( ConfigurationManager.ConnectionStrings["Connection"].ConnectionString)) using (SqlComm...
In Object Oriented Programming, since we use classes and methods in these classes, when we are going to implement a certain functionality we must decide where it belongs, in other words, on which class it belongs. This raises questions like: "should I create a new class and add this there" or "should I add this to one ...
What is the curve below called (if it has a name)? What can you generally infer from such a curve? The line with negative slope is the number of remaining test cases and the line with positive slope is the number of bugs.
I'm working on a project in which we are incrementally replacing an existing application. By incrementally I mean some features will be developed and shipped in the new application, and those features will be "deprecated" in the old application, but still available. The deprecated features will then be removed from the...
Context: I'm going to use the board game Sorry as an example, but this question could apply to other board games. In Sorry, each player has four pawns. Based on drawn cards, a player moves their pawns around the board. These moves can impact other players' pawns, like bumping another player's pawn back to Start. For a...
I am trying to write documentation for a project and I have trouble finding information about list of documents that need to be written. I know there are Vision and Scope, User Requirements, Functional Requirements etc., but I haven't been able to find concrete description about which documents should be written and in...
I need to call third party APIs where the payload size has a maximum size limit, say, 4 MB. That means I cannot call the API with a payload more than 4MB in size. How can I solve this in an algorithmic way? Because a simple solution could be like every time I generate a payload, I check the size, and if it exceeds, I c...
I worry that I'm too concerned with code smells. I've spent the last two days procrastinating over implementation details and how I would actively refuse using the approach suggested. We have a scenario where we "pull" orders and each order can be "deleted", "re-created" or "ignored" Tech lead suggested having one data...
In a question on stackoverflow the answer I received was basically "It happens if you replace a .dll file in an already built application". That seems very dirty to me. I understand the need for marketing changes like renaming the executable and things like that, but here we are talking about changing the functionality...
I have a collection of Python objects, lets call them fruits. Some of these fruits might be faulty. To check for these faults, I have a number of functions that performs different checks, and returns a list of fruits that did not pass the check: def not_delicious(fruits, limit): return fruit for fruit in fruits if ...
We are trying get our CI/CD up and running and I was after some feedback on it. We are using VSTS and building c# api + JavaScript applications. We want to use VSTS build and Release management. The release management uses the idea of 'promotion' of the same build through the various environments. Our process We tend...
Is it a good idea to use the same naming nomenclature (e.g. camelCase) for both front end (eg. Javascipt) and backend (eg. php) ?
Recently, we have learned about UML class diagrams in university and I began applying that knowledge to my work projects. However, I am still unsure how or where I am supposed to describe the functionality that a method of a class offers. In code, I would simply put a docblock above a method in which I describe that m...
For junit tests where I am just testing if something works correctly, should I use assert(true)? Since it is legacy code, it is difficult to get a good assert statement.
Github uses the convention "/user" (singular) to interact with the logged-in user's info. They still have the full "/users" suite of paths to support getting info based on IDs (or usernames in their case), but the singular resource took me by surprise. Is this common/accepted/desired across the web, or is this just a ...
I’m a little unclear on some questions relating to the "intent" part of concurrent collaboration algorithms (operational transformation and conflict-free replicated data types). Please help! Strings are a frequently used example in OT explanations. Usually, you see something like "abd" * ins('c', 2) * del(1) ≠ "abd" *...
In our software, we have a windows service that performs all our background processing from sending scheduled SMS to performing backups, (maybe 10 different functions). I am questioning as to what other people's experiences are in regards to windows services, is it better to have a single service for a single function...
We are working with a performance metric that all API requests should respond within 50ms when running locally. I am taking this from the average response time of Githubs API. I have an object called Foo. A single Foo might contain 6KB of text when serialized as json. Foo has a sub object which makes up about 3KB call...
In android, some codes, such as updating UI buttons, needs to be called in UI thread, however, before UI update, some task, such as getting response from internet, need to be done on another thread, here is the most common form of response callback I see: public void httpResponseCallback(String responseString){ MyF...
I have to do a program to school in Assembler but we did just a few basic things. Is it possible to write code in Java and convert it to Assembler?
I am in the process of refactoring a large application originally written in .NET 2.0, running on an old version of Microsoft's Compact Framework. The idea is to refactor and rewrite the code so that it in the future will run on Windows 10 IoT. So far this is going pretty well. However, the program should also ideally ...
I have released API 1.0.0 in the master branch (default branch). Since then I have separately branched to branches api2/foo and api2/bar, both containing backwards-incompatible changes. The API version is declared in the source code. Should I bump the version to 2.0.0 in both api2/* branches, or in the master branch? I...
Context: We're having a ton of super heated debates around the office. I'm just a neutral observer, as this is my first month at my current employer. Previously I haven't ventured outside of the Bootstrap waters... but it has got me thinking. Is doing this weird/bad/a code smell/etc... Currently we seem to have a lot o...
My team is currently trying to design an authorization system that can be used in any language (Think authorization as a service). One thing i'm trying to figure out is if there is a good way to write authorization checks without littering them all over my code. Is there any way to actual do this in practice? For examp...
I read in this article about microservice architecture by M. Fowler: Another consequence of using services as components is a more explicit component interface. Most languages do not have a good mechanism for defining an explicit Published Interface. Often it's only documentation and discipline that prevents cli...
I am learning software design by building a CRUD web application (ASP.NET MVC with Entity Framework). I split it into two projects: first is Core library, that contains business logic, second is Web GUI. I got an idea, that separated Core library can be used elsewhere (for example desktop application) or GUI can be com...
Say I have a Service Layer method like this: public void TestMethod() { DomainObject domainObject = new DomainObject(); domainObject.TestMethod(); } TestMethod looks like this in the Domain Layer: public void TestMethod() { TestMethod1(); TestMethod2(); TestMethod3(); } Is it bad practice to Unit Test ...
We are planning on using OAuth2 / OpenID-connect for Authentication & Authorization and I'm looking at what services would be required. So far I've identified that I need at a minimum: An OpenID-connect authorization service, e.g. implemented using Identity Server Service(s) for registering and managing users Service(...
I have the following interface in my business layer public interface IUserService { void CreateUser(User user); List<User> FindUsersByName(string searchedString); User GetUserById(int userId); User GetUserByCredentials(string login, string password); void UpdateUser(User...
A lot of ISAs including x86, x64, ARM, Itanium, have a pop instruction that requires an operand which is usually a register (or, in ARM's case, a register list). In fact, I can't think of an ISA off the top of my head where the pop instruction doesn't require an operand (other than stack-machines for bytecode like the...
I'm designing a C# bot using the Microsoft Bot Framework. I'd like the bot to be easily extensible, allowing developers to add dialogs/responses while making code changes in as few places as possible. From my own experiments and looking at the examples in Microsoft's BotBuilder repo, it seems like adding a new dialog/r...
With the creation of Temporal Tables in SQL Server 2016 (or similar technologies in other databases), would you consider Event Sourcing unnecessary? Both are audit techniques, very similar (one deals with entities, the other with specialized DTOs), but Temporal tables are far easier to implement as they are ready right...
There is an application that processes TCP/IP requests according to some logic, and pretty always it connects to DB. Architecture is very common: one client -> one processing thread -> one DB connection -> one DB thread to process a query(DB thread exists inside DBMS application and mentioned here to show how insuffici...
How to calculate C(n, r) modulo m, m is of the form p^a, where p is prime. Here C(n, r) means n choose r. The range of n and r is large (of the order of 10^18) so it cannot be solved by calculating the power of primes. Also m is less than 10^6. I tried reading the generalization of Lucas Theorem, but could not underst...
I would like to make a semi-automatic OCR software for offline handwritten documents, where the OCR tries to recognize the words and the user has the ability to correct the fails of the recognizer by defining the misrecognized characters. I found a similar issue but doesn't really answered my question: https://stackove...
Problem: 3000 business objects, each with some regular data (~20-30 shallow fields, JSON) and its own unique small behavior (often just a one-line javascript function). Possible solutions on my mind: Solution 0: business_objects.js (~1 MB) data and functions on same object. Solution 1: data.json (~800KB) + only_behavi...
Academic task… First we were told to generate a set of static .html files showing election results in various administrative divisions. Then we were told to "modernize" this by using Django templates. Fair enough, I can see the benefits of such approach. But then we were told to further "mordernize" this by making the ...
What is the best way to provide a web application in multiple languages? The focus of my question is not what to think about, but indeed how to do it. The text in the web application: text in the popup of spatial features text in the sidebar containing the feature's description text elements of the website components:...
Recently lots of people adopted DI in their projects (I am working with aspnet core). The problem I have is that DI turns my code towards procedural paradigm. For example in OOP way I would do: class Something { Something(Other object, Dependency dep); // created manually or by factory obj DoStuff(); } Howeve...
What is a good way of setting up a "shared index" of file metadata, when there can be no shared process such as a database server? I'll explain the scenario: A server contains M (say 10000) large files (say e.g. image files). each file is in a unique subdirectory with guid name. The root directory is shared as windows ...
Are there best practices for method summaries? I'm a bit confused as to what belongs in the parameter and returns description when both are objects. Here is an example of a method I am summarizing: public class DocumentRequestObject { public List<UserIds> UserIds { get; set; } // User Ids being searched for do...
I'll preface this with a few classes that shows what I'm trying to do interface IDataField { /* ... */ } class DataFieldImplementationA : IDataField { /* ... */ } class DataFieldImplementationB : IDataField { /* ... */ } interface IData { IDataField Field { get; } } class DataImplementationA : IData { publi...
Example 1 (used at the moment) If (BodyPart["Right Leg"].BodyStatusEffects["Active"].Active) { BodyPart["Right Leg"].BodyStatusImpacts["Poisoned"].Active = false; BodyPart["Torso"].BodyStatusImpacts["Poisoned"] = BodyPart["Right Leg"].BodyStatusImpacts["Poisoned"]; BodyPart["Right Foot"].BodyStat...
This is a question regarding how Multiple Dispatch works. Suppose that we have a type hierarchy like this: Drawable -> Shape -> Polygon -> Rectangle And there are three functions (This is a pseudo-code): void func(Rectangle*, Drawable*, Drawable*) ... void func(Rectangle*, Rectangle*, Drawable*) ... void func(Polygon...
I have a Data Access Layer that uses a json API. If the structure of the program looks like: Controller | Data Access Layer Is it best to convert the response strings into objects in the Data Access Layer and return them as types to the Controller OR Should I be returning strings back to the Controller, ...
Disclaimer: I am asking this question with regard to a school project. The purpose of the project is hands-on learning and simulation of a real-world software development project. I am fully aware that I don't properly understand what I am doing; and I am not putting anyone at risk in the case of designing a very flawe...
I have a class similar to ServletFilter which has multiple validation on the input request class TokenHandler implements SomeHandler{ Response handle(Request request){ if(paramXMissing(request)){ return new Response(); // empty response } if(paramYGreaterThan100(Request request)){ return new...
I have the following situation. I'm writing a c++ program where I have a function that checks a custom equivalence of two json objects. If the check fails, I don't want the entire program to stop (its a QT gui program), and I have a branch that executes upon receiving an exception. This exception is then passed up t...
I am learning unit testing on the job, at a new job. The testing team is small, (1 other), and all of the tests are written in the following fashion. class TestClass(unittest.TestCase): def testFunction(self): #Test - 1 #Assign #Act #Assert #Test - 2 #Assign ...
Our Web API app is C#/MS-SQL and our DBAs want us to use two databases, one Writable, one Read-only. The database for writes will replicate to the read-only copy. This question may apply to other languages as well. The reason for this (from the DBAs) was so performance would not be impacted if/when tables are locked d...
I'm attempting to develop an open-source Python module for modeling task networks for discrete event simulation. The most fundamental component is the task object, which includes various data such as a distribution of possible task duration times, a release condition (criteria for initiating the task), a beginning effe...
With all the github services available nowadays, it has become quite easy to have automated unit tests for e.g. C++ or Python coding projects. Together with colleagues I have written a basic install script for Arch Linux in Python that I would like to test automatically instead of manually creating a VM, letting the in...
I develop mobile apps, now im working on a very big project building a tool for the employees to be heavily used. Now the app is on development mode, and testing with few users, but will need to be scalable and have a fast response. So the question is about the way the thing is being constructed, how it updates the inf...
I'm working on a project for my College and I'm stuck on this problem in my design. Right now I have something like: public abstract class AbstractClass { protected SomeClass attributeOne; protected SomeClass2 attributeTwo; public SomeClass getAttributeOne() { // code } public SomeClass2 getAttributeTw...
I am not sure which stackexchange website is correct website to post this question. I haven't worked on payment process before - and I need help with payment process using Stripe - we are developing a website in which we will be selling items from different businesses. Now the flow of the Application is like this: C...
I'm starting to learn about reactive web applications, and I pretty much get the hang of the whole components, virtual DOM, states and more. First of all, I usually don't name a technology, but for the sake of simplicity I'll use ReactJS as the example, but I'm sure the concepts also applies for other libraries/framewo...