instruction
stringlengths
34
36.1k
Pull requests are a great feature of modern vcs hosting. They provide a consolidated view of everything that's happened within a branch's development, including a master diff of the composite change, and all the discussion that's taken place. My question is this: Is there any downside to issuing a pull request immediat...
There are various metrics like "test case effectiveness", that is calculated as (Total number of bugs found / Total number of test cases executed). While this produces some numbers in the beginning, when run on a mature product, usually no bugs are found. But then I would get 0/100 = 0% and it does not make sense to re...
I am studying SDLC models from a book. While attempting the exercise questions, I found these questions: What is the best choice among process models to address tight schedules and cost of the software precisely? What should be the best choice among different process models for development of any general software, suc...
The problem You're given an n number. Check if that n number can be splitted in half so that both sides of a | are prime numbers. Example: Input Output 223 2|23 123 Not possible to split. My Idea I was given an example of n number that has only three digits, and in that case it would be easy to finish the task, bu...
Original Class class HomeController { function __construct() { $this->setPhpRenderer('Module'); $this->repository = new HomeRepository($id); $this->proposalService = new ProposalService($this->repository); $this->quickAdd = new QuickAdd($this->repository); } } /* * Instanti...
I am developing a mobile application back-end service using Laravel 5.3. I am following REST API. Application having payment gateway integration and it needs more security. I followed JWT auth by using the tymon/jwt-auth library for laravel. I have few concerns: my token getting expired after 1 hour, after that server...
So recently, I had a client ask me to restructure his Database hierarchy which consisted mainly of changing table names and column names and creating cross-references to stop red locks. He later emailed me about his 'program' no longer functioning: which the reason was simple, he hadn't updated the queries in his progr...
This is language agnostic. I want to develop a simple custom assertion class using test driven development. The class will have an assert method called assertCarIsNotDamaged which will check if a person's car has no damage. It will check a hash map of car parts and their desired status with the status of the parts of ...
So my exact case is that I have ~1400 domains on an ancient, self-hosted bind server and I'm looking to migrate them to a hosted service. The trouble is that the hosted service's API has a rate limit of 150 requests per 300 seconds and each domain will require at least 3 requests to migrate. [Note: This API does not pr...
I am trying to understand how interpreter pattern can actually be implemented. As per the diagram; an expression has 2 nodes: terminal & non-terminal. Can it have multiple type of nodes as well? Because I believe it is drawn considering the math expression transformed in binary tree DS where leaf nodes are number and...
This is probably a dumb question, but how do programming languages work on a low level? If you go to the Go language GitHub page here, it says almost 90% of the source files are Go files. How is it possible that a programming language is made up of itself, especially 90% of itself? I can kind of understand how a langua...
I serve static content from Tomcat. Someone suggested moving the static content to a web server in order to optimize performance. How are web servers designed that makes them better at delivering static content?
I am reading Real-Time UML Workshop for Embedded Systems and I do not understand what they are saying here. I have bolded the parts of the text that I do not fully understand. I am trying to understand this from a C stand point of view. An interface is a named collection of services. Services come in two basic flavo...
Google Maps API lets one use polygons to create shapes on a map. What I wish to do is nest these polygons, and use them to describe data which can then be used for navigation. Let's say that the data is population density. A series of nested polygons would surround a major city, each one with a value. The most densely ...
I'm writing a boolean that will toggle between these two forms for writing markup into my strings, but I do not know what I should name my boolean. bool setMarkupForm(bool markupForm); Is not obvious enough to me to tell me what it is doing. What terms are used to differentiate between: <element></element> and <elem...
BEFORE: I have an interface that has one method definition public interface IDockable { void Dock(DockerContainerConfig config); } Everything is ok for my first implementation public class DockerContainer : IDockable { public void Dock(DockerContainerConfig config) { } } public class DockerContainer...
I am looking over Simula language to see how it compares to C++/Smalltalk, and I have two questions that are difficult to find answers to because each time I type in Simula into Google, it gets replaced by "C", "Python", or "Simulation". Was Simula case sensitive? What file extension was used for Simula programs?
We are building a Microservice architecture for our projects, with mostly front-end Symfony applications interacting with back-end RESTful APIs. The problem is this approach is breaking the Symfony entity management relying heavily on Doctrine with database. Where Symfony usually handle entities with Doctrine, automati...
Recently, one of my colleagues stated that the cache should always be required dependency. We should require it in non-null constructor parameter. And we can't use null-object pattern with it. How to bring over this point of view? What do you suggest? How do you inject cache in your technologies? update1: By cache I me...
I have been asked to document coding standards for javascript at my organization level. Does maintaining coding standards at my organization level sound worth enough? kind of old timers? with the way, how javascript evolving with frameworks like AngularJS, should we just refer the industry standard instead of keeping t...
I want to model some mathematical structures. For this purpose I want to define an interface, an abstract class for general purpose algorithms and concrete implementations of that class (I have three in mind). Now the situation arises that the general purpose algorithms that do not depend on the details of the datastru...
I am currently planning a monitoring server for a distributed system. In a file (or maybe a database, someday) I save all the servers and parameters that I want to monitor. When the monitoring system starts, I parse that configuration file and store the content in a Configuration class (see source code below). In order...
Anonymous function expressions in JS bug me as they make stack traces and Chrome Dev Tools profiler output harder to use, so I've decided to name ALL my function expressions from here on in. The obvious thing seems to be to name them the same as the name I am assigning them to, e.g. this.myFunc = function myFunc() {}; ...
This code golf question got me thinking. I wasn't even aware that the Cashier's Algorithm was a formal thing. Reading it, and Googling around, I see that all solutions seem to concern themselves with paying out the fewest number of coins. I wondered if vending machines operate exactly that way, or if they think “uh, o...
I don't know whether to call the data dynamic or inconsistent. But I need to create profile pages for people generated from xml or json. The challenge is in the data the is returned. The data is bibliographical data about a person, and the APIs that are returning it are old, 11 years old. They need revisiting. the data...
For storing sparse matrices I know there are multiple formats that are common, like COO, CSR, DIA, ELL, HYB, etc. (Link to some storage formats), but I haven't found that any of these stores the number of nonzeros per row. I am considering creating a sparse matrix storing format similar to CSR except that instead of ro...
I am currently in the process of putting together a matching algorithm. The matching process is as follows: Query data is used to perform a "lookup" on a set of reference data in order to determine an applicable id which is then later used in a sales order When the lookup data is queried, quite often more than one res...
Background I am designing a language, as a side project. I have a working assembler, static analyser, and virtual machine for it. Since I can already compile and run non-trivial programs using the infrastructure I've built I thought about giving a presentation at my university. During my talk I mentioned that the VM pr...
I've been thinking about the Traveling Salesman Problem. In examining it and grids of cities, I noticed that I could frequently pick out the shortest route just by staring at it. Granted, I couldn't necessarily get the solutions for the complex grids, but if I could get the simple ones there had to be a way to consiste...
How can my program best represent a translation between imperfectly-matched data structures? I am tasked with a one-way translation of data from one system to another. Both systems are established, I don't have the option of changing their data structures. If the structures corresponded item-for-item, it would be simpl...
I can't figure out why microprocessor systems implement unsigned numbers. I guess the cost is just double the number of conditional branches, since greater than, less than, .etc, need a different algorithm than signed, still are there any algorithms that unsigned numbers are a significant advantage for? my question par...
The offical Scrum Guide states that The Product Backlog is an ordered list of everything that might be needed in the product and is the single source of requirements for any changes to be made to the product. Does this mean that the Product Backlog also contains requirements that have already been successfully implem...
Let's say I've got many functions and each function accepts an unordered list (order does not matter). For each function I want to see if this list is valid based on certain rules (a knowledgebase that has the rules for each function's list). Each one of this lists is at its core a combination, right? And each combinat...
I have a large number of instances of a class. Those instances can fire an event. The only important thing for that event is which instance fired it. I have another instance of a class (and maybe in the future more classes), that want to subscribe to that event. For example (in pseudo C#): class Button { public even...
Recently I developed an Android application which is very difficult to maintain. We are stuck in a complicated situation. We developed Android Apps which contained 500k LOC and another team developed the same application for SetupBox which is 300k LOC. These two applications share some logics and features but they have...
I have been reading a bit more about trunk based development, my company currently mainly uses the git flow model, and I had a question regarding the commits that happen on the trunk and how they are versioned. I'll use the Paul Hammant blog post to try and keep the question less subjective. So below we have the branch...
I'm in the process of designing a library system. There's one application for the librarian to manage books, manage users, etc. But, we also need to ensure that subscriptions are paid on time in this system and to ensure only people who have an active subscription can enter the library. My solution to the above problem...
After seeing an article on visitor pattern, it is clear to me how it works. And I created a sample program for my understanding; main(){ SortingAlgorithm bubbleSort; : intList.sort(bubbleSort); } class IntList implements Sortable{ : public void sort(SortingAlgorithm algo){ return algo.sort...
The operation of increase-key or decrease-key is for updating a key within a max- or min-heap, respectively. Why doesn't a max-heap have a decrease-key operation, and a min-heap a increase-key operation? Thanks.
I was suggested to define a singleton in Python in the following way: class Controller: pass # ... controller = Controller() However, this way, controller cannot be replaced with a derived class. What are other sensible ways to define singletons in Python Django? Maybe, when defining a reusable app, I should ...
What programming language along with implementation and compiler can I use to study the pure, unoptimized space complexity of an arbitrary algorithm? And what methods can I use to do so? For example, Scheme and Elixir implement tail call optimization. If the algorithm I wrote were recursive, whatever methods I could u...
Working on WPF (UI programming) in C# I've started frequently injecting methods into the constructor of my view models. For example: public class HtmlRegexListViewModel : ViewModel { private readonly Action<HtmlRegex> onSelection; public List<HtmlRegex> HtmlRegexes { get; private set; } private HtmlRegex sel...
For programs that read in source code, transform that source code, and then write back out the transformed source code so that it can be read and edited by humans, what sorts of data structures are typically used for representing source code with all its textual details? Is there a standard "textbook" data structure fo...
I need to expose an API A which internally uses another API B. API B accepts an array of product codes and returns their information. That array could have any length but API B will return information of only first 10 product codes and silently discard the rest, i.e. doesn't throw an exception or return an error. Now w...
I don't see the reason to have classes for stacks, queues and deques if we have the data structure linked list, since a linked list can act as both a stack and a queue (and always has the functions of both, if not just named differently). So this brings forth my question, Is there a specific reason I should use stacks...
I'm doing my third online course in learning java because I couldn't get over how to even start a project from scratch. There was a lesson in this new course that made me ask this question of the code and how to write it. It was verses using the dot notation when using class level variables. This is how the instructor'...
In .NET framework, System.Threading.Semaphore is an IDisposable that requires manually invoking dispose. However, in JavaSE, java.util.concurrent.Semaphore is not a Closeable nor an AutoCloseable. Why do they choose different API design? Which one is better?
I am developing a product that uses custom hardware with accompanying software. It requires additional components which are sold separately to make the overall application work. Using these additional components makes it similar to a razor-blade style business model (see http://www.investopedia.com/terms/r/razor-ra...
I'm designing an application using Micro-Services and I'm unsure on the best mechanism to use to collect data from multiple services. I believe there are two options: Integrate an 'inter-service' communication mechanism that allows the services to talk directly. The API Gateway would call an individual service, which ...
I've just written a simple mathematical library which consists of pure functions that take a few arguments, do some computation and return a result. I'd like to write unit tests for this library, but most frameworks I could find (Jasmine, Mocha, QUnit, etc.) include a wide range of bloat, ranging from regex matching to...
Suppose you are developing a Python standalone application (not a library). Would you make it a Python package? Or just files next to each other? If you would make it a package, what would be the "starting point" file (where the first line of code runs)? The __init__.py? Or a short "startup" script outside the package...
I am learning React+Redux now and came to the testing section. Many people use Mocha or Jest to test React components, so far so good, makes sense. I previously have experience using Selenium and I see that Mocha is quite different in a sense that it tests just small parts of a web page(ReactComponents) and not the wh...
Consider a class with a number of methods that are required to return a number of values each. In a strongly typed language such as C#, we can have the effect of returning more that one value from a method by using DTO classes. Consider that the values that my methods are to return collectively are these (let's call it...
So I have to create an object design for this application, it is just problem for practicing. You are building application that will load data from several different advertising systems and then store the data into database, so it will be possible to analyze them. You need to take in mind that every advertising s...
I am storing numbers in my database without formatting (e.g., 1434587). But I need a formatted string in the UX (e.g., $1,434,587). Is it better to store the raw number AND the formatted value in the database? And simply retrieve it to show to the user? Or is it more efficient to only store the unformatted raw number o...
One of the main reasons for writing unit tests is to make sure that code still behaves the same way after refactoring. However, if interfaces change during refactoring, the tests need to be updated as well. Changing tests and production code at the same time introduces risk. How do you avoid it? As an example, say you ...
This is an interview question that I've run across a few times, and I'm really not sure how to solve it given that four numbers are missing. I'm familiar with algorithms for finding one or two numbers are missing, but I don't see a way to generalize either of them to four.
I need to be able to support clients on both MySQL and PostGres databases in a legacy application that does not use any ORM. Say, I have the following interface to query a list of users. public interface IUsers { ... } I have two implementations for the above interface. One for MySQL public class MySQLUsers : IUsers...
Let's say that I'm running Nginx as my webserver. I know that Nginx handles the -s reload command which will reload the configuration when it's changed, but waits around for current requests to finish before it cycles the worker processes to use the new config, so hooray, no downtime! But what about changing actual fil...
Imagine you are creating a video player in JavaScript. This video player loops the user's video repeatedly. Each time a new loop begins the player runs a recursive function that calls itself N times, N being the number of times the video has looped, and because of that the browser will trigger a too much recursion Rang...
I'm exploring the relationship between decentralization and distribution, and I've come to a question for which I've found no real explanation. Does the qualification of a system as "decentralized" infer that the system is distributed? Using the practical example of a star topology in which the central node sends dire...
I have a string series[Episode 37]-03th_July_2010-YouTube and I want to extract the number which comes directly after Episode (eg: 37 from Episode 37)the position ofEpisode 37` may not be fixed in the string. I tried: def extract_episode_num(self,epiname): self.epiname = epiname try: self.temp = ((self...
I want to split a C++/CLI application on two parts : 1. Communication Part, with I/O + logging on text file : 3 COM Ports, 2 sockets and 1 log file 2. UI Part, to handle the data received from COM Ports, sockets etc... For the moment, my application is constantly reading from all COM Ports (with some writing when neede...
Just for the sake of discussion below, when I refer to mocking, I mean mocking/stubbing/faking, as contrast to use real implementation in testing I just had some discussion with my colleague during a pair programming session regarding whether we should use mocking in unit tests for our own written code. (Not sure wheth...
As I am learning DDD to help build an app idea the proper way ;) I have come across a confusing aspect that I am trying to find a solution for. I understand the need for Uuids in an app the size of which I am creating, but I am a little lost as to what method I should use to create Uuids for user-generated objects. I h...
I am building a SPA that basically incorporates multiple video streams (using WebRTC) and various other components such as a text 'chat' feature. I have spent a couple of weeks building a proof of concept prototype using vanilla javascript, jQuery, HTML 5 and Node.js. I was considering using a framework like Angular, o...
Windows Console App vs Service I would like to extend the question at the above post, as the previous answers did a great job of helping me understand the difference between a service and not a service. The question I have now, is with applications that require to be up 24/7, what security concerns there are with a use...
I am writing a class which periodically has to check, if the data it manages is too old, if so it should delete it. I am new to the C++11 multithreading library and I have the following questions: Is such a periodic task better suited for std::thread or std::async? If we use std::async how long is the cleanUp functio...
In building my classes, I have noticed that I have not been very consistent about naming my boolean returns. In Qt; I notice that many of their classes use the is prefix, but checking their coding style and conventions, there is no explicit mention that I have seen thus far. Does the Qt project use a standard or metric...
After some serious quality problems in the last year, my company has recently introduced code reviews. The code review process was quickly introduced, without guidelines or any kind of checklist. Another developer and I where chosen to review all changes made to the systems, before they are merged into the trunk. We w...
Say I have a function that takes some arguments that fall under a bunch of constraints, e.g. one of them has to be an integer, another has to be a string of length at least 10, et cetera. In general, is it the function writer's (i.e. my) responsibility to have a bunch of asserts or whatever to enforce these preconditio...
I have two applications. The client application is written in .NET and the server application is written in native C++. I am using TCP sockets for data communication between the two applications. However, this data is sent over plain text and therefore can be intercepted. What is the best way to protect this informati...
I know in lua you can do something along the lines of print=System.out.println print("Hello") But is there something similar in java?
I understand the concept behind Composition ('has a') where the contained class is destroyed upon termination of the container class. Likewise, I get Aggregation which is a 'looser' relationship between two classes, and termination of one object doesn't dispose of the other entirely. The hard bit, for me, is to actual...
I've been trying to get a clear understanding of what the end of the follwing code outputs: class C { public int foo(C p) { return 1; } } class D extends C { public int foo(C p) { return 2; } public int foo(D p) { return 3; } } C p = new C(); C q = new D(); D r = new D(); int i = p.foo(r); int j = q.foo(q); int ...
I do a lot of programming in my class. It's just my first semester, and most of my stuff is review. I've taken to using a verifyInput function to ensure that user inputs match certain criteria. Since I end up using verifyInput so much, I keep coming up with more ways to enhance and expand it. At the moment, my code loo...
Hi I have a data structures programming project involving creating my own array based list and then efficiently storing String read from a file but in reverse. So that arr[0] = the last line of the file Initially I just thought to have two for loops: First to store the data by its order in my list Second to create a ne...
I want to develop application using java frameworks(spring,hibernate,strut). This application has large complex operations.I want to know what is the best between JSF and angular? As well as i want reference for compare those technology
Take C++ constructors for example, we know they don't return values. Why did Bjarne Stroustrup in the beginning decide not to allow constructor returning 'false' to indicate it fails, so that the run time system can destruct its constructed members just like throwing an exception? What are the concerns that make OO lan...
I have a git repo on the internet and two workstations. Other developers have access to the git repo. Workstation A is at the office and is not accessible from the internet, but can push/pull the git repo. Workstation B is at home. I'm working on a private local branch on Workstation A and have to leave for home when i...
My current workplace has several disconnected teams that depend on each other. There are several legacy prjects with project files. I want to find a way to find a way to visualize our architecture so we can identify "upward" references and nail down where we need to add additional testing. Is there an automated or semi...
I'm having a hard time trying to figure out why the two methods declarations have different results. On the first method signature its obvious you can't compare Apples with Apples and Oranges with Orange, because none of them implement Comparable<>. But on the second method I was surprised that you could actually compa...
I want to design and implement a mobile application in which: Every user who have already registered is able to add new news (including title: text plus a picture, and content: long text, pictures or even videos). Users can scroll hot news (from the News Page) and make decision to read one. They might press the like b...
I'm beginning using AngularJS (v1) framework, and after browsing good practices I found those examples (from this page https://github.com/johnpapa/angular-styleguide/tree/master/a1), like : /* recommended */ function SessionsController() { var vm = this; vm.gotoSession = gotoSession; vm.refresh = refresh; ...
With pre-built CMS usually comes a lot of features that you do not need in your typical smaller project for small businesses and in the end you have to write a lot of your own functionality for said project anyways that is missing. So basically CMS in that scenario saves you initial time overhead of not having to desig...
In object oriented design, we define solution domain with classes. We give a particular role to each class such as factory, data transfer object, serializer, validator, service, proxy, adapter, etc. Do you know a common name for this concept rather than role?
I'm currently working on a computational physics code in Fortran. In summary, the code performs the following operations: Initialize Loop until done Advance solution over time Possibly write output We want to support different physics modules, which solve different equations. I am thinking about the following desi...
We have a database backing an iOS and Android app whose primary data is a simple text field. We have a build tool which builds the database - taking a raw txt file which is a custom data format, which looks like: --- .id SOME_ID .author AUTHOR_NAME .field MORE_DATA .data_title TITLE Data data data [#tag, #tag, ...]: s...
Suppose I eat five meals a day, and since there are seven days in a week, I have recipes for seven of each meal, for 35 recipes in total. Each recipe has a calorie count. Each day must contain one recipe per meal, and each recipe is fixed to a particular meal (e.g. you can't have pancakes for dinner). All 35 recipes mu...
TL;DR: I have noted that some tutorials are using an extra method call to retrieve a variable, in my case EntityManager of Doctrine. Is it generally a good idea to use such extra method call, when it seemingly adds overhead, even if this overhead is "just a little bit" of overhead? In my case I am talking about the c...
I'm new to compiled languages. I'm learning C. I'm used to coding in python. I was wondering if there was any equivalent, or replacement method in compiled langues for functions able to create a function, and to return it. In python one can write: def genAdder (p): def adder (n): return n + p return add...
I've setup a Gitlab server to manage several different Laravel Apps. I'm also able to configure the Gitlab CI to deploy the code to the development and production sites. Everything is kind of streamlined. The problem is Clients want to make many small text changes in the view files. Most of them are fixing the grammati...
I recently upgraded some tests that unearthed a lot of previously hidden bugs. The bugs are rare and low priority, but they are still bugs and will eventually need to be fixed. How should I handle the changes to the tests? If I check-in my changes, many existing validations will fail, and given that these bugs are rel...
Is it correct that hashtables assume no key is shared between more than one records? In other words, can hashtables be used for implementing multimaps? When using a hashtable, can't multiple records with the same key value be dealt with in the same way as dealing with hash collision? Specifically, can the following op...
I want to try a whole bunch of azure services in my project. Now I facing a design problem for the development cycle. I want to test everything local and only it works I want to push it do azure. My OS is manly linux and osx, but there is e.g. no azure storage emulator? Is there a workaround?
Suppose I took the libstc++ implementation of a C++ standard class, and modified it (so now I have, say, a magic_vector based off of the code for std::vector). What licensing restrictions does that imply for that file specifically and for projects using it? I'm asking about libstdc++ specifically because I read here t...
I am interested what would be the ideal way to scale Microservices in DDD world? In case of the following scenario, where Sales context is hosted as a microservice on a different host then Support context, if sales context exceeds hardware limitations, would you: a) scale vertically (increase the resources of the serve...
Just to re-cape cache-aside pattern it defines following steps when fetching and updating data. Fetching Item Return the item from cache if found in it. If not found in cache, read from data store. Put the read item in cache and return it. Updating Item Write the item in data store. Remove the corresponding entry fr...
A faster prime number generator with hyperthreading and L1 cache About five years ago I wrote a simple VB widget to generate the first one million prime numbers and then port them to into its single VB listBox. It took about four hours on a 1.4 GHz Athlon with 1GB of PC-3200 DDR. I was wondering about some possible tip...
I have a file parser and my manager told me that I need to create unit tests for it. Here is my code: public class ParsedDetails { public int Id { get; set; } public Guid Guid { get; set; } public bool IsValid { get; set; } } public class CsvParser : IParser { private const int CsvColumns = 2; priv...