In this universe we obey the law of commutativity

This kind of thing has happened to be a few times now, so I thought I’d share the fun.
In one of our pieces of software we have a process that looks like this:

void MyThread()
{
while (true)
{
DoFunctionA();
[…]

GetTextExtent vs. DrawText (with DT_CALCRECT)

Working on an MFC app that has just been converted to Unicode (finally!), I noticed that one button (which is created dynamically) is too small to fit the text in Korean (and Russian and a few other languages).
The code was calling something like:

CSize sz = m_btAdjustColors.GetDC()->GetTextExtent(sCaption);

It seems correct, but these script languages are throwing it […]

How to file good bug reports (from Frank Kelly)

This is an issue I run into constantly at my job.
Frank Kelly wrote up a good summary of some items. They’re simple, easy to understand, easy to follow, even for non-programmers.
In fact, I’m sending this link out to everyone in my group here at work.
Technorati Tags: testing,programming,bug reporting

Tags: bugs, Links/News, programming, self-improvement, teams, […]

Never make assumptions about performance

The importance of measuring performance changes is a topic that has been covered by others smarter and more experienced than me, but I have a recent simple tale.
I’ve simplified the code quite a bit in order to demonstrate the issue. Suppose I have a wrapper around an image (it has many more attributes):

[…]

Tip: Easily Automating use of WaitCursor

This is really simple and probably common, but it’s a useful tip anyway.
Say you need to set a form’s cursor to the wait cursor while you accomplish something.
You would do something like this:
this.Cursor = Cursors.WaitCursor;
 
//do something
 
this.Cursor = Cursors.Default;
Of course, what if “do something” throws an exception? Then your cursor won’t be set back to the […]

.Net Reflector

Lutz Roeder’s .Net Reflector has been discussed on many blogs before, but I want to give it an additional plug. I recently had to emulate some C# serial-port code in our C++ app. The .Net SerialPort class is great, easy-to-use, and works well. Unfortunately, we’re using a C++ serial port library that does not support […]

Solving "Unexpected Store Error" in Exchange

Getting a weird COM Exception with the cryptic ID 0×8055001E?
We’ve been struggling with this problem for over a year now, and we finally have a solution.
We have some critical code that is contacting Exchange server via COM Interop and CDOEX.DLL to read some inboxes and process e-mails. About once a month or so, we get […]

Easily Unit Testing Event Handlers

In C#, If you need to unit test a class that fires an event in certain circumstances (perhaps even asynchronously), you need to handle a little more than just running some code and doing the assertion. You have to make sure your unit test waits for the event to be fired. Here’s one naive way […]

DiskSlicer 1.2 Out

I made some minor updates to DiskSlicer. Mostly, some minor bug fixes, but also I added the much-requested ability to delete files directly from the program.
Go get it and enjoy!

Tags: software, storage

Difference between ConfigurationSettings and ConfigurationManager

If you upgraded a project from .Net 1.0/1.1 to .Net 2.0, and it used application configuration files, you will soon come across the compiler warning message
‘System.Configuration.ConfigurationSettings.AppSettings’ is obsolete: ‘This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings’   

You have to add a reference to the System.Configuration assembly, but once you do, you can just […]