language-agnostic

How to explain to your mom what an algorithm is?

How do you explain to your mom what an algorithm is? My family is mostly non-technical, and they don't really understand what programming is, or what an algorithm is. I tried the old cooking recipe analogy, but are there better ways to explain what we do and how we think? Update: There are some really good answers so far that explain ...

Graceful degradation - when to consider

When designing and building the UI for an application that uses AJAX, when do you consider graceful degradation (for users who have JavaScript disabled, or are using a screen reader)? At the end, once the AJAX version of the site is completely finished At every stage of development I don't Something else... ...

Is there a SHOULD (or other modal verb) constructs in any programming languages?

As far as I know I've never encountered a SHOULD construct in a computer language, but then again I don't know that many languages, compared to the hundreds out there. Anyways SHOULD and other modal verbs are very common in natural languages, and their meanings are quite clear when writing documentation and legal-binding contracts, so ...

Debugger usage

Do you use the debugger of the language that you work in to step through code to understand what the code is doing, or do you find it easy to look at code written by someone else to figure out what is going on? I am talking about code written in C#, but it could be any language. ...

What's a good approach for developing a simple serial number generator/verifier?

I'm working on an app I'd like to sell some day -- sooner rather than later! I'd like to develop a reasonably simple serial number scheme to protect it. A simple number/letter combination not more than 25-30 alphanumeric characters long (think Microsoft product keys) Does not require the user to enter any personal information (like an ...

Programming Vocabulary

I am getting ready to teach someone without any background in programming a language (PHP) I want to make sure I don't forget any important vocabulary this is what I have so far: Function/Method Variable Class String Integer Boolean Float Static Typing (Not needed for PHP but should be understood.) Dynamic Typing Are there any other...

Which authentication mechanism to choose?

Well, on my free time, I'm making this small web site. The site will not require to authenticate, only some actions (like leaving a comment) will require to do so. I would expect to have up to 100 (probably less) unique visitors a day. I don't really expect more than 50% to (bother to) register. Right now, I'm thinking of three possibl...

Clustering Algorithm for Paper Boys

I need help selecting or creating a clustering algorithm according to certain criteria. Imagine you are managing newspaper delivery persons. You have a set of street addresses, each of which is geocoded. You want to cluster the addresses so that each cluster is assigned to a delivery person. The number of delivery persons, or clusters...

script to map network drive

I want to be able to connect to a (wifi) network hard drive from my laptop, but only occasionally. If I use the "Map a network drive" command in WinXP explorer, I have to put in the drive's IP address and name, then the router name and its password. Too much to remember! I'm looking for a way of scripting this activity (in any language)...

What is "elegant" code?

I see a lot of lip service and talk about the most "elegant" way to do this or that. I think if you spend enough time programming you begin to obtain a sort of intuitive feel for what it is we call "elegance". But I'm curious. Even if we can look at a bit of code, and say instinctively "That's elegant", or "That's messy", I wonder if any...

What to do with XML node names (hard coded values)?

I've been working with xml lately. And have noticed a bit of a phenomenon (maybe not that big of a deal to the rest of the world, but to me it was). Perhaps, it is me being a newb. But shouldn't most hard coded or magic numbers be broken out to a configuration file? For example, string url = "http://www.domain.com/aDocument.xml"...

Data structure that always keeps n-best elements

I need a data structure that always holds the n largest items inserted so far (in no particular order). So, if n is 3, we could have the following session where I insert a few numbers and the content of the container changes: [] // now insert 1 [1] // now insert 0 [1,0] // now insert 4 [1,0,4] // now insert 3 [1,4,3] // now insert 0 ...

To what extent should code try to explain fatal exceptions?

I suspect that all non-trivial software is likely to experience situations where it hits an external problem it cannot work around and thus needs to fail. This might be due to bad configuration, an external server being down, disk full, etc. In these situations, especially if the software is running in non-interactive mode, I expect th...

Unit testing code that does date processing based on today's date

When code processes dates based on the current date, testing should cover edge cases such as leap years as well as the more frequent month and year boundaries. In our code we always get the current date deep down in our classes using DateTime.Now (.NET, in our case). How can you unit test such code? Is this where Dependency Injection ...

Repeated Keyword Value in JSON

On JSON.org the essential data structures that JSON represents are given as A collection of name/value pairs, and An ordered list of values. I have not been able to find anywhere whether a second member having the same name as one already parsed into the current object should (a) throw an exception or (b) replace the existing membe...

How do I distinguish between 'binary' and 'text' files?

This is a duplicate of http://stackoverflow.com/questions/277521/how-to-identify-the-file-content-is-in-ascii-or-binary, but since I don't have the rep, I can't edit that question to improve it. Informally, most of us understand that there are 'binary' files (object files, images, movies, executables, proprietary document formats, etc) ...

Flexible, Solid and Portable Service Discovery

I am looking for a way for clients in a LAN to find all the instances of my server application without any configuration. Instead of hacking something myself, I'd like to use an existing solution. Personally, I need it to be done in Python, but I'd happy to hear about solutions in any other language. So why am I not using avahi or OpenS...

What are the differences between different GUI toolkits and language bindings?

As far as I can tell, all GUI toolkits are basically the same. They all have some sort of base Widget that everything else that can be drawn inherits from. They all have basically the same widgets - Window, Scrollbar, Button, Dialog, FileSelector, DrawingArea, Menu, Container, etc. They all use event driven architecture with a "main lo...

Poor man's authentication algorithm?

Brainstorming request I need an idea for an authentication algorithm with some unusual requirements. The algorithm would be used to verify that the sender of a message is legitimate. Restrictions: The "transport layer" is e-mail the sender ('Alice') is a human being Alice only has access to a web browser and internet access (includi...

Throttling login attempts

(This is in principal a language-agnostic question, though in my case I am using ASP.NET 3.5) I am using the standard ASP.NET login control and would like to implement the following failed login attempt throttling logic. Handle the OnLoginError event and maintain, in Session, a count of failed login attempts When this count gets to [s...