instruction
stringlengths
34
19.9k
During team formation, we have a conflict where 2 developers both really want the same coveted window seat with a lush view of a creek & the woods. What sort of game / activity can we place them in that will: Decide who gets the seat Provide a random (not skill based) chance of winning Allow both team members to part...
Given a corner x of an undirected Graph G I would like to ask for the connected component of x, but my first try does not work as desired. Here it is: edge( a,b ). edge( b,a ). edge( b,c ). edge( c,b ). edge( c,d ). edge( d,c ). connected( X,X ). connected( X,Y ) :- edge(X,Y). connected( X,Y ) :- \+ edge(X,Y), edge(...
Now I know people could consider this question duplicate or asked many times, in which case I would appreciate a link to relevant questions with answer to my question. I have been recently in disagreement with some folks about code coverage. I have a group of people who want our team to drop looking at code coverage al...
There seems to be an aversion to writing even the most basic documentation. Our project READMEs are relatively bare. There aren't even updated lists of dependencies in the docs. Is there something I'm unaware of in the industry that makes programmers dislike writing documentation? I can type out paragraphs of docs if n...
What is the difference between Microsoft.Web.Helpers and System.Web.Helpers? Did one take the place of the other (same thing, different version/name), or are they separate things. If so, how do they differ? What is the raison d'etre of each, and are there scenarios where you might use both of them?
My company is an online retailer, and we use an homebrew ecommerce platform. In the last year or so, we've partnered with a accounting software vendor, as our homebrew solution was unable to produce reports as needed, or otherwise satisfy the requests of banks and investors. We're off to a rocky start with the softwar...
We all know “The quick brown fox jumps over the lazy dog” used as benchmark for printing and fonts. I wonder if there is a similar “Lazy Dog” for Programming Languages. There are so many different programming languages, with all kinds of features and syntaxs, similar or different. The problem is: the user will be confu...
I am releasing an application at no cost, but I am not granting users the right to modify or redistribute the code. How should I call this? I initially used the term "free license", but on second thoughts I find this confusing because free can have several meanings, and in people's mind it is often associated with ope...
I'm going to make an application that will be given data to put in a database. The data will for the most part be the same, but the way it is formatted will vary a lot (could be in anything from text files to .xls to .doc). I'm not a very experienced developer, but I can see some potential issues and I want to minimize...
Looking through the server vs local code on a humongous legacy project, I see this in Settings.settings: <?xml version='1.0' encoding='utf-8'?> <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> <Profiles> <Profile Name="(Default)" /> </Profiles> <Set...
The finally block for a try-catch structure is well known, and gives a really easy and elegant way to deal with some must-be-done code. Therefore, I can see no reason why It shouldn't be good for methods too. For instance, lets say I'm writing some very complicated logic in a method, and I expect to end up with a bunch...
I am creating a widget for rotating topics. The functionality is as follows: Each topic is displayed one by one on the homepage and has a duration of 30 seconds. A countdown timer is displayed on the page. When it reaches zero the current topic gets marked as "shown" and the next topic is displayed. Users can choose t...
I would to find an efficient structure (speed and volume) to store nodes and their neighbourhood. My input is build out of stings in the following format ./X/Y.log where X ∈ [0,359] and Y ∈ [0,169] and each pair of (X,Y) defined the coordinate of a cell on a grid of the size [170x360]. I would like to find which cell...
So after many many many years of building sites from scratch (and doing a lot of the lifting myself) I've dipped my toes into two projects that have been around for a few years that I've been avoiding: Bootstrap and Jekyll. The design was a very customised job that required me to dig into the LESS so I've got the Boots...
I've created a gateway which receives a POST from cUrl on one system which is a well-formed XML string. After processing the gateway sends back a response XML. All the fields in the XML are required and while the system sending the data constructs the XML itself I'm running some validation to make sure that every value...
Suppose I have a table "Progress" with two columns. One column is ID which is identity. Another column is Progress_Label ID Progress_Label 1 Submitted 2 Approved by user 3 Rejected by leadership 4 Cancelled 5 Completed What is the best programming practice, should I go by ID or by label? In m...
When I first taught myself how to make websites (html/css) I used exact pixel width and height for all div elements. I've also practiced making websites with nothing but percentage width and height. I can use either technique fairly easily, but I wanted to know is there a standard technique or structure to building the...
I come from an embedded world where we use C/C++ for programming, and use an IDE to generate a binary file, which is then programmed into a Hardware Board, which can then be tested. With this background, what is a better workflow for automated builds than the current workflow of -build(using IDE)->Flash into the hardwa...
We know some signature/checksum methods for text, like md5,sha. Now, I want to compute a checksum for a matrix, to represent the exact matrix. Say, two matrixes with different sizes, or with different values, have different checksum. And slightly different matrixes(same size) result in slightly different checksum. So, ...
Say I have an array of runners with which I need to find the tallest runner, the fastest runner, and the lightest runner. It seems like the most readable solution would be: runners = getRunners(); tallestRunner = getTallestRunner(runners); fastestRunner = getFastestRunner(runners); lightestRunner = getLightestRunner(ru...
I was going through an article here In the section named Aggregate Method ,the author says Then summing over the entire sequence, all the 1's sum to O(n), and all the di also sum to O(n). That is, and then gives this Σ1≤i≤n ci ≤ n + Σ0≤j≤m 2j−1 I can understand how summing 1's to get n , But I am not very clear ...
My question is about how to create a definition for an object that is handled by different web services. A brief description of my current scenario and why I think it's a problem: A PHP web application provides AJAX endpoints for populating various parts of my web app. The endpoint provides access to User and Project e...
Sometimes, the syntax of a language seems weird, I often think, why would someone make something like that, but definitely there is a reason and a history behind every aspect of a programming language. Apart from being fascinating, It helps me remember the syntax and also the purpose that language solves. Does knowing ...
I am going to make an online judge platform. I have looked for some online judge platforms on the Internet for reference (I mean the platforms which have the source code available, and can be hosted my others, not something like Codeforces). Most of them have a web interface written in PHP (or something else). When use...
From my understanding of REST, the implicit assumption is that all operations are CRUD operations. Sometimes, you are not doing CRUD operations and are doing some more complex logic. In this case, is not SOAP more suitable? Or is it the case that all operations no matter how complex are a series of CRUD operations so t...
Due to data protection, I cannot discuss fine details of the work itself so apologies PROBLEM CASE Sometimes my software projects require merging/integration with third party (customer or other suppliers) software. these software are often in linkable executables or object code (requires that my source code is retarget...
I work on embedded systems, so frequently, I am required to implement protocols. When I do this I like to make nice clean layers. However, this become difficult where the fields used by different layers are shared. I like to think of the layers as offering a number of services following the spirit of OSI model: Frami...
Looking at node.js, and avoiding nesting callbacks. I found Async.js, can someone show me how can I rewrite this code using the async.waterfall method? // db is a mongodb instance db.open(function(err, client){ client.createCollection("docs", function(err, col) { client.collection("docs", function(err, col...
I am getting some data from Gov tracker (http://www.govtrack.us/developers/api) and creating a Windows 8 Store application.. I started out trying to use the HttpClient to get the JSON and then use Json2Charp.com to convert it to classes... But then I had no idea what to do with this giant class and the line var co...
I have a desktop application that has the ability to automatically update itself on the next restart (without the user's consent - but this is another issue altogether). Assuming that the user would never notice anything related to application updating (such as a progress bar, or pop-up requiring restart), and that our...
Web applications usually have a database. The code and the database work hand in hand together. Therefore Frameworks like Ruby on Rails and Django create migration files Sure there are also servers written in Self or Smalltalk or other image-based systems that face the same problem: Code is not written on the server bu...
When reading articles on ISP, there seem to be two contradicting definitions of ISP: According to first definition ( see 1, 2, 3), ISP states that classes implementing the interface shouldn't be forced to implement functionalities which they don't need. Thus, fat interface IFat interface IFat { void A(); void...
EDIT: As pointed out by Steve Evers and pdr, I am not correctly implementing the Memento pattern, my design is actually State pattern. Menu Program I built a console-based menu program with multiple levels that selects a particular test to run. Each level more precisely describes the operation. At any level you can ty...
I have a file (or rather, a list of about 100 files) in my website's repository that is still requiring the use of register_globals and other nastiness (like custom error reporting, etc) because the code is so bad, throws notices, and is 100% procedural with few subroutines. We want to move to PHP 5.4 (and eventually 5...
This is referring to a discussion in an answer and the comments of this question: What's with the aversion to documentation in the industry?. The answer claimed that "code can't lie" and thus should be the go-to location instead of documentation. Several comments pointed out that "code can lie". There is truth on bo...
I've stumbled upon this problem when tried to run our application in bad network conditions; it spawns hundreds of threads (which exist long time before termination), and with time the application crashes. However, other developers answered this is "not a bug" and "as designed". I have a strong gut feeling that spawnin...
In general, how do I decide whether to use make a class a super class, or to make it a private data member of another class? For example, given two classes, how does one decide whether to do this: public class Sprite { private BaseImage image; ... or this: public class Sprite extends BaseImage { ... Funct...
In a nutshell, should we design death into our programs, processes, and threads at a low level, for the good of the overall system? Failures happen. Processes die. We plan for disaster and occasionally recover from it. But we rarely design and implement unpredictable program death. We hope that our services' uptimes ar...
So, I've been evaluating Entity Framework and NHibernate (I'm not looking for an EF vs. NH battle here, though!). One thing that I see come up very often is that NHibernate is recommended for "legacy"/brownfield database projects, and lighter-weight ORMs (Dapper, etc) are sometimes recommended for newer dbs. I will be ...
In git if I change a character in a line the entire line is considered changed. I don't know much but stackexchange seem to track changes in a word-by-word basis in the edit history. Is there an option to make git like that, or is there anything else that does this?
What does "branching is free" mean in Git? I hear this a lot whenever Git is mentioned in comparison to other version control systems. I haven't had the opportunity (?) to deal with others (SVN, etc.), so how is branching "expensive" in others?
I see the http parser written by Igor Sysoev for nginx does not use regular expressions https://github.com/joyent/http-parser What could be the main reason for such design decision? I guess I could write few regular expressions to parse HTTP req & res this would be a lot less complex than Igor's version of the parser. ...
I have been asked to make a mobile app for a friends website. The website is a Multi level marketing site that sells products and franchises. A client logs in in to the website and can view his or her dashboard ( user can view team members, business volume, commissions, invoices, etc.) The app is supposed to bring the ...
My OOP JavaScript question is at the very bottom if you want to skip my introduction. In an answer to the question Accessing variables from other functions without using global variables, there's a comment about OOP that says: If there's a chance that you will reuse this code, then I would probably make the effor...
Consider the following regex (no unicode): Example:\x04\x05\x41 Suppose you search this regex case-insensitively. Would you expect it to search the final \x41 in case-sensitive manner? People whom I ask actually expect such behavior. And such expectations are wrong. Perldoc says: Note that a character expressed as on...
As programmers I feel that our goal is to provide good abstractions on the given domain model and business logic. But where should this abstraction stop? How to make the trade-off between abstraction and all it's benefits (flexibility, ease of changing etc.) and ease of understanding the code and all it's benefits. I b...
(Let me edit this question to try to better get across what I am asking.) I don't understand what a license is and how I may "use" it. From the little that I do understand, there are two situations: One writes a program/source code and puts a license on it. The license says how other people may (are allowed) to use th...
Non-Turing complete languages offer a great advantage over Turing-complete languages as they are much more analyzable and, thus, offer much broader optimization possibilities. Yet they are barely used and Turing-completeness is actually sold as a good feature. Are there any mainstream non-Turing-complete languages avai...
Except the garbage collector, what are some other features in Java that make it unsuitable for real time programming? On the net, whenever Java vs C++ is discussed with regards to real time programming, it is always the garbage collector that is mentioned. Is there anything else?
I am developing an iPhone app, which I am integrating with PayPal. I did it successfully using PayPal library. I am testing it on sandbox mode. When I transfer money from one account to the other account, it displays a message "send to server for verification". Is there a real need to store this PayPal transaction id a...
I have an Email class that has a Send method that optionally takes an SmtpClient and sends an email asynchronously using SendAsync. If no SmtpClient is supplied to this method, it instantiates a default SmtpClient and uses that to send the email. Inside the Send function, I provide a SendCompleted callback which dispos...
Researching archiving systems like archive.org, found out main issue of such is the dynamic content. Initial analysis shows that content 'dynamicity' can be assigned to one of the following levels: Static html content - plain old web page which is represented only by html markup with auxiliary css-referred resources (...
I am in the process of filing in the gaps in my knowledge so that I can become a better developer. I am an ASP.NET developer and I sometimes need to do pure back-end stuff too. I ahve compiled a list of things I deem as necessary to know. Please feel free to fill in any gaps: WebForms MVC jQuery HTML5 WPF WCF The Repo...
I have come across a book that claims that alterations and augmentations to GPL works can be kept close-source as long as these are not redistributed into the wild. Therefore, customizations of websites deriving from GPL packages need not be released under the GPL and developers can earn profit on them by offering thei...
I am creating a flowchart for a program with multiple sequential steps. Every step should be performed if the previous step is succesful. I use a c-based programming language so the lay-out would be something like this: METHOD 1: if(step_one_succeeded()) { if(step_two_succeeded()) { if(step_three_succee...
I am trying to achieve zero downtime deployments so I can deploy less during off hours and more during "slower" hours - or anytime, in theory. My current setup, somewhat simplified: Web Server A (.NET App) Web Server B (.NET App) Database Server (SQL Server) My current deployment process: "Stop" the sites on both We...
Backstory I inherited a bunch of code that I'd like to refactor. It is a UI application written in javascript. Current state: We have main application which consist of several UI components. And each component has entry fields, textboxes, menus, etc), like "ticket", "customer information", etc. Based on input, where t...
Quick question concerning shared code/logic in back and front ends of a web application. I have a web application (Rails + heavy JS) that parses metadata from HTML pages fetched via a user supplied URL (think Pinterest or Instapaper). Currently this processing takes place exclusively on the client-side. The code that f...
I have come to a point, in building a services oriented architecture (on top of Thrift), that I need to expose events and allow listeners. My initial thought was, "create an EventService" to handle publishing and subscribing to events. That EventService can use whatever implementation it desires to actually distribute ...
At a recent job interview, I couldn't answer a question about SOLID -- beyond providing the basic meaning of the various principles. It really bugs me. I have done a couple of days worth of digging around and have yet to come up with a satisfactory summary. The interview question was: If you were to look at a .Net pr...
I'm developing an iOS app where one of the features will be allowing users to share and collaborate on data (e.g. lists). From everything I've read and based on the way that iCloud CoreData sync works I assume that it would not be a good fit for the following reasons, but I wanted to make sure I wasn't missing anything...
Note that my question is referring to those attributes that even on their own already represent a concept ( ie on their own provide a cohesive meaning ). Thus such attribute needs no additional functional support and as such is self-contained. I'm also well-aware that even with self-contained attributes the custom typ...
I saw below test question the other day in which the authors used a flowchart to represent the logic of loops, and I got to thinking it would be interesting to do this with some more complex logic. For example, the closure in this immediately-invoked function expression (IIFE) sort of boggles me: while (i <= qty_of_get...
I've spent about 20-40 hours developing part of a game using JavaScript and HTML5 canvas. When I started I had no idea what I was doing. So it started as a proof of concept and is coming along nicely now, but it has no automated tests. The game is starting to become complex enough that it could benefit from some aut...
I am going to be developing a program that detects duplicate files and I was wondering what the best/fastest method would be to do this? I am more interested in what the best hash algorithm would be to do this? For example, I was thinking of having it get the hash of each files contents and then group the hashes that a...
I am not sure if anyone has done it. I am trying to do something that is in general, uncommon i.e. unit-testing executable (Windows) or ELFs (Linux). I know that CppUnit provides a good unit testing facility, but I have never used it for unit-testing (used UnitTest++). I hear rumours that you can unit-test executables ...
This has been a cause of frustration for me on many sites like IRCTC, Online Banking sites which wont allow Back, forward or refresh. If you do you would be logged out and you have to login again. What I don't understand is what concern had there been in their mind to have such terrible "feature".
According to Jeff Bay's Essay on Object Callisthenics, One of the practices is set to be "Wrap all primitives and Strings" Can anyone elaborate on this ? In languages where we already have wrappers for primitives like C# and Java. and In languages where Collections can have generics where you are sure of what type goes...
We were looking for some topics related to audio analysis and found acoustic fingerprinting. As it is, it seems like the most famous application for it is for identification of music. Enter our manager, who requested us to research and possible find an algorithm or existing code that we can use for this very simple app...
We have a large bazaar repository and we want to convert it to a git repository. The bazaar repository contains the folders of each of the interns. Any documentation/code prepared by interns is committed in their directory so there are a huge number of commits. What steps should be performed to securely convert the baz...
Assume I have a simple interface for translating text (sample code in C#): public interface ITranslationService { string GetTranslation(string key, CultureInfo targetLanguage); // some other methods... } A first simple implementation of this interface already exists and simply goes to the database for every me...
I serialized lambda expressions in C# before. Now I wanna use F# instead of C# for serialization and deserialization. I heard F# is better in this area. Is it true? How can I do that with F#? I’d appreciate even if you just suggested a correlated link.
I have some experience in programming in Java but wondering if someone could explain what is the difference between Enterprise Java vs Core Java? Someone asked me a question on whether I use core-Java or Enterprise Java. Now I have to ask is there such thing as core-java?
I'm supposed to implement a relatively complex form that looks like follows, but has at least four more pages requiring the user to fill in all necessary information for the tracks: This data will need to be sent to the server, which is implemented using Dropwizard. I'm looking for best practices on how to upload and ...
On the past 2 projects I've worked, teams prefer a local development environment over a development server. The one project lead stated that local was better since it didn't require an internet connection. But, this seems assumed when developing. Which is usually better?
Assume I have a Query - as in CQS that is supposed to return a single value. Let's assume that the case that no value is found is not exceptional, so no exception will be thrown in this case. Instead, null is returned. However, if no value has been found, I need to act according to the reason why no value has been foun...
I’ve got a 2 database tables in parent/child relationship as one-many. I’ve got three classes representing the data in these two tables: Parent Class { Public int ID {get; set;} .. other properties } Child Class { Public int ID {get;set;} Public int ParentID {get; set;} .. other properties } Toget...
What values in an application should be configurable, or otherwise not hard coded? Does this differ based on application type (batch vs UI) and are there any published standards or guidance on this topic (IEEE, ACM, vendor, etc)?
Lately I have been writing a game engine, and I have been writing a lot of "foundation stuff" (standard interfaces, modules, a message system ect.), but I have noticed a pattern, a lot of the stuff is interdependent and I can not debug until everything is done, hence I do not debug for about 3 to 5 hours at a time. I a...
For all you OOD experts. What would be the recommended way to model the following scenario? I have a certain class hierarchy similar to the following one: class Base { ... } class Derived1 : Base { ... } class Derived2 : Base { ... } ... Next, I would like to implement different compression/decompression en...
I have an application that allows users to edit certain parts of text and then email that out. My question is what is the best way to store this in a Microsoft SQL Server database. Right now I have two tables, one holding the HTML data and one holding the plain text data. When the user saves the info, it replaces newli...
How come in C++ when you put: while (expression); the while loop doesn't run no matter if the expression is true or not. However if you put: if (expression); the statement runs no matter if the expression is true or not. It seems like they should both behave the same way.
I previously asked this at stack overflow but it was closed, I believe because 'programmers' is a more appropriate venue for this question. I have done some work on the SVN Importer project (Apache license), which appears to be effectively dead (no published changes in 5 years). I have a login to their svn server but d...
I've inherited a legacy software system, and have been tasked with performing usability and system upgrades. While there's nothing bad with the system, from discussions with the users, there are "small" usabilty issues that need to be addressed. At this stage I'm the lone developer on this system, and apart from testin...
I'm trying to work through how to write this code. def get(params): """ Fetch a user's details, or 404 """ user = User.fetch_by_id(params['id']) if not user: abort(404) # Render some template for the user... What's the best way to handle the case where the lookup fails? One principle says you s...
I understand the concepts of deadlock well enough, but when I'm given a problem like the one below I'm not sure how to go about solving it. I can draw a resource allocation graph, but I'm not sure how to solve it from there. Is there a better more formal way of solving this? Consider a system with five processes, ...
I decided to get my hands wet and got the YII framework for PHP. I created my first application, then created new controller, model and view. Connected to database, got my record passed from controller to the view and printed the hello world. I am confused now. If I have to do the same thing for each page, this seems l...
I'm trying to implement this JavaFX code where I want to call remote Java class and pass boolean flag: final CheckMenuItem toolbarSubMenuNavigation = new CheckMenuItem("Navigation"); toolbarSubMenuNavigation.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e...
Even after reading a bunch I'm still falling into the same trap. I have a class, usually an enity. I need to implement more than one, similar operations on this type. It feels wrong to (seemingly arbitrarily) choose one of these operations to belong inside the entity and push the others out to a separate class; I end u...
I am not really sure how to correctly describe my question, so please forgive me if this is a duplicate. I am creating a flowchart for my program where I implement a method. Let's assume I call this method someMethod. The C code could look something like this: bool someMethod(int Foo, int Bar) { foo += 5; bar -...
It seems apparent that English is the dominant international language for programming based on previous P.SE questions (though a highly upvoted comment correctly points out that asking a question like that on a predominantly English site will skew the results). However, is there benefit in learning a foreign language f...
The question, Stored procedure Naming conventions?, and Joel's excellent Making Wrong Code Look Wrong article come closest to addressing my question, but I'm looking for a more general set of criteria to use in deciding how to name modules containing code (classes, objects, methods, functions, widgets, or whatever). En...
Starting point: I currently do development for Dynamics Ax, Android and an occasional dabble with Wordpress and Python. Soon, I'll start a project involving setting up WP on Google Apps Engine. Everything is, and should continue to, run from the same PC (running Linux Mint). Issue: I'm afraid of botching/bogging ...
If you have a method that doesn't need access to any non public fields, properties or methods where should you put the method ? should it just be a normal method in the class, a static method that takes an instance as a parameter, an extension method or something else ?
I'm asked to refactor my component code to support A/B Testing. What is the better approach: 1) Pass a boolean value to the methods and check for that flag inside the method body? method(flag abTest): if A_VERSION_ENABLED: // Do 'A' logic else // Do 'B' logic 2) Create dedicated methods for...
I want multiple users to edit same document. Problem I'm facing is when a new user joins, he might see an outdated document. How do I make sure that new users get most recent changes? Some solutions I thought of: Save on every change. I don't like this solution because it will slow things down on UI and put load on ...
I am putting this question to C++ programmers because: a) Only a C++ programmer can judge the technical merits of the examples; b) Only a programmer will have a feel for the temperament of another programmer who writes code like this. HR and the directors are aware there is a problem simply because they see evidence in...
Sockets were invented in Berkeley around 1983, but how did networked computer programs work before this? These days, pretty much everything uses sockets, so it's hard for me to imagine how else programs could communicate and Google turned up nothing.
I created a library that is a invoker for a web service somewhere else. The library exposes asynchronous methods, since web service calls are a good candidate for that matter. At the beginning everything was just fine, I had methods with easy to understand operations in a CRUD fashion, since the library is a kind of re...
Assume a simple class that implements the Tester/Doer pattern: public class FooCommandHandler : ICommandHandler { public bool CanHandle(object command) { return command is FooCommand; } public void Handle(object command) { var fooCommand = (FooCommand)command; // Do somethin...