language-agnostic

Grand Central vs Parallel Extensions

Does anyone know of any good websites on the upcoming "Grand Central" technology from Apple (in Snow Leopard) and how it compares to the Parallel Extensions (and the native parallel computing stuff) coming from Microsoft? ...

What is the best way to replace or substitute if..else if..else trees in programs?

This question is motivated by something I've lately started to see a bit too often, the if..else if..else structure. While it's simple and has its uses, something about it keeps telling me again and again that it could be substituted with something that's more fine-grained, elegant and just generally easier to keep up-to-date. To be as ...

How can Polymorphism replace an if-else statement inside of a loop?

How can polymorphism replace an if-else statement or Switch inside of a loop? In particular can it always replace an if-else? Most of the if-thens I use inside of loops are arithmetic comparisons. This question is spawned from this question. int x; int y; int z; while (x > y) { if (x < z) { x = z; } } How woul...

Is it better to go broad or go deep?

This is a rather general question about how best to further yourself as a programmer both professionally and personally. As good Pragmatic Programmers, we have been taught that continual learning and self-improvement are things that we should consider a natural part of our lives as technologists. Part of this process is keeping abreast...

The most unconventional code you've written?

What code have you written where you were forced to break conventions? You know you were going against best practices but there just seemed no other way around it. What was that code and what made you do it? ...

When working with domain models and POCO classes, where do queries go?

I am new to domain models, POCO and DDD, so I am still trying to get my head around a few ideas. One of the things I could not figure out yet is how to keep my domain models simple and storage-agnostic but still capable of performing some queries over its data in a rich way. For instance, suppose that I have an entity Order that has a ...

What's the best name for a non-mutating "add" method on an immutable collection?

Sorry for the waffly title - if I could come up with a concise title, I wouldn't have to ask the question. Suppose I have an immutable list type. It has an operation Foo(x) which returns a new immutable list with the specified argument as an extra element at the end. So to build up a list of strings with values "Hello", "immutable", "wo...

Testing the rendering speed of IE on a specific page

If my goal is to test the rendering speed in IE of a specific web page through repeated loads (merely using a javascript onload event for timing and viewing the page doesn't cut it), what would be a good way to do it? My current attempt was by using the IE WebBrowser object in VB and C#, though I'm open to other suggestions. Below is s...

Semantic Diff Utilities

I'm trying to find some good examples of semantic diff/merge utilities. The traditional paradigm of comparing source code files works by comparing lines and characters.. but are there any utilities out there (for any language) that actually consider the structure of code when comparing files? For example, existing diff programs will re...

Methods for storing metadata associated with individual files?

Given a collection of files which will have associated metadata, what are the recommended methods for storing this metadata? Some files formats support storing metadata internally (EXIF,ID3,etc), but not all file formats support this, so what are more general options? Some of the metadata would almost certainly be unique (titles/descri...

Do programmers peak?

Athletes often peak in their early twenties, this can be later depending on the sport. In some cases experience can offset the slowness and tiredness which comes with age but only up to a point. Mentally we also slow down a little with age, although keeping an active mind can help this. Is there a time where age affects your ability t...

Should Tuples Subclass Each Other?

Given a set of tuple classes in an OOP language: Pair, Triple and Quad, should Triple subclass Pair, and Quad subclass Triple? The issue, as I see it, is whether a Triple should be substitutable as a Pair, and likewise Quad for Triple or Pair. Whether Triple is also a Pair and Quad is also a Triple and a Pair. In one context, such a r...

Is it possible to run "native" code on top of a managed OS?

I was reading up on Midori and kinda started wondering if this is possible. On a managed OS, "managed code" is going to be native, and "native code" is going to be...alien? Is it possible, at least theoretically, to run the native code of today on a managed OS? ...

Can any algorithmic problem be solved in a purely functional way?

I've been contemplating programming language designs, and from the definition of Declarative Programming on Wikipedia: This is in contrast from imperative programming, which requires a detailed description of the algorithm to be run. and further down: ... Any style of programming that is not imperative. ... It then goes on to...

Developing to an interface with TDD

I'm a big fan of TDD and use it for the vast majority of my development these days. One situation I run into somewhat frequently, though, and have never found what I thought was a "good" answer for, is something like the following (contrived) example. Suppose I have an interface, like this (writing in Java, but really, this applies to ...

What are some good strategies to fix bugs as code becomes more complex?

I'm "just" a hobbyist programmer, but I find that as my programs get longer and longer the bugs get more annoying--and harder to track. Just when everything seems to be running smoothly, some new problem will appear, seemingly spontaneously. It may take me a long time to figure out what caused the problem. Other times I'll add a line of ...

Document key ingredients of good software development?

I am writing an architecture and design document for software development at our company, that will contain the rules and guidelines for developers to follow. It is targeted at J2EE web applications, but I constantly keep mentioning the same basic 'ingredients' (for lack of a better word, and to avoid buzzwords) to introduce and defend c...

Calculating future occurences of Friday the 13th

I'd like to be able to start with a year, and calculate occurrences of Friday the 13th. A brute force solution is easy and obvious. I have something slightly better, but I have no doubt that someone else can come up with an elegant algorithm for this. Perhaps a little trickier, I'd be interested in giving the program a month, and have...

Getting infinite session on Facebook

Please help me out in getting infinite session on facebook. I am getting a session logged out or invalid session key while testing my application.Does this infinite session apply to anyone who logs in? ...

Improving Code Readability

When it comes to code documentation, it is usually accepted that code should explain itself, and inline code documentation (excluding public API documentation) should only explain meta-code issues such as workarounds, explanations on why specific implementations were chosen, etc. How do you accomplish making your code more readable and ...