language-agnostic

Skip List vs. Binary Tree

I recently came across the data structure known as a Skip list. They seem to have very similar behavior to a binary search tree... my question is - why would you ever want to use a skip list over a binary search tree? ...

What's the best example of a "naive implementation"?

What is the clearest explanation of what computer scientists mean by "the naive implementation"? I need a good clear example which will illustrate -- ideally, even to non-technical people -- that the naive implementation may technically be a functioning solution to the problem, but practically be utterly unusable. ...

Should carriage return \r and new line \n always be used together? \r\n

In JavaScript this was a cross-browser compatibility issue, so both were used, but there are numerous instances in different languages where I see both printed out together as \r\n. Is this still the generally excepted norm that you should just always use both, or is there ever a time where languages understand both and you end up with a...

How to unit test complex methods

I have a method that, given an angle for North and an angle for a bearing, returns a compass point value from 8 possible values (North, NorthEast, East, etc.). I want to create a unit test that gives decent coverage of this method, providing different values for North and Bearing to ensure I have adequate coverage to give me confidence t...

What model should I use for a browser-based game?

As a hobby project I am currently trying to create a small browser-based game - and I thought it would be the "right thing" to code it using the MVC pattern, separating the game's "engine" from presentation. It would be a simple "rpg" game, where the player's character wander the world fighting monsters and gathering items. My problem i...

Anemic Domain Model: Pros/Cons

I would like to know what the pros and cons are for using an Anemic Domain Model (see link below). Fowler Article ...

Explaining nested arrays to a programmer

How have you explained nested arrays to a programmer. I'm thinking someone that has an entry level understanding of programming, but is trying to do more complicated coding. The array with array works, but they can't quite get their mind around the idea. Edit: example of a nested array: array( 'array1' => array( 'key1' => ...

What is Type-safe?

What does "type-safe" mean? ...

GPRS communication Microcontroller

What are all AT commands required for GPRS communication? ...

Using "friend"-declarations for unit testing. Bad idea?

[Of course, the question is not restricted to a specific "friend" implementation, feel free though to point out implementation specifics if relevant] Reading through the unanswered questions, I stumbled upon the InternalsVisibleTo attribute: Specifies that types that are ordinarily visible only within the current assembly are vi...

Help me write a binary search for boundary values (extracting sub lists)

Let's say I have an array of lots of values (C++ syntax, sorry): vector<double> x(100000); This array is sorted such that x[n] > x[n-1]. I would like a function to retrieve an array of all values in the range [a, b] (that's inclusive). Some interface like: void subarray(const double a, const double b, vector<double> &sub) { ... ...

What is meant by "thread-safe" code?

Does it mean that two threads can't change the undelying data simultaneously? or does it mean that the given code component will run with unpredictable results when more than one thread are running it? ...

Drawing a Topographical Map

I've been working on a visualization project for 2-dimensional continuous data. It's the kind of thing you could use to study elevation data or temperature patterns on a 2D map. At its core, it's really a way of flattening 3-dimensions into two-dimensions-plus-color. In my particular field of study, I'm not actually working with geograph...

As a programmer how broad does your knowledge have to be ?

I am pretty focused on software, I try to keep up with all the new stuff that comes out and like a lot of other people I have a hard (but fun :) ) time keeping up. Still I believe you need to keep up so you know the best possible solutions for many problems. Lately I have gotten more and more into discussions on levels I just don't know...

Does any one know of a free/open source multi-platform program to create flow charts?

Does any one know of a free/open source multi-platform program to create flow charts? It should run on at least Windows, Linux, and Mac OS/X. ...

Spell checking city names?

I figure this problem is easier than just a regular spell checker since the list of U.S cities is small compared to all known English words. Anyhow, here's the problem: I have text files with full of city names; some of which are spelled correctly and some which aren't. What kind of algorithm can I use to correct all the misspellings ...

Can there ever be a "silver bullet" for software development?

I recently read the great article by Fred Brooks, "No Silver Bullet". He argues that there hasn't been a silver bullet that made software devlopment remarkably easier and that there never will be one. His argument is very convincing and I certainly agree with it. What is the stack overflow community's take on it? Is it possible for a ...

Count Duplicate URLs, fastest method possible

Hi Guys, I'm still working with this huge list of URLs, all the help I have received has been great. At the moment I have the list looking like this (17000 URLs though): http://www.domain.com/page?CONTENT_ITEM_ID=1 http://www.domain.com/page?CONTENT_ITEM_ID=3 http://www.domain.com/page?CONTENT_ITEM_ID=2 http://www.domain.com/page?CONT...

What are some exercises you do to make you a better programmer?

Lately, I have taken to programming without a mouse to force myself to become more comfortable with different shortcuts. It's been a good exercise as I feel using shortcuts is essential for productivity . I figured I would ask if anyone else did the same types of things and could recommend other things to help improve my habits. ...

Inheritance vs. Aggregation

There are two schools of thought on how to best extend, enhance, and reuse code in an object-oriented system: Inheritance: extend the functionality of a class by creating a subclass. Override superclass members in the subclasses to provide new functionality. Make methods abstract/virtual to force subclasses to "fill-in-the-blanks" when...