language-agnostic

Why is Google's "face recognition" feature available only in Picasa WEB and not Picasa for the PC?

I friend asked me this today. Picasa Web has a cool (and frightening :-) feature where it will recognize all the faces in your photo album. But the PC (desktop) version doesn't have this. Several reasons I can think of: They just haven't gotten around to writing the PC version of the code. They are licensing that feature and it cost...

Eliminating coupling out of classes that have strong conceptual bonds with each other

I have the types Rock, Paper, and Scissors. These are components, or "hands" of the Rock, Paper, Scissors game. Given two players' hands the game must decide who wins. How do I solve the problem of storing this chain chart without coupling the various hands to each other? The goal is to allow adding a new hand to the game (Jon Ske...

What does it mean to "program to an interface"?

Hi, I have seen this mentioned a few times and I am not totally clear on what it means. When and why would you do this? I know what interfaces do, but the fact I am not clear on this makes me think I am missing out on using them correctly. Is it just so if you were to do: IInterface classRef = new ObjectWhatever() You could use ...

What are the best programmatic security controls and design patterns?

There's a lot of security advice out there to tell programmers what not to do. What in your opinion are the best practices that should be followed when coding for good security? Please add your suggested security control / design pattern below. Suggested format is a bold headline summarising the idea, followed by a description and examp...

What is the best way to measure "lines-of-code"?

Duplicate of http://stackoverflow.com/questions/353380/what-is-a-line-of-code Should you count end-lines? Should you base it on delimiters in your language, such as semi-colons? Should you count all non-whitespace characters then divide by the average number of non-whitespace character per line? Maybe the concept of "lines" isn't even ...

What was the most stupid bug you could not find for a long time?

I was working on a project that missbehaved, for some reasons no exception was thrown even when it should have. Deep down I have found this kind of error handling: try { m.invoke(parentObject, paramObj); } catch (IllegalArgumentException e) { new CaseLibException(e); } catch (IllegalAccessException e) { new CaseLibException(...

Prototype based object orientation. The good, the bad and the ugly?

Hello, I come from classes object orientation languages and recently I have been learning those fancy dynamic languages (JavaScript, Python and Lua) and I want some tips about how to use OO in those languages. It would be useful to know the pitfalls and the shortcomings of such approach and the advantages compared to traditional OO. The...

The "You're Doing It Wrong!!" feeling

NB - This question is not a stab at RoR or at Redmine's plugin system I have been working on a custom plugin for Redmine, a project manager platform built with Ruby on Rails (RoR). Now I am not really a RoR or for that matter, a Ruby guy. I have managed to write the plugin and everything works, despite being a mess behind the scenes...

What language(s) for very large lists?

Java (and maybe the underlying C-ish code) has max capacity of Integer.MAX_VALUE (~ 2 billion) for arrays and containers in java.util. Are there other languages that feature containers with larger capacities? ...

Good programming website like Stack Overflow?

What other good collaborative programming/software development/engineering websites do you know of? I'm not looking for language or platform specific websites. Nor am I looking for something similar to the format of Stack Overflow. My main criteria is that the community is knowledgeable, helpful active friendly I know the question i...

Rosetta Stone: Lambda expressions

How are anonymous functions/lambda expressions expressed in various programming languages? Are the syntax and semantics especially useful or not useful in that language? Are there any programming languages for which true anonymous functions aren't possible? Like other Rosetta Stone questions, responses should start with the name of th...

What is Map/Reduce

I hear a lot of noise about map/reduce, esp in the context of Google's massively parallel compute system. What exactly is it, and why is it "cool"? ...

Validating Kana Input

I am working on an application that allows users to input Japanese language characters. I am trying to come up with a way to determine whether the user's input is a Japanese kana (hiragana, katakana, or kanji). There are certain fields in the application where entering Latin text would be inappropriate and I need a way to limit certain ...

How to deal with exceptions

My technical lead insists on this exception mechanism: try { DoSth(); } catch (OurException) { throw; } catch (Exception ex) { Util.Log(ex.Message, "1242"); // 1242 is unique to this catch block throw new OurException(ex); } 1242 here is an identifier of the catch method which we handle an exception other than OurExcep...

While vs. Do While

I've seen both the blocks of code in use several different times, personally I have always used the first but my question is: is there a functional difference, and if there is what is it? while (condition is true ) { // do something } do { // do something } while ( condition is true); I will be applying this to PHP but I assu...

Are comments necessary for a programming language?

After some stupid musings about Klingon languages, that came from this post I began a silly hobby project creating a Klingon programming language that compiles to Lua byte-code. During the initial language design phase I looked up information about Klingon programmers, and found out about this Klingon programming rule: A TRUE Klingon...

How to test a hash function?

Is there a way to test the quality of a hash function? I want to have a good spread when used in the hash table, and it would be great if this is verifyable in a unit test. EDIT: For clarification, my problem was that I have used long values in Java in such a way that the first 32 bit encoded an ID and the second 32 bit encoded another ...

Arrays, what's the point?

As I'm programming I haven't seen an instance where an array is better for storing information than another form thereof. I had indeed figured the added "features" in programming languages had improved upon this and by that replaced them. I see now that they aren't replaced but rather given new life, so to speak. So, basically, what's ...

Code Golf Christmas Edition: How to print out a Christmas tree of height N

Given a number N, how can I print out a Christmas tree of height N using the least number of code characters? N is assumed constrained to a min val of 3, and a max val of 30 (bounds and error checking are not necessary). N is given as the one and only command line argument to your program or script. All languages appreciated, if you s...

Defend zero-based arrays

A question asked here recently reminded me of a debate I had not long ago with a fellow programmer. Basically he argued that zero-based arrays should be replaced by one-based arrays since arrays being zero based is an implementation detail that originates from the way arrays and pointers and computer hardware work, but these sort of stuf...