language-agnostic

What are the disadvantages code reuse?

A few years ago, we needed a C++ IPC library for making function calls over TCP. We chose one and used it in our application. After a while, it became clear it didn't provide all functionality we needed. In the next version of our software, we threw the third party IPC library out and replaced it by one we wrote ourselves. From then on, ...

Different types of iterators

Are there other types of iterators? Any links that show different types of iterators? The only one I know is .NET's IEnumerable. Particularly for C#, but all others are welcomed too. ...

Design of listener for multiple events

I'm familiar with standard listeners, esp. in Java. For example, if you have a collection of objects, it might support a set of listeners for different things: CreateListener, ChangeListener, DeleteListener. Each has one method (e.g. objectChange) that is passed a list of affected objects. An app using this collection could register i...

How to avoid flooding a message queue?

I'm working on an application that is divided in a thin client and a server part, communicating over TCP. We frequently let the server make asynchronous calls (notifications) to the client to report state changes. This avoids that the server loses too much time waiting for an acknowledgement of the client. More importantly, it avoids dea...

How do you make testing not boring?

Just as the title said. What ways do you use to test your own code so that it wouldn't be a boring task? Do you use any tool? For my projects, I use a spreadsheet to list all the possible routines i.e. from the basic CRUD and also all the weird routines. i make about 10 routines. I get about 2-3 bugs and sometimes major ones by doing th...

Efficiently get unretrieved message Ids from a POP3 server.

I understand most of the POP3 protocol, but one thing that bothers me is how POP3 clients efficiently get a list of unretrieved message ids from the POP3 server. Many services like Yahoo and Gmail now offer gigs of space and most people (myself included), rarely if ever delete an email message. I'm currently implementing a simple POP3 c...

Should we use foreign-key constraints when persisting Domain Models?

A while ago I had a discussion with my colleagues about the persistence of Domain Models and whether we should enforce foreign-key constraints at the database level. My first reaction was that the very use of a relational database implied the enforcement of such constraints, but some argued that the database should be seen as nothing bu...

What is an idempotent operation?

What is an idempotent operation? ...

most readable programming language to simulate 10,000 chutes and ladders game plays?

I'm wondering what language would be most suitable to simulate the game Chutes and Ladders (Snakes and Ladders in some countries). I'm looking to collect basic stats, like average and standard deviation of game length (in turns), probability of winning based on turn order (who plays first, second, etc.), and anything else of interest you...

What's the difference between "keyword" and "reserved word"?

What's the difference between keyword and reserved word? Fore example in the concepts' proposal one can read the following statement This proposal introduces five new keywords: concept, concept map, where, axiom, and late check. All of these keywords will also be reserved words. ...

How to make these dynamically typed functions type-safe?

Is there any programming language (or type system) in which you could express the following Python-functions in a statically typed and type-safe way (without having to use casts, runtime-checks etc)? #1: # My function - What would its type be? def Apply(x): return x(x) # Example usage print Apply(lambda _: 42) #2: white = None...

2D motion blur solutions

I'm thinking of chucking motion blur into my 2D program, but I doubt the results of my current algorithm. My approach looks like this at the moment: Draw to backbuffer. When time to update front buffer, blend the backbuffer onto the front buffer. Repeat What would cause the "motion blur" effect is obviously the blending, as objects...

Should a TDD test always fail first?

As a followon to the discussion in the comments of this answer, should a TDD test always be made fail first? Consider the following example. If I am writing an implementation of LinkedHashSet and one test tests that after inserting a duplicate, the original is in the same iteration order as before the insert, I might want to add a separ...

Moving Objects in Center-of-Mass Viewport

I'm modeling a force-based physics simulation where several particles are interacting with each other. The particles can move in such a way that a static viewport can easily lose track of them (imagine the whole group of particles moving off the screen to the right and the viewport displaying a blank background). My current solution is...

Choosing a name for an open source library

How important it is that a Google search for the name will return no result? If the library is written in Java and a search for 'java libname' returns 10,000s results, does it mean you should try harder and find a name that's availble? ...

Exceptions and Abstractions

When should you throw a custom exception? e.g. I have some code that connects to a server. The code that connects to the server throws an IOException when it fails to connect. In the context of the method it's called, this is fine. It's also fine in the network code. But as this represents not having a connection (and therefore not wor...

What's the best way to strip leading / trailing digits from a number?

If I have a number like 12345, and I want an output of 2345, is there a mathematical algorithm that does this? The hack in me wants to convert the number to a string, and substring it. I know this will work, but I'm sure there has to be a better way, and Google is failing me. Likewise, for 12345, if I want 1234, is there another algor...

Is it possible to pass a variable's name along with the value, when passing through functions?

I want to know if it's possible to retrieve the variables name from when it was passed into a certain function. For example, if I call parseId(myId) to a function with the signature parseId(id), i can obviously retrieve the value of 'id'. However, is there any way I can retrieve 'myId' as a string (without passing it as another value)?...

How do you interpret the results from shootout.alioth.debian.org?

A lot of people talk about the performance comparison of some languages by referring to the tests on shootout.alioth.debian.org . The thing is, I don't know how to read the results. The image seems incomprehensible, as I can't seem to find a NORMAL legend. Can you explain one of the tests, with a image? Choose whatever languages you want...

What programming practice that you once liked have you since changed your mind about?

As we program, we all develop practices and patterns that we use and rely on. However, over time, as our understanding, maturity, and even technology usage changes, we come to realize that some practices that we once thought were great are not (or no longer apply). An example of a practice I once used quite often, but have in recent yea...