C++ Code Smells

A recent security bulletin from Microsoft highlights the dangers of certain constructs in C++. These constructs constitute a set of code smells for C++. In this post, I’ll describe what I consider to be C++ code smells and how to deal with them.

Read the rest of this entry »

Bill Whittle Tells You What’s At Stake

Bill Whittle tells you what’s really at stake in the battle between elitists and Sarah Palin over on his show “Afterburner” on PajamasTV.

Read the rest of this entry »

Direct3D Programming Tip #8: Use Find in Files To Locate API Call Examples

The Direct3D API covers quite a bit of ground, particularly if you include D3DX. A question that arises fairly often in discussion forums is “where can I find an example of xxx?” for some particular API function or method named xxx.

Read the rest of this entry »

SlimDX Presentation on August 13th, 2009

I’ll be presenting a talk on SlimDX at the Utah .NET User Group meeting for August, 2009.

The Utah .Net User Group meets the 2nd Thursday of every month at 6:00 PM. Meetings are held at Neumont University in the South Jordan area about 20 minutes from downtown Salt Lake City. If you are traveling on I-15: exit on 106th south, head west, and they are right on the left hand side of the road in the grey 4-story buildings right there on the 3rd floor.

Utah .NET User Group meetings are free and open to everyone. Pizza and soda is usually provided free!

Refactoring: Split Module

You have a C module containing variables and functions that implement two different responsibilities.

Split the two responsibilities into two modules.

Read the rest of this entry »

Refactoring C++ Template Classes To Reduce Code Bloat

Test-Driven Development and Refactoring At Agile Roots 2009

I was a guest instructor at Zhon Johansen’s Test-Driven Development and Refactoring course at the recent Agile Roots Conference in Salt Lake City. Zhon and I did a dry-run rehearsal of this course for the Utah .NET User Group meeting in June. The streaming video for this tutorial is now available.

Read the rest of this entry »

Boost.Build Tutorial

Boris Schäling has written a tutorial on Boost.Build.

Build systems are a pain, particularly if you have cross-platform builds to manage. Where I work we support both Mac and PC versions of our products and coordinating the builds is a challenge. I haven’t used Boost.Build myself, but I know that the Boost folks have had to deal with all sorts of platforms and C++ compilers. They use advanced features of the compiler and have had to work around a number of painful situations. If you are investigating a new build system, Boost.Build is worth a look.

Agile Code Reviews

Have you ever been tasked with doing classic “Fagan” style code reviews? They’re boring. They’re tedious. They take up lots of time and yield little, if any, results. At a previous employer, we did these kinds of code reviews. It consisted of printing out the source code to be reviewed, one copy per reviewer. Each of us reviewed the code alone, making notes to the printout. Then we’d gather in a conference room and discuss our findings while one person combined all our notes into a list of items to rework. That person would rework the code alone and then report back to the group the results. Whew! This is what the agile development world would call a “high ceremony process”. It has lots of formal steps and the associated paperwork. Is there a better way? In this post, I’ll discuss what we do at my current employer that makes code reviews a fun team activity.

Read the rest of this entry »

Technical Debt Resources

Brad Appleton has posted a great article on technical debt with lots of links to further resources on the subject. If you’re struggling with an aging code base and your managers just don’t understand why you can’t produce features as fast as you used to or at the same quality as before, then direct them to specific resources after reading this blog post. Using ‘debt’ as a metaphor is perfect for the cruft that inevitably finds its way into our code when talking to non-technical types.

Refactor early and often to avoid accumulating technical debt to the point that it cripples you!

Refactoring: Reverse Boolean

You have a boolean variable that represents a negative condition and you want the variable to represent a positive condition.

Replace all assignments to the variable with their logical inverse and replace all uses of the variable with its logical inverse.

Read the rest of this entry »

Description Helpers For Direct3D 10, 10.1 and 11

In Direct3D 10, a number of device render states were aggregated into immutable objects. These immutable objects simplify state management on the device for the runtime and the driver, making it quicker to switch between state configurations on the device. These immutable state objects are created by filling in a description structure and creating the object. This mechanism is present in Direct3D 10.1 and Direct3D 11 as well. In this post, I will discuss some helper classes for constructing these state objects in a manner that more clearly reveals your intention.

Read the rest of this entry »

Direct3D Programming Tip #7: Use Smart Resource Locks

In Direct3D9, direct CPU access to a resource is obtained by obtaining a lock on the resource. Every time you obtain the lock, you must make sure that you release it. In Direct3D10 and Direct3D11, a similar situation is faced with resources, but the terminology has changed to mapping the resource. Using a helper class to handle the lock and unlock operations on a resource helps you create exception safe code in C++.

Read the rest of this entry »

Refactoring Tools Shoot Out

Over the past few years, I’ve been using a number of refactoring add-ons for Visual Studio.  The three refactoring add-ins I have tried are: Refactor! Pro from DevExpress, Visual Assist X from Whole Tomato and ReSharper from JetBrains. In this post, I’ll review and compare these refactoring add-ons.

Read the rest of this entry »

Direct3D Programming Tip #6: Link Against The Debug D3DX

Just as important as using the Direct3D debug runtime is using the debug D3DX library. D3DX is provided as a DLL library and like the runtime it is provided in two versions: release and debug builds.

Read the rest of this entry »

C++ Unit Tests With Boost.Test, Part 5

In Part 4 of this series, we completed some UI functionality using a test-driven development style. In this final part of the series, I will cover the facilities in Boost.Test for sharing common setup and teardown actions between tests and organizing tests into suites.

Read the rest of this entry »

C++ Unit Tests With Boost.Test, Part 4

In Part 3 of this series, we completed Bob Martin’s Prime Factors Kata using test-driven development and unit tests written in C++ with Boost.Test. In this part, I will discuss test-driven UI development.

Read the rest of this entry »

C++ Unit Tests With Boost.Test, Part 3

In Part 2 of this series, I discussed the assertion facilities of Boost.Test and how to get the first passing test on Bob Martin’s Prime Factors Kata. In this part, I will continue with test-driven development to complete the functionality of the PrimeFactors::Generate method.

Read the rest of this entry »

C++ Unit Tests With Boost.Test, Part 2

In Part 1 of this series, I discussed how to setup a basic C++ unit test project that executed the unit tests when you built your code. In this part, I will discuss the assertion framework provided by Boost.Test in the context of a simple programming exercise that demonstrates test-driven development.

Read the rest of this entry »

C++ Unit Tests With Boost.Test, Part 1

In this post, I will describe how to start making unit tests in C++ with Boost.Test.

Read the rest of this entry »