« December 2005 | January 2006 Archives | February 2006 »

Programming by contract in C++

| 0 Comments
There's the first part of what I expect to be a very nice article about programming by contract in C++ over at The C++ Source: The Nuclear Reactor and the Deep Space Probe. Updated 3rd Jan 2006 - the article now appears to be called Contract Programming 101.…

C++ Tips: 1 - Avoid unnecessary optionality

| 7 Comments
One of my main aims when writing code in C++ is to have the code clearly communicate its purpose. I find it useful to be able to look at a single line in isolation and have a pretty good idea of what its effects are on the code that it cooperates with. Unfortunately C++ code can often be written in an imprecise way that makes reasoning about what it actually does harder than it needs to be. By increasing the precision of your code writing you can limit what the code could potentially do to just what you want it…
When designing code it's often easy to include undefined behaviour. The need for code that exhibits this kind of behaviour is, however, generally pretty rare and there are often ways around allowing undefined behaviour. In general it's usually best to try to avoid undefined behaviour and instead be clear about exactly what happens under all usage conditions.…

C++ Tips: 3 - Strive to be const correct

| 0 Comments
Another extremely powerful tool that you can use to ensure that your C++ code communicates as clearly as possible is const. By correctly using const all the time when designing your abstractions you can divide an object's interface into two smaller, easier to understand interfaces; one which does change the object's internal state and one which doesn't. By correctly using const all the time when defining constants and variables you can clearly communicate which are which. Strive to be const correct.…

LEGO Mindstorms NXT

| 0 Comments
LEGO has announced a new version of their Mindstorms autonomous robot building system. I did a fair amount of playing around with the original Mindstorms kit way back when and created a system that allowed you to control your robots over a NetMeeting connection. The new Mindstorms NXT system sounds pretty cool. I like the idea of being able to use bluetooth to control and download programs to the robots and the new sensors sound much more complex than the old stuff. Via GoRobotics.net.…

iTech Bluetooth Virtual Keyboard

| 2 Comments
I recently purchased an iTech Bluetooth Virtual Keyboard for use with Michelle's PDA. It's basically a little box that's about the size of two packets of chewing gum with a red window in the top. It projects a keyboard onto a flat surface and detects when you press the keys. It's one of those devices that looks too cool to work, but it does, kinda... Unfortunately there were driver problems with the iPaq 4150 that meant that it would work for around 20 keypresses and then stop, reset itself, reconnect and then start working again... At first I thought that…
In the fight to make C++ code easier to reason about and understand, never underestimate the value of a name. Giving something a decent name is the first step in thinking about the concept at a slightly more abstract level. Abstraction is all about selective forgetfulness, by grouping together several related program elements, defining a concept and giving that concept a name you can, from then on, choose to work at the level of the name rather than the detail. This has a marvellous effect on the amount of information that you can hold in your head at the same…

Grumpy old men

| 0 Comments
Am I a curmudgeon of technology? You betcha - Ted Neward over at "The Blog Ride" explains why he's cynical about new technology and suggests that we'd do well to have a little more cynicism. I agree with him, I tend to take a similar position having been let down by various "silver bullets" in the past. I think I decided that it was my time spent working with OLE DB providers that caused me to be more cynical towards the Microsoft technology hype machine; When someone brings me a "cool" new technology and claims that because simple things are…

Implicit Interfaces

| 0 Comments
ImplicitInterfaceImplementation - from Martin Fowler is an interesting piece where Martin suggests that it would be useful to be able to provide alternative implementations of a class's implicit interface. That is, given a class that does not inherit from an interface, it's sometimes useful to be able to split the class into an implicit interface, the public operations that it provides, and treat that as if it were explicitly declared as an interface from which the class derives. This would be useful in testing as it would allow you to mock up things that are currently difficult to mock up.…
Beware! The rules for when a destructor is called for a managed C++ class in Visual C++ are different than for "normal" C++ class.…

Now I'm confused (C++/CLI destructors)

| 2 Comments
So here I am, writing a piece about how the C++/CLI destructor and finalizer stuff could have been a bit neater and I put together some sample code to demonstrate my point and it doesn't do what the docs I mentioned yesterday suggest that it should do...…

Detecting the Excel Function Wizard

| 0 Comments
I'm currently working on some C++ Excel addins for an investment bank. I originally wrote the addins for them back in 2001 and they've evolved slowly ever since. Right now we're adding some new functionality and, whilst testing some of the new functions in the test sheets, I noticed that the functions weren't behaving themselves properly when the Excel Function Wizard was in use...…

Beware the momentum of prototype code

| 4 Comments
A while back Chris Baus wrote a little rant about prototypes. I started to write a piece that defended prototypes when correctly used and ran out of steam; or, more to the point, couldn't really say very much except they're OK except when they're not, try not to get to the point where they're not. Having just recently been bitten by a prototype that was trying to rise above its station, I now have more to say.…

Excel addins sharing data

| 0 Comments
Or, marvelling at my own, past, cleverness. I've been doing a lot of work on these Excel addins for my current client and, as I get back into the whole C++ XLL stuff, I start to realise just how cool my child of 2001 really is.…

Online autism "test"

| 9 Comments
I scored a 28, which is "above average", so considerably nearer to Asperger's than it is considered to be "normal". Which, to be honest, seems about right to me. If nothing else, it might make you think... Via Steve Pavlina's personal development blog.…
If you're into writing C/C++ XLL addins for Excel and you'd like to help make sure that the new features in the new XLL interface provide all the functionality that you'd like, then it might be an idea for you to get in touch with David Gainer via the contact form on his Excel 12 blog.…

So that's what it's called

| 0 Comments
Jeremy D. Miller points out that my 'second' style of coding (see here) is called writing a "spike" in XP terms.…

A collection of links

| 0 Comments
Once again I've been too busy to comment on the following blog postings in a timely manner so here's a collection of stuff that's been sitting in my "good stuff" list for a while now.…

Purecall

| 2 Comments
I've been plugging away at my multi-process Win32 debugger code this week and one of my test harnesses had started to suffer from intermittent "R6025 - pure virtual function call" errors. These tend to crop up if you call a virtual function from a constructor or destructor or if there's a race condition between calling a method on an object from one thread and destroying the object in another thread. For me, at least, they tend to be simple mistakes to fix once I know where the problem lies. Unfortunately, often the standard error report of a "purecall" is less…

First tracks

| 0 Comments
Last week I managed to get my GPS code to download the GPS "track" from my device and create an html file that uses the Google Maps API to display it as an overlay. I spent some time trying to get the map to display correctly from within the normal blog pages but something was causing Internet Explorer to fail to display the tracks. Firefox and Opera were fine; I guess it's something to do with IE using VRML to display the track and the others using a server-side generated graphical overlay. Anyway, the file is here.…

When your mocks are executable

| 0 Comments
The size of the "units" that I test with my unit tests varies quite considerably. Usually I tend to work at the single class level; the test will provide mocks for the services that the class requires and the tests will ensure that the class behaves correctly and interacts as expected with the its service providers. Sometimes though the units consist of a whole subsystem, still often a single class, but one which wires up and collects many other classes into a single component; again the service providers that it uses may be mocked but they're often only right on…

The best toys always come with an SDK, 2

| 0 Comments
I finally got around to upgrading my mobile phone from an aging Sony Ericsson T68i to a more current (though still hardly bleeding edge) Motorola Razr V3. I'm not interested in the downloadable java games but the fact that you can get a J2ME SDK for it and that the docs seem to imply that you can access the GPRS network using SSL and that you can also access the serial port makes it interesting... Now I just need a hack to be able to somehow connect the Garmin GPS to the V3 and some code to grab the location…

Charles Petzold on why he loves books

| 0 Comments
Charles Petzold confesses his love for books. I must admit this bit really hit home for me: "I love how my books remind me of passages in my life. I love the shelves of authors I've been obsessed with, and the books that knocked me over. I love knowing that I still own virtually every book I've read." I have shelves and shelves of technical books as I've always been quite happy to buy a book on the chance that I might learn one thing from it. I have some that I didn't really learn anything from but they're few…

Always Produce

| 3 Comments
Paul Graham writes about "How to do what you love"... It's quite a good piece but the best bit is hidden down near the end. He suggests that a good way to "stay honest with yourself" about dreams to do something other than your "day job" is to Always Produce; that is, don't just talk about it or think about it, produce physical artefacts. This is excellent advice and it can be applied to pretty much everything you do.…

Look back and shudder

| 0 Comments
I'm currently investigating a memory leak in a complicated piece of multi-threaded code. Unfortunately the code doesn't have any unit tests and the leak only shows up reliably in the release build. Worse, I wrote the code and nobody has fiddled with it since, so it's my leak and my code and I have nobody to complain about and no excuses. I miss the unit tests and loose coupling that would be present if I hadn't written this particular piece of code quite so long ago.…

Leak plugged

| 2 Comments
Well, the leak in my legacy code wasn't too hard to find. There was one potential leak and one screamingly obvious leak. I'll post the fixed code tomorrow.…

More on the socket server leaks

| 7 Comments
It seems that the leak that I found isn't likely to be the one that my new user of the code is having problems with. They've built the code with Visual Studio 2005, made a few (correct) changes to the code to get it to build with the stricter compiler and they find that several of the servers leak; at first it looked like it was just the more complex servers but I've just tested the simplest echo server and that leaks in just the same way. They're obvious (big) leaks. Unfortunately, though the leak itself is obvious, the cause…
« December 2005 | January 2006 Archives | February 2006 »

About this Archive

This page is an archive of entries from January 2006 listed from newest to oldest.

December 2005 is the previous archive.

February 2006 is the next archive.

I usually write about C++ development on Windows platforms, but I often ramble on about other less technical stuff...

Find recent content on the main index or look in the archives to find all content.

I have other blogs...

Subscribe to feed The Server Framework - high performance server development
Subscribe to feed Lock Explorer - deadlock detection and multi-threaded performance tools
Subscribe to feed l'Hexapod - embedded electronics and robotics
Subscribe to feed MegèveSki - skiing