language-agnostic

How would you tackle the netflix prize?

So, I'm just stabbing into the wild. I'm really not much of a data-miner. I ask out of pure interest because I really won't have time to try taking part in this contest. But just for the fun of it, how would you tackle it? It works something like this: You get a really large set of movie IDs and user votes. Now given a few votes by so...

Recursion for user input - elegant or strange?

Dev-cpp comes with an example program Jackpot, which has a GetResults function in it: void GetResults () { . . . else if (i>j) { cout << "Too BIG\n"; life = life - 1; // -1 to the user's "life" cout << "Number of remaining life: " << life << "\n\n"; GetResults(); } Is this an...

Where is the best place to put the constant on a condition?

Where is the best place to put the constant in a condition? Left side or Right side? I personally use in the right side: if($value > 23) { } ...

Displaying messages on form success page

Assume you have page A which is the "home" page for the web app. Assume there is a second page B which contains a form. After successfully processing the form the user is directed back to page A. If you need to display a success message for the previous action (the successful form submission), what is the best way to get that message ...

UI Databinding: alternatives and future

UI Databinding aka transfer of information/data from the biz-layer/datamodel of an application to the UI and from the UI back to the datamodel, seams to be ignored a little by language and framework designers. Almost all information processed by software systems today has to be presented at some point of the processing chain to human u...

Win32: Is it possible to build an app that houses other apps?

I was wondering, how would you go about writing an application that basically houses other applications inside of it? The reason I ask is that I'd love to build an app that 'conquers' my current explosion of open windows. I've used virtual window managers before and they're nice and all, but I could do so many things with an app like I...

Hash Code and Checksum - what's the difference?

My understanding is that a hash code and checksum are similar things - a numeric value, computed for a block of data, that is relatively unique. i.e. The probability of two blocks of data yielding the same numeric hash/checksum value is low enough that it can be ignored for the purposes of the application. So do we have two words for t...

How do you check if a domain name exists ?

Not only easy ones like .com or .net, but also, .co.uk, .fr, .gov.rw ... ? Should I really make a huge mapping "tld to relevant whois server", or is there an easier way ? ...

Am I immoral for using a variable name that differs from its type only by case?

For instance, take this piece of code: var person = new Person(); or for you Pythonistas: person = Person() I'm told constantly how bad this is, but have yet to see an example of the immorality of these two lines of code. To me, person is a Person and trying to give it another name is a waste of time. I suppose in the days before...

stopping code rot

Given that working features are better value for a company than good code at any given point in time and that bad code makes adding more features difficult: How do you stop the code from deteriorating over time? At any point, getting a feature to work is higher priority than getting it to work with well engineered code which takes lon...

Code Smell? - Adjusting variables with +- 1

I just wrote this method: private String getNameOfFileFrom(String path) { int indexOfLastSeparator = path.lastIndexOf('/'); if (indexOfLastSeparator > -1) { return path.substring(indexOfLastSeparator + 1); } else { return path; } } The line that bothers me is: return path.substring(indexOfLastSeparator + 1); Is that a ba...

Number of trits matching count criteria

For all trinary numbers with length 36 (including those starting with 0's), how many have exactly equal counts of 1's and 2's, or exactly one more 1 than 2? For example: 00 - yes 01 - yes 02 - no 10 - yes 11 - no 12 - yes 20 - no 21 - yes 22 - no So for all trinary numbers of length 2, 5 out of 9 possibilities match. This presumabl...

New project: whose responsibility is it to create tasks/tickets in the issue management system?

I'd like to know whose responsibility in the team it is to take the spec (produced by the business analysts) and itemize it (tickets and sub-tasks) in the issue management system (e.g. JIRA) (for the perusal of the developers). I have a feeling it depends on your project management method of choice (e.g. PRINCE2) and/or team size, but p...

Detecting single one-bit streams within an integer

I have to check a number if it satisfies the following criteria: in binary, all one-bits must be successive. the number must have at least one bit set. the successive one-bits may start at the MSB or end at the LSB, so it's perfectly valid if the number is made up of a single one-bit stream followed by a zero-bit stream or vice versa....

In-Place Radix Sort

This is a long text. Please bear with me. Boiled down, the question is: does someone know a workable in-place radix sort algorithm? Preliminary I've got a huge number of small fixed-length strings that only use the letters “A”, “C”, “G” and “T” (yes, you've guessed it: DNA) that I want to sort. At the moment, I use std::sort which u...

What are some good tools and strategies for multi-platform development?

Background: People often ask what is the best "developers toolkit" to use for a specific platform. The problem with this common question is it assumes the luxury of finding a set of tools for a single platform (viz. Windows, Linux or Mac). It doesn't address the people out there on the fringes who have to work routinely on "all of the a...

Python VS PHP, Differences?

I'm already proficient in PHP and Javascript, but for a project a client is insisting that it be done in Python instead. Its a good opportunity, so I've agreed to learn Python. My questions are: How easy/hard will it be to build AJAX powered web applications in Python compared to PHP what are the main differences in the two languages...

When to use and not to use each development paradigm?

Given the various methodical approaches to development, can we get some heuristics together on which ones are appropriate in what circumstances, e.g. case-driven development model-driven development behavior-driven development test-driven development Rational Unified Process Jackson Structured Design et al No method is too old, speci...

Generating shuffled range using a PRNG rather than shuffling

Is there any known algorithm that can generate a shuffled range [0..n) in linear time and constant space (when output produced iteratively), given an arbitrary seed value? Assume n may be large, e.g. in the many millions, so a requirement to potentially produce every possible permutation is not required, not least because it's infeasibl...

Class member order in source code.

This has been asked before (question no. 308581), but that particular question and the answers are a bit C++ specific and a lot of things there are not really relevant in languages like Java or C#. The thing is, that even after refactorization, I find that there is a bit of mess in my source code files. I mean, the function bodies are a...