language-agnostic

British English to American English (and vice versa) Converter

Hi, Does anyone know of a library or bit of code that converts British English to American English and vice versa? I don't imagine there's too many differences (some examples that come to mind are doughnut/donut, colour/color, grey/gray, localised/localized) but it would be nice to be able to provide localised site content. ...

How would you organize a timezone dropdown?

I'm trying to present the (web) user with a useful subset of Olson timezones, though with a friendlier naming convention. Any recommendations for how to sort and label them for maximum usefulness? By country? Continent? GMT offset? I'm not very concerned about inaccuracy for past dates, so some of the timezones that are only histori...

Best practice regarding number of threads in GUI applications

In the past I've worked with a number of programmers who have worked exclusively writing GUI applications. And I've been given the impression that they have almost universally minimised the use of multiple threads in their applications. In some cases they seem to have gone to extreme lengths to ensure that they use a single thread. Is ...

Do you leave historical code commented out in classes that you update?

When you need to obsolete a section of code (say either the business rules changed, or the old system has been reworked to use a new framework or something) do you delete it from the file or do you comment it out and then put in the new functionality? If you comment it out, do you leave a note stating why it was removed and what it was ...

Picking a random element from a set

How do I pick a random element from a set? I'm particularly interested in picking a random element from a HashSet or a LinkedHashSet, in Java. Solutions for other languages are also welcome. ...

Formula for controlling the movement of a tank-like vehicle?

Anyone know the formula used to control the movement of a simple tank-like vehicle? To 'steer' it, you need to alter the force applied the left and right "wheels". Eg. 1 unit of force on both wheels makes it go forward. -1 units of force on both wheels makes it go backwards. Apply more force to one wheel than the other and it turns....

Techniques to Get rid of low level Locking

I'm wondering, and in need, of strategies that can be applied to reducing low-level locking. However the catch here is that this is not new code (with tens of thousands of lines of C++ code) for a server application, so I can't just rewrite the whole thing. I fear there might not be a solution to this problem by now (too late). However ...

Is there an alternative to FTP?

I am trying to find an alternative to FTP? It's a single file transfer up to 4gb. Any suggestions? maybe HTTP? Or should I stick it out with FTP? More info - We have an app that we distribute to tens of thousands of clients that upload single large files. FTP has proven to be error prone with a single file of that size. Speed is ...

Should a web app use its own public API to display data?

I'm starting to build a site that as most do, displays data in various ways from a database. I'm building a public REST API as part of this project, and will be designing this in parallel with the main site, as I believe that it's an integral feature. Should the site itself use the public API when retrieving data, or should it use a dif...

Which design is better for a class that simply runs a self-contained computation?

I'm currently working on a class that calculates the difference between two objects. I'm trying to decide what the best design for this class would be. I see two options: 1) Single-use class instance. Takes the objects to diff in the constructor and calculates the diff for that. public class MyObjDiffer { public MyObjDiffer(MyObj ...

What's the first thing you 'trip up on' when learning a new language.

So... You've sat down and got a blank sheet in front of you, and a browser open in the background with access to the manual. What in your opinion makes you scratch your head and think Now how... See also: Easiest language to start with Best ways to teach a beginner to program? ...

How do I find the center of a number of geographic points?

If I have a series of points as longitude and latitude, how would I calculate the center of all of those points? ...

When should I use Debug.Assert()?

I've been a professional software engineer for about a year now, having graduated with a CS degree. I've known about assertions for a while in C++ and C, but had no idea they existed in C# and .NET at all until recently. Our production code contains no asserts whatsoever and my question is this... Should I begin using Asserts in our pr...

How to pass arguments to a constructor in an IOC-framework

How can I pass arguments to a constructor in an IOC-framework? I want to do something like: (Trying to be IOC-framework agnostic ;) ) object objectToLogFor = xxx; container.Resolve<ILogging>(objectToLogFor); public class MyLogging : ILogging { public MyLogging(object objectToLogFor){} } It seems that this is not possible in Stru...

Best rule for maximum function size?

In another question, a popular answer suggested that large functions demonstrate poor form. How large would you let a function get before you broke it up? (This could be in lines of code or a more qualitative answer, your choice. This is probably a language-dependent question to some extent, so you might want to indicate that and how ...

What is a good algorithm for compacting records in a blocked file?

Suppose you have a large file made up of a bunch of fixed size blocks. Each of these blocks contains some number of variable sized records. Each record must fit completely within a single block and then such records by definition are never larger than a full block. Over time, records are added to and deleted from these blocks as records ...

Decoding letters ('a' .. 'z') from a bit sequence without waste

I seek an algorithm that will let me represent an incoming sequence of bits as letters ('a' .. 'z' ), in a minimal matter such that the stream of bits can be regenerated from the letters, without ever holding the entire sequence in memory. That is, given an external bit source (each read returns a practically random bit), and user input...

What is dependency injection?

There have been several questions already posted with specific questions about dependency injection, such as when to use it, what frameworks are there for it. However, here's the newbie question: What is dependency injection and when/why should or shouldn't it be used? Edit: While external links for followup reading are always apprecia...

How do you create tests for "make check" with GNU autotools

I'm using GNU autotools for the build system on a particular project. I want to start writing automated tests for verifcation. I would like to just type "make check" to have it automatically run these. My project is in C++, although I am still curious about writing automated tests for other languages as well. Is this compatible with pre...

How do you document projects you work on?

Where I work, I'm constantly doing development work. We're usually in a position where we're always busy doing development work with no time to write real maintainer documentation. I doubt my position is unique. My question to everyone is, how do you/your development team handle documentation? Do you document as you go? Do you write do...