November 6th, 2007
Roundoff problems have been the bane of programmers since computers started handling floating point numbers. Floating point numbers are represented by a finite number of bytes. This limits the precision of numbers that may be represented - you only get so many significant digits. More subtly, however, finite length floating point numbers limit which numbers may be represented accurately. Repeating decimals (which, in a sense, require an infinite number of significant digits) cannot be represented precisely. You may only store the nearest value representable by the computer. This is the origin of annoying roundoff problems found in floating point arithmetic.
The C# and Java 4-byte float data type provides 7 significant digits of precision, while the 8-byte double type provides 15. Using the higher precision double data type helps minimize the roundoff error, but it must still be addressed.
So, when I encountered the C# 12-byte decimal data type with its 28 significant digits, and Java’s arbitrary size BigDecimal data type, I figured these were simply ways of further minimizing the problem with a wider floating point type. Only after digging deeper did I realize that the implementation behind both of these data types is a stroke of genius.
Read the rest of this entry »
Posted in Technical Articles | 1 Comment »
October 20th, 2007
I have to admit, when I first heard about the open source project Crap4j, I thought it was a joke. It sounded like a sarcastic, tongue-in-check spoof on the masses of brittle legacy Java code accumulating daily in software development shops around the world.
It isn’t a joke.
The Crap4j Web site describes the Change Risk Analysis and Predictions software metric as “a mildly offensive metric name to help protect you from truly offensive code.” Well said. The levity of the name belies the seriousness of the problem. Java is no longer a new language. Greenfield development has made way for maintenance and incremental upgrades to massive legacy code bases for which the original development team is long gone.
We all know legacy Java code is often poorly documented, but dig a little deeper and you’ll discover something even worse: it’s poorly tested! Now, consider that legions of developers have added little tweaks and bug fixes along the way without giving consideration to meaningful refactoring. What else can you do but throw up your hands (or your lunch) and declare “This code is crap!”
Read the rest of this entry »
Posted in Technical Articles | No Comments »
August 21st, 2007
I’ve recently started experimenting with NHibernate – the C#/.NET version of the Hibernate O/R matpping tool that was originally developed for Java. The Java version is very powerful, and I’m a huge fan of it. The C#/.NET version is, for the most part, a straight port of the Java code base (and an ugly port, in some ways). Nevertheless, it appears to be just as robust as its predecessor.
Be warned, however, that the NHibernate DLLs require a high level of trust in the ASP.NET environment they’re deployed to. I spent an entire weekend beating my head against a wall trying to get a simple app up on my GoDaddy account. I suspect NHibernate probably wasn’t designed with a medium trust environment in mind. I was able to make a few tweaks to get the code running with fewer permissions requirements. However, the permissions required to enable dynamic proxies – a fundamental part of the NHibernate architecture – are non-negotiable.
I learned from GoDaddy tech support that their Deluxe Windows plan, a shared host environment, simply doesn’t allow those permissions. I’d need to upgrade to a dedicated server, and that’s just a little too pricey for an environment simply for experimentation. I was able to get NHibernate working without any hacks at Webhost4life, but I thought I’d share what I tried first at GoDaddy just to help you understand the permissions implications if you’re in a medium trust environment — and how you might need to address them on your own projects.

Read the rest of this entry »
Posted in Technical Articles | 5 Comments »
August 9th, 2007
Have banks learned nothing? According to Gartner, U.S. computer users lost $929 million to phishing scams from May 2004 to May 2005. In response, major banks have launched aggressive campaigns to educate customers about how to defend themselves and recognize fraudulent emails.
Their recommendations to customers are simple and easy-to-follow. If someone calls you on the phone asking for your ATM number, don’t give it to them! Only divulge secret information when you initiated the phone call. Be wary of emails asking for your social security number or credit card numbers. You know the drill.
So, why is Wells Fargo undermining all of these self-defense measures by sending out emails with hyperlinks to a Web site asking for your online banking username and password?!
Read the rest of this entry »
Posted in Commentary | 1 Comment »
August 6th, 2007
Vincenty’s Formula is an iterative solution for calculating the distance and direction between two points along the surface of Earth. For clarity, I’ve stripped out portions of the code I’ve put up for discussion, but you can download the entire C# source code from here. If you prefer Java, please see the Java version of this discussion.
Several years ago, I stumbled on a great pastime called “geocaching.” It’s a worldwide treasure hunting game where participants use handheld GPS receivers to find hidden “caches” - small boxes filled with prizes, trinkets, and “travel bugs“. The caches are hidden by other participants who post nothing more than the latitude and longitude on a website like Geocaching.com. My children and I have had a blast. It’s a great way for a grown man to justify playing in the woods (and buying an expensive gadget!) under the pretense of “playing with the kids.” With over 420,000 caches in 222 countries on all continents (including Antarctica!) there are bound to be several near you.
Read the rest of this entry »
Posted in Technical Articles | 6 Comments »
July 31st, 2007
Here’s a nasty bug that crept into one of my team’s projects recently. When will equivalent C# objects fail to compare as equal? The answer is “when operator== doesn’t work as expected.”
Read the rest of this entry »
Posted in Technical Articles | No Comments »
July 25th, 2007
All you geniuses and rocket scientists out there probably already know this, but I just stumbled on it, and I think it’s kind of cool. Did you know you can customize the adding and removing of C# event handlers? I didn’t.
I’m going to end this post with the question “Yes, but what’s it good for?” You folks with the Ph. D. in C#, feel free to scroll to the bottom and post your answers. For my fellow mortals out there, let me recap what I’m talking about.
Read the rest of this entry »
Posted in Technical Articles | 4 Comments »
July 22nd, 2007
Ever get a phone call from an IT recruiter that leaves you scratching your head wondering “what was that all about?” You know - the recruiter who wants you to take a gig in a city you don’t want to move to, doing work you have no qualifications for, and for $15/hr less than your current rate? Yeah, they rankle me, too.
It’s not the recruiter’s fault.
Many IT staffing companies are utterly clueless about the extraordinary value their recruiters add to the company’s image in the eyes of job candidates. I’ve been a software professional since 1992 — C++, Java, and now C# — and I value the relationships I’ve formed with a handful of hot-shot recruiters in the Dallas area. Later, I’m going to hold up a lady named Shanna as an example of the sort of top-notch recruiter staffing companies should strive to attract and retain.
Read the rest of this entry »
Posted in Commentary | No Comments »