language-agnostic

What is a sensible maximum number of characters per line of code?

Everybody's screen size and font are different, so while my code fits on my screen, it might scroll off the right edge of your screen. What should be the maximum length of a line of code? ...

How do you prefer to organize exception definitions?

I almost feel embarrassed to ask, but I always struggle with how to organize exception definitions. The three ways I've done this before are: Use the file-per-class rule. I'm not crazy about this because it either clutters up my directory structure and namespaces. I could organize them into subdirectories and segment namespaces for ...

Loop termination conditions

These for-loops are among the first basic examples of formal correctness proofs of algorithms. They have different but equivalent termination conditions: 1 for ( int i = 0; i != N; ++i ) 2 for ( int i = 0; i < N; ++i ) The difference becomes clear in the postconditions: The first one gives the strong guarantee that i == N after...

What should every programmer know?

Regardless of programming language(s) or operating system(s) used or the environment they develop for, what should every programmer know? Some background: I'm interested in becoming the best programmer I can. As part of this process I'm trying to understand what I don't know and would benefit me a lot if I did. While there are loads ...

The best Tail GUI

What is the one single best GUI program for tailing log files you've come across? ...

What are the good, bad, and ugly about the web framework(s) that you use?

What web frameworks do you use, and what's good about them? What would you like to see changed? What made you switch away from The Framework You Don't Use Anymore? ...

How would you sort 1 million 32-bit integers in 2MB of RAM?

Please, provide code examples in a language of your choice. Update: No constraints set on external storage. Example: Integers are received/sent via network. There is a sufficient space on local disk for intermediate results. ...

Most common examples of misuse of singleton class

When should you NOT use a singleton class although it might be very tempting to do so? It would be very nice if we had a list of most common instances of 'singletonitis' that we should take care to avoid. ...

A StringToken Parser which gives Google Search style "Did you mean:" Suggestions

Seeking a method to: Take whitespace separated tokens in a String; return a suggested Word ie: Google Search can take "fonetic wrd nterpreterr", and atop of the result page it shows "Did you mean: phonetic word interpreter" A solution in any of the C* languages or Java would be preferred. Are there any existing Open Libraries which...

Put a process in a sandbox where it can do least harm

I'm looking for the concept to spawn a process such that: it has only access to certain libraries/APIs it cannot acess the file system or only specific parts it can do least harm should malicious code run in it This concept is known as sandbox or jail. It is required to do this for each major Operating system (Windows, MacOSX and Li...

How do I tell if I can re-use a 'free' software library in a commercial app?

Whats the easiest way, of telling if I can redistribute it in a piece of commercial software? In license agreements I often read the terms GPL, OpenSource, Freeware, Artistic License but have never got a definitive answer on what the differences are. ...

What are hashtables and hashmaps and their typical use cases?

I have recently run across these terms few times but I am quite confused how they work and when they are usualy implemented? ...

Can Regex be used for this particular string manipulation?

I need to replace character (say) x with character (say) P in a string, but only if it is contained in a quoted substring. An example makes it clearer: axbx'cxdxe'fxgh'ixj'k -> axbx'cPdPe'fxgh'iPj'k Let's assume, for the sake of simplicity, that quotes always come in pairs. The obvious way is to just process the string one characte...

When writing XML, is it better to hand write it, or to use a generator such as simpleXML in PHP?

I have normally hand written xml like this: <tag><?= $value ?></tag> Having found tools such as simpleXML, should I be using those instead? What's the advantage of doing it using a tool like that? ...

Humor in code

When you are writing code or naming products, which sources of cultural references are you most likely to draw from? Which reference sources do you think are more likely to be universally understood? For example when findbugs sees that you've implemented equals() without overriding hashCode() it suggest that you implement it by returni...

Buying a machine for continuous integration - key factors?

I'm planning to propose to my (very small) company that we buy a computer to run continous integration on. If they say yes, the task of actually buying the machine will probably fall on me, so my question is: What do I look for in a computer that will be used for continuous integration for a very small (3 people) php team? What "stuff"...

What is the best way of storing time?

What is the best way to store time ? There seem to be a lot of ways to handle this. Wikipedia has a listing, but most of them are epoch based. What if you were an archaeologist and wanted to store a date in your program? ...

Querying XML like SQL?

Is there any framework for querying XML SQL Syntax, I seriously tire of iterating through node lists. Or is this just wishful thinking (if not idiotic) and certainly not possible since XML isn't a relational database? ...

How can a transform a polynomial to another coordinate system?

Using assorted matrix math, I've solved a system of equations resulting in coefficients for a polynomial of degree 'n' Ax^(n-1) + Bx^(n-2) + ... + Z I then evaulate the polynomial over a given x range, essentially I'm rendering the polynomial curve. Now here's the catch. I've done this work in one coordinate system we'll call "data sp...

Solving the NP-complete problem in XKCD

The problem/comic in question: http://xkcd.com/287/ I'm not sure this is the best way to do it, but here's what I've come up with so far. I'm using CFML, but it should be readable by anyone. <cffunction name="testCombo" returntype="boolean"> <cfargument name="currentCombo" type="string" required="true" /> <cfargument name="cu...