instruction
stringlengths
34
19.9k
According to Gregory Baker & Erik Arvidsson (Google), creating a named function and then passing that to setTimeout is actually faster than creating an anonymous function (reference: Optimizing JavaScript code -> Avoiding pitfalls with closures): Creating a closure is significantly slower then creating an inner functi...
I have a database table that stores uploaded files (excel files) in a blob field. Each record contains the uploader, upload-time, the upload ID (primary key) and of-course, the blob itself. At some point, I need to get that data from the database do something with it. Currently, I have a POJO which just mirrors the tab...
I am implementing a C preprocessor in C... I have the three functions: trigraph replacing function Line splicing function comment removing function However these functions work separately on files i.e. First function will take a file and replace the trigraphs producing a temp-file1 as output Second function will take...
I was wondering what is the best way to organize my source code. I was researching on SO and found https://stackoverflow.com/a/1398594/137261 but this source code layout is library specific and doesn't cover my situation. My situation: 10 own modules (100k lines of code) 15 external libraries (e.g. boost, sqlite, zlib...
I am looking for a recommendation of a best practice for XML comments in C#. When you create a property, it seems like that the expected XML documentation has the following form: /// <summary> /// Gets or sets the ID the uniquely identifies this <see cref="User" /> instance. /// </summary> public int ID { get; ...
I have a web app I would like to gradually refactor by adding structure to it. I have narrowed down the options to Backbone (with some plugins), Ember.js and AngularJS My goal is to refactor that app, which has the usual jQuery spaghetti and gradually add some structure to it. Requirements not a "all or nothing" fram...
I happened to create a mutable class like this: class Mutable<T> { private T value; public Mutable() { this.value = null; } public Mutable(T value) { this.value = value; } T get() { return this.value; } void set(T value) { this.value = value; } } And then it's often used in a method like this: bool...
For commercial and licensing purposes, what is the correct wording for differentiating JavaScript source code (written by the programmer and including comments) from the minified version used in production?
I have a class which represents an entity object in our system (for sake of argument, a Customer object) public class Customer() { private int id; private String name; ... // 30+ fields public Customer() { // empty constructor! } // getters and setters } I'm trying to refactor this so that the fiel...
My team is trying to find out the best way to test one of our components; the main scope is to check if the user/actor has the right to complete the operation requested. The component is formed by many functions that usually have the following structure (simplified): Example language: PHP public function addGroup($idEn...
Say some 20 people go to a shop and everyone buys something. When it comes to paying, 5 of them pay the complete amount of 10,000$ split unequally between them. Since everyone bought different things they all owe different amounts to the payers. Now there are multiple ways the payers can clear the balances with the pa...
I'm in the middle of designing an API for a very basic flashcard application for learning purposes and I'm wondering if you all think there can be any improvements. In the app, a Folder contains Folders and Sets. A Set contains Cards. The Homepage lists any top-level Sets and Folders that the I've created (but neve...
The upper management at our company has laid out a goal for our software team to be “15% more productive” over the next year. Measuring productivity in a software development environment is very subjective, but we are still required to come up with a set of metrics. What sorts of data can we capture that would measure ...
Say I have a class that implements multiple interfaces. I pass the same instance around using a different interface, depending on what the consumer is interested in. I am trying to remember what this is called. I know there is a fancy name for it - I thought it was "interface partitioning", but I'm not finding any hits...
Is there a way to make sure that modifications to free software are released even when no binaries of modified code are conveyed? Though it may sound odd and from what I understand, e.g., GPL requires to distribute source only if binary is conveyed to other parties thus making it possible for unlimited private use as i...
I'm writing a middle layer between vendor code and company business logic. Part of the exercise is to insulate our business logic from vendor's types to make swapping out vendor code easier. As such, I'm writing a lot of extension methods that do translation to and from. I'm placing these extensions in public static p...
Within the world of developers/firms specializing in building/deploying solutions built around software built/sold by Oracle (aka "Oracle houses"), what ORM middleware is considered as the "industry standard" (if any), based on your experience? We have limited experience on Oracle's stack, so would appreciate insights...
I've used git for my personal projects for years, but that's always working alone, not needing to branch much, etc. Our development team at work has decided we are definitely switching to git, and as one of the most experienced git user on the team I have the task of figuring out our project structure. Our current st...
Background I hate the way .Net/IEEE-754 handles equality of floating-point numbers (FPNs) (i.e. double, float). It requires the programmer to be prescient with respect to the yet-to-be-determined history of the number, as the programmer must choose a 'reasonable' value of epsilon where frequently no such value can be d...
Is it okay to have a strategy implemented as a non-static inner class or is it considered a bad practice? public class SomeClass{ private final Strategy strategy; public void someMethod(){ this.strategy = new Strategy(); //call some strategy method to run an algorithm strategy.doSomeWork(); } priva...
Say I have a method called 'functionA' that is called by a service and carries out a single piece of functionality, it is easy to unit test as it is does one thing only. If a few months later an new requirement comes in that requires another method 'functionB' to be called directly after 'functionA' has executed. What...
Some programming languages like e.g. Scala have the concept of Option types (also called Maybe), which can either contain a value or not. From what I've read about them they are considered widely to be a superior way of dealing with this issue than null, because they explicitly force the programmer to consider the cas...
For the sake of an exercise, say you have an input file with a series of lines of text with the objective of reversing their respective character sequences. Now introduce 5 threads that will each do the reversing, thread 1 taking care of line 1, thread 2 taking care of line 2 and so on. If the aim is to save these reve...
I noticed some duplicate code in a codebase I am working on that appended a filename to a directory path, so I decided to refactor it into its own method. The application I am working on is not well tested, however; I just set up the first unit tests on it two days ago, so I am very concerned to get as much code under ...
I work for an organization that does a lot of work with government data. We have a couple of different projects where we've abstracted out common text search/manipulation operations into reusable libraries, for things like standardizing the way politicians' names are displayed (e.g., transforming "MCDONALD, BOB (R-VA)...
Distributed issue tracking seems like a belting idea to me, but it has never really taken off in a big way. Is there a good reason for that? I am aware of: bugz everywhere too complex to set up too many requirements reasonably successful, used by some large projects fossil tries to integrate too many things, and en...
I was watching one of Uncle Bob's videos and he brought up the Database Interface Layer. He had this diagram showing it: These arrows show that the DB Interface Layer is aware of and calls the Application and Database layer, but not vice versa. The DB Interface Layer has "data records" in it. These are "classes" t...
How are effort estimations and duration estimations distinct? At present my understanding is that effort is related to the amount of work required for one person to complete a task, and duration is the total amount of time required to complete the task, irrespective of resources. Is this the commonly accepted definitio...
In a lecture, the lecturer described the following model : E - entry (the preconditions to a task). T - task - doing the task V - verifying the tasks quality D - Delivering the tasks X - Exit. or ETVDX If anyone is familiar with this 'generic compliance model', how does it fit into software development exactly? I...
I've got a simple authentication solution, where a user can log in with either email or username. Since I want to show the little feature in the acceptance tests but don't want to pollute them, I thought I'll introduce some randomness. Do you think this is bad or good? step "Fill in my credentials" do fill_in :user...
I am looking to write a Bayes filter that will act as an indicator of topic for a number of topics with a variable number of sources. Given a really big number of RSS feeds and here really big might only be a few hundred only few percent (let's say 2%) are interesting to a given group. What I want to write (in PHP) is ...
From time to time I find there is a need to build a service class. Something I can't really attach inside a model in order to respected GRASP and SOLID. So I created a class called AccountTransferService. Are service classes good design practice ? Do they represent a Model ? If a Service is not a Model what are they...
From time to time I implement functionality which requires asking user questions sequentially. Questions are conditional, that is the answer defines the set of the following questtiongs. Sure it is Wizzard UI design pattern, but for now I have no clear understanding how it is implemented from the point of view of softw...
I always try to follow the DRY principle strictly at work; every time I've repeated code out of laziness it bites back later when I need to maintain that code in two places. But often I write small methods (maybe 10 - 15 lines of code) that need to be reused across two projects that can't reference each other. The meth...
I think i've understood more or less what a parsed Scheme program looks like (a binary tree with atomic values on the leaves, if i have understood correctly). Can anybody please define to me, or give a reference, what a state (or a computation) of a Scheme program is? Is it just the current binding plus a position, o...
Say we have some thread that wants to check when another thread is finished its task. I have read that we should call a wait() type function that will make this thread wait until it receives a notification that the other thread is finished. And that this is good because it means we aren't performing expensive polling. ...
I'm writing some code that sets cookies and I'm wondering about the exact semantics of the Set-Cookie header. Imagine the following HTTP header line: Set-Cookie: name=value; Path=/%20 For with path does this set the cookie? / or /%20(unescaped) (/%20 or /%2520 escaped)? The reason I'm asking is that I should support n...
Activity network diagrams are used to determine the forward and backward paths for a project, and consequently to determine the critical path or maximum time to development. I'm already familiar with using work breakdown structures which break down functional requirements into necessary and sufficient deliverables, b...
I'm working on a translator in C++. Basically I want to parse the file with translations and store it in my program, so I can perform search through the words and simply access the corresponding word. My file will look like that: word|translation second word|second translation etc. It doesn't have to be | as delimiter...
Recently completed a project for handling credit card processing. One of the difficulties I faced was handling the delay / possible failure of notification messages. The most complex example was: an external system sending the request for payment my system turning that request into a request to the payment gateway sen...
I've read that ios apps can communicate via unique urls. An online tutorial on tutsplus says Communication between apps provides your application with an opportunity to take advantage of other application’s functionality, send and receive data between apps, and provide a rich user experience that “just works”. I have...
To better understand my question, let me elaborate the background of the subject matter. I work in a financial institution where the business module (credit finance) is constantly changing. In the IT world, however, the developers have a 6 week cycle taking list of projects/enhancements, put it in a timeline and busine...
I was studying the book Structure and Interpretation of Computer Programs and in section 1.1.5 The Substitution Model for Procedure Application the author explains the concepts of normal order and applicative order, which I believe I have understood well. Now, I am taking a course on Coursera called Function Programmin...
I have been reading about the libraries people have written for languages like Java and C# that make use of byte code weaving to do things like intercept function calls, insert logging code, etc. I have also been reading up on Lisp/Clojure macros in an attempt to better understand how to utilize them. The more I read a...
I'm using the BigRational class from bcl.codeplex.com. It will be opensourced when it's finished, and it's modified. However, I don't get legal jargon, so even though it's quite short, could someone explain to me what it does/doesn't allow you to do?
I would like to write some long text in some structure to allow a set of operations on that text. The question is which structure or format should I use, which suits best the use that I plan to do of that text? Next I describe that use: I would like to write text in natural language, possibly with translations to seve...
So say you had a site like StackExchange. Now imagine you created a machine-writeable API capable of posting questions and comments and doing everything your browser can do. Of course, about 5 minutes after launching, you'd have so much spam that you would probably have ran out of room on your database servers and wil...
I have heard two separate uses for the term controller when speaking of the Model View Controller methodology. An intermediary section of code that communicates between the Model and View, tying them together. The module that deals with input, similarly to how the view deals with output. For starters, which definitio...
I am trying to make my way back to JavaScript (been there last time some 7 years ago) with the help of lovely "Eloquent JavaScript" book. While I admire author's capabilities and approach, I have also began being concerned. I am from C/C++ background and there I learnt it rather hard way that funky constructs often und...
I've heard the term pop all around. I've read various articles regarding the subject and heard two main definitions to the term "Service Location": A glorified Registry - Bad practice, global variables, general evil. A type of Dependency Injection Container - Can help with managing dependencies, making modular and ext...
I'm in the process of building a new pledge management system for one of my clients, a charity foundation. I have already built one for them (it was done using Delphi), but its feature-set is a little limited. Now, I have decided to move to PHP and use the Laravel framework to manage the database for the new system - i...
I have a basic issue with the MVC architecture. I am aware that the View usually listens to the Model. But how are user requests propagated to the Model? Currently I do it like this, when the user clicks e.g. the update Button in the GUI. So the ActionListener calls a method of the View. The View calls a method of the ...
first of all I am new here and I hope that this is the right place for my question. I have a question about the recommended architecture of a project. IDEA: Automate some calculations concerning to aerodynamics. I have some input data and I need to process this data in several sub-calculations. You can see such a calcu...
I do not know if this would be the right stack exchange site to ask this question but I have been researching on RAD (Rapid Application Development) and Agile methodologies and was trying to find their diagrams but if I google images this, it comes up with many different diagrams. So based on the images I drew my own d...
I started to get more and more engaged in open source development and I was wondering if there are any guidelines on how to properly document and maintain a fork? For example, let's say you fork a project to add some specific thing to it. Maybe you do not want to send pull requests back to the original project or maybe...
I have the following type hierarchy: interface I: ----+class B implements I ----+class C implements I ----+class D implements I I have another class Consumer1 that supports types C and D but not B (in its various methods) and a class Consumer2 that supports type B. I have total control over Consumer1 and C...
Is the following guaranteed to return true for all numerical and non-zero values of x? bool IsRoundTrip(double x) { double y = 1 / (1 / x); return x == y; } What conditions would cause a discrepency?
Considering that it's April, 2013; do I still need to worry about non-JavaScript capable/enabled clients? Note: This question excludes having helper text with: JavaScript is required to view this page, upgrade to a modern browser or modify your settings BTW: Just to be clear, in order to cater to non-JavaScript capable...
I am a Sr java Developer and have recently joined a new team. Here I have been asked to create a functional document looking at the code of a legacy application. This application was written about 8-10 years back, which is currently running in live environment but due to lack of documentation it is difficult to be setu...
Main I'm making a scripting language using C++. I plan to use it with a simple test game editor. But I have to make a support for bindings to call game engine's nodes' methods to update positions, rotations, etc. What are the main approaches for this? The game engine I plan to use also supports lua, so maybe I can also...
Is it a good practice to use reflection if greatly reduces the quantity of boilerplate code? Basically there is a trade-off between performance and maybe readability on one side and abstraction/automation/reduction of boilerplate code on the other side. Edit: Here is an example of a recommended use of reflection. To g...
First of all I'm not asking for legal advice but just checking if anyone agrees with my suspicions. That might help in convincing Sencha to change their license. Their commercial license says: The Open Source version of the Software (“GPL Version”) is licensed under the terms of the GNU General Public License versions...
I have some classes that are composed with ORM generated Models. example1: For example the Report.php (Model) is using a Document.php Model generated with ORM. Based on the document object a report is created. I would like to know some name suggestions for the Report.php folder path. It clearly belongs to the /Model fo...
Hopefully, this question is not too open-ended... I have been tasked with taking a 3 year old application (.NET 4.0, WPF, WCF, EF 4, SQL 2008) that was designed for a very specific market X and "re-purposing" it for a another very specific market Y. To further complicate things, the company has also mentioned a third m...
I am a software engineer for 4 years, and I just changed my company for the first time. Company works with pair programming, and it's been 3 days, I couldn't even write a single line of code. It's so frustrating for me because I was very productive at my previous company. The codebase is large, they are using 5-6 langu...
I am considering using sourceforge, bitbucket or github for managing source control for my business. I have open projects and I participate in open projects such as gcc. But I also have a business where I develop closed-source software for my living. How trustworthy are sourceforge, github or bitbucket in terms of ke...
I have forked a project that was released under the GPL and made substantial modifications, however there are still some parts and general ideas that are the same as upstream. Due to user interest I am wondering how, if at all, I can relicense the project. Another developer and I have attempted to reach the upstream d...
We are writing a system with a sort of quasi-MVC structure (it was never stated as that, but that's what it is). I'm building up a full knowledge of the system and the controller will have to make calls to me to update it; they system itself is something similar to a graph. We need to have a sense of a path between mu...
We have been using Hosted SVN + Fogbugz for our source control and task/issue tracking. Our developers are very comfortable with SVN and we are hesitant to switch source control (e.g. TFS) providers at this point. However, Management extensively uses Microsoft Project for project management and are considering setting ...
Adap.TV has chosen C++ to develop their software. However, they've decided not to use the standard containers1 and boost for performance reasons, as they've blogged about it in the following article: Why we use C++ (without using STL or boost) It says (emphasis mine), There are several rules that we are obeying in o...
I recently started working for a company that has me making mockups for an app they'd like to see converted to an iPhone app. I have not been informed as to how all the boards fit together, but I do have a general idea on what they should look like. I would like to write notes or comments on each individual board about...
I asked a question on StackOverflow in November about separating a very large application into layers and tiers: https://stackoverflow.com/questions/13342626/net-divorcing-layers. The previous developer included data logic and business logic in the business logic layer My question is about the tiers element. I resear...
I'm kinda having a debate here with my friend, whether it's OK to have a development language before putting the idea into C++. When I say development language I mean a language to try ideas out before putting them into the compiled language, in this case C++. My friend thinks it's unnecessary (and maybe a waste of tim...
It seems to be easier to use and more feature rich than standard swing layouts. It looks like a do it all replacement for all standard layouts. If you are making simple code to just show the time in a window, then MigLayout is probably not useful. But, if you are making a flight cockpit panel, then MigLayout might be t...
We have an MVC4 application that we would also need to distribute as a standalone (no network connectivity) desktop application. Rather than rebuild the HTML/JS front-end we would like to reuse that so in essence we're distributing a self-hosted HTML-view-based .NET MVC application. What we roughly envision is: MVC4 .N...
My design doesn't allow me to mock the data so I am using sqlite as test database that has minimum data to run the unit tests. Below is the pseudo code //Method to be tested public IList<Funds> GetFunds() { List<Funds> objFundsList = //gets two records from sqlite db; return objFundsList; } //Test Method publ...
I work on a C++ project that generates bajillions of warnings. Most of the warnings appeared after the code was written: Initially the project used Visual C++ 8, soon switching to 9, but there is little difference in the generated warnings. Warnings were either fixed or silenced, so there were no warnings then. Then a...
I have many sublcasses of one class. I choose concrete class based on type (simple enum). I like idea of class cluster. Should i use it or just create factory class (but each class in objective-c is actually a factory)? What is the difference between factory pattern and class cluster pattern. When to use it in your cod...
What are the major differences in between Java version in terms of software development? Where can one find a summary of the most important changes related to programming? The Release Notes such as http://www.oracle.com/technetwork/java/javase/releasenotes-136954.html can be hard to read. For example there is new code...
Every competent Java programmer knows that you need to use String.equals() to compare a string, rather than == because == checks for reference equality. When I'm dealing with strings, most of the time I'm checking for value equality rather than reference equality. It seems to me that it would be more intuitive if the l...
I have a project where the customer requirement specifies a report and contains mathematical equations for the contents of some of the columns on that report. One of the columns on this report is a running total which starts at a opening value, and which 'should' remain at that opening value all the way down the report...
In an Agile development process usually the main focus is on User stories, but sometimes a single requirement may span several user stories. For example, the client may request a search page for all users in a forum, and there are several actions that can occur on each user such as ban user, delete user, reset Password...
I want to use an ORM with a legacy database, but I don't want to expose some of the underlying data types. For example, some of the columns are nullable doubles or floats and I want my domain model to use non nullable decimals. It seems to be impossible to have Entity Framework automagically cast between these types, a...
I'm building a REST api where clients are authenticated using client certificates. A client in this case is not an individual user, but some sort of a presentation layer. Users are authenticated using a custom approach and it's the responsibility of the presentation layer to see that this is properly done (note: I know...
I'm a freelance programmer and recently I finished a website, it all works fine but there was one user that complained to my client that he couldn't log in. This problem was clearly a cookie-restriction/old browser one (I couldn't create the problem myself and hunderds of users are working with the website just fine) N...
I have a web application that I have been developing for a small group within my company over the past few years, using Pipeline Pilot (plus jQuery and Python scripting) for web development and back-end computation, and Oracle 10g for my RDBMS. Users upload experimental genomic data, which is parsed into a database, an...
I'm heading a new team of developers working on a software project that makes use of continuous integration (circleci) w/ a pretty fleshed out suite of busterjs unit/integration/acceptance tests. Our project is primarily written w/ coffeescript, and I try to make use of coffeescript-linter to ensure everyone working ou...
I was reading this article: A Critique of Common Lisp and finding it hard to make out the precise definition of "stock-hardware machine" and its difference with "micro-coded" machines. I tried to search for a precise definition of the former to no avail. What I currently construe stock-hardware machine to be is that, i...
I'm having some difficulty to evaluate the revision of a software: the software was paid by customer years ago, never used, and now the customer have noticed that it doesn't work as expected. Now this customer asked me to evaluate the project (I have the sources), and I should give an estimation of the time to fix it a...
Reading about ARM architecture I found many similarities to PDP-11 architecture which did not exist between ARM and x86. For example, General-purpose registers named Rx compared to AX, BX,... for x86 Uniform registry file (all registers permit all kinds of operations) Similar names for program counter (PC both on AR...
A LAMP project I am currently working on is pretty well organized on the backend. However, there are a ton of pages that just have a diarrhea of javascript and html squirted all over numerous locations with little discernible architecture, rhyme, or reason. In a few cases, some kind of javascript prototype was created ...
I am interested in hearing some guidelines as to what feedback is or is not appropriate for a code review. My team has a very unstructured review process and I am trying to suggest some ways to improve it. I am no expert so I hope to hear from you experts out there! Should code review comments be limited to actual p...
As the number of bugs in a codebase increases, that number not only decreases the quality of the code, it also affects the mindset of the developers. Developer self-confidence falls when things are not going well. If self-confidence is not right, things more easily become a mess. How do you guys keep your self confi...
I have a graph with about a billion vertices, each of which is connected to about 100 other vertices at random. I want to find the length of the shortest path between two points. I don't care about the actual path used. Notes: Sometimes edges will be severed or added. This happens about 500 times less often than looku...
I am new to image processing using Python. Now I am learning OpenCV and the mahotas module in Python. Many functions in these modules are related to watershed of an image. I don't know what watershed means for an image. Here is an example from the OpenCV documentation: http://docs.opencv.org/search.html?q=watershed...
I'm looking for a C function library, which would contain a collection of simple and plain utility functions "missing" from C or POSIX standards. I found this earlier question, but answers there list only full frameworks or libraries designed to replace/duplicate standard libraries instead of seamlessly fill the gaps. ...
Let's say we have 4 classes A, B, C, D where: A is a superclass of both B and C and C is a superclass of D. I suppose, in a diagram, it should look like this: A / \ B C \ D Moreover, the class A implements the interface Comparable<A> and also implements a method public int compareTo(A a...
The context We're building a web application using Entity Framework 5.0. One of the requirements is that it should be possible for the administrators to link related products so that when someone browses to a product we can render a list "You might also like these products:". Since a product can be linked to many produ...
If i have two systems (A and B) running on LAN(INTRANET) which are directly connected. There are no routers in the middle. In this case, if system A sends a few UDP packets every few milliseconds to system B: Is it possible that system B receives the packets in a different order? Please note that I'm not asking whe...
I am creating an advanced search page where there are about 20 search fields for a user to filter their search. My question deals with the query string, Is it standard web development practice to have say 20 parameters in a querystring? The search results display large tables of data. Is there an alternative that stil...