7April2008

How do I unit test something that writes to a file?

Posted by legalize under: Computers; Programming; Unit Testing.

This is a question that comes up periodically. Remember that a good unit test is one that is fast (< 100ms/test). A test that accesses files, databases or the network is not going to be this fast. But, we still have code that writes data to files or reads data from files and we want to unit test that code. So how can we do that?

Read the rest of this entry »

0 

24February2008

Writing Unit Tests Against Direct3D

Posted by legalize under: Computers; DirectX; Programming; Unit Testing.

Writing a unit test involves holding the “system under test” in a software vise and controlling all the other interactions of the system under test with the rest of the system. In an object-oriented programming language, the easiest way to control the interactions of your system under test with the rest of the universe is to interact with the universe through polymorphic interfaces. Because your system under test is collaborating with the universe through interfaces, it is not coupled to other concrete classes in your application. To unit test the system and its interactions, you provide “fake” or “mock” objects implementing the interfaces of the system’s collaborators. The system under test has no idea its collaborating with fake objects because it is coupled to an interface, not a concrete class.

Read the rest of this entry »

0 

9January2008

Channel 9 Video on Deploying the C++ Runtime

Posted by legalize under: Computers; Programming; Windows Installer.

The Visual C++ Team Blog has an entry about deploying the C++ runtime linking to a Channel 9 video on the topic. Since Visual Studio .NET 2005, the Visual C++ team has been updating the C++ runtime and choosing a new DLL to house that runtime to avoid “DLL hell” and other incompatabilities from updating the runtime underneath an already deployed application. If you’re using C++ and deploying your application with the runtime, you might want to watch the Channel 9 video and explore your options to choose the one that’s best for you.

0 

8January2008

Visual Studio 2008 Feature Pack in beta

Posted by legalize under: Computers; Programming.

A Visual Studio 2008 Feature Pack includes enhancements to MFC and portions of the upcoming addition to C++ standard library, as described in Technical Report 1.

0 

20December2007

Refactoring: Guard Macro Body

Posted by legalize under: Computers; Programming; Refactoring.

You have a C/C++ macro that needs to perform several statements or contains conditional statements.

Wrap the statements in a do { } while (0) construct to ensure that the statements are executed in the proper order and that the use of the macro doesn’t interfere with other control structures in the program.

Read the rest of this entry »

2 

17December2007

Direct3D Graphics Pipeline Update

Posted by legalize under: Computers; DirectX; Programming; Direct3D Graphics Pipeline.

Its been quite a while since I uploaded a new version of the draft of my book. Rest assured, I’m still working on the book and I really do plan on finishing it someday! However, I’ve gotten some feedback that the installer for the samples will sometimes fail. Since I haven’t gotten any detailed log files back from anyone who experienced the failure, I’ve been trying to figure out how to diagnose the problem and correct it. The samples also needed updating to Visual Studio .NET 2005 — and I guess now they’ll need updating to Visual Studio .NET 2008! So I’ve been working on my installer code by fitting unit tests to the code in an attempt to find the underlying problem that people have reported. My manual testing with old versions of Windows (that need updating of their DirectX runtime) with VMWare haven’t reproduced the problem that people have described, so I’m hoping that fitting everything in the installer with unit tests will help me identify the problem. I’ll also be converting the installer for the sample code to use WiX (Windows Installer XML) instead of the deployment project type in Visual Studio. This will make the installer more robust and will eliminate the script hackiness I had to do in my white paper. It will also make the installer source accessible to people who don’t have the Professional edition of Visual Studio since it will use only free tools. Once all the samples and source have been appropriately updated, I’ll go back to incorporating 9.0c changes into my manuscript.

1 

17December2007

Faking Out the Win32 API with Templates

Posted by legalize under: Computers; Programming; Unit Testing.

When writing a unit test, you want to hold the code under test in a vice. You want the code under test to collaborate with objects whose behavior you control so that you can inject controlled conditions into the code under test. This is fairly straightforward when the code under test collaborates with a class that implements an interface. You can simply write a test harness class with the desired behavior. The test harness class is usually called a “fake” object or a “mock” object. It is not the real collaborator, but an object whose purpose is to inject the desired conditions into the code under test to validate its behavior under different circumstances.

However, Win32 code has another sort of collaborator that is more difficult to fake — the global functions in the Win32 API. What happens when your code calls LoadLibrary and the file can’t be found? Furthermore, with a true unit test you don’t even want to do file I/O because that will make the test run slow. You want unit tests to run as fast as possible because you will be running them often as you make changes to the production code.

Read the rest of this entry »

0 

16December2007

“Professional XNA Game Programming” by Benjamin Nitschke

Posted by legalize under: Programming; XNA Game Studio Express.

Overall I liked this book. Like most books that are “first” on a subject there are a few small errors that reflect how the XNA Framework changed between early betas and the final release. This is just the facts of life when you buy the “first” book on a new technology given the lead times on books. Its just not feasible to rework a book extensively based on the final code and have the book come out “first”. Even with that disclaimer, this is still a good book for the game developer that wants to learn about the XNA Framework and write a single set of source that runs on Windows and on the Xbox 360. This book covers XNA Game Studio Express 1.0

Read the rest of this entry »

0 

18October2007

Remaining GameFest 2007 Presentations

Posted by legalize under: Programming; Gamefest 2007.

Dave Weller has links to the remaining GameFest 2007 presentations.

0 

18October2007

Why TRAX is Dumb II

Posted by legalize under: Politics.

Over at the CATO@Liberty blog, they ask Is Portland Light Rail a Success?.

I routinely hear people say that Salt Lake City’s light rail, TRAX, is a success. When asked for more information on what makes it a success, they generally devolve to their own personal opinion that they find TRAX convenient for them and that they like it. I’m sure its easy to like something that you don’t have to pay for, but that is not the measure of success for spending public money. I’d like it if tax money were simply diverted to my bank account. I would consider that a success, but the people who pay those taxes would disagree.

When I watch the TRAX cars roll by they are mostly empty. The exceptions are when there is a sporting event at the arena downtown or other such activity and people are using TRAX as a way to get downtown without having to find a parking space (not that finding a parking space in downtown SLC is even remotely hard). I hear news reports, increasing in frequency, of people’s cars being vandalized and burglarized while they are parked at the TRAX station. When you think about it, all those cars parked in the TRAX station are just sitting ducks. There’s no patrolling of the TRAX station parking lots as far as I know and if people are commuting to work then the cars are just sitting there unattended and unmonitored all day long. It must be easy pickings for thieves.

TRAX has always felt like bureacratic empire building within UTA more than a solution to a problem. If light rail were an alternative that people really wanted compared to their cars, then private industry would already be providing it.

2 

Browse

Calendar

August 2008
M T W T F S S
« May    
 123
45678910
11121314151617
18192021222324
25262728293031

Categories

Links