Earth to Wells Fargo: Stop Being Stupid About Phishing!

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 »

C#, GPS Receivers, and Geocaching: Vincenty’s Formula

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 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 »

C# Grief With Overloaded Operators

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 »

Intercepting Add and Remove of C# Event Delegates

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 »

Tip to IT Staffing Companies: Respect Your Recruiters

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 »

Demonstrating BindingList Serialization Bug

July 20th, 2007

Okay, so I blogged about how C# BindingList<T> serialization is broken and how to fix it. The problem centers around filling a BindingList subtype with items that implement INotifyPropertyChanged. This enables your list to fire ListChanged events indicating ItemChanged whenever a property of a list item changes. Unfortunately, serializing and deserializing the list causes the ItemChanged notification to stop firing unless you take steps to properly rebuild the list. This happens because C# event handlers aren’t serializable, and .NET fails to rewire the listeners.

A colleague of mine asked for a quick example to demonstrate the problem, so I whipped up this test case.

Read the rest of this entry »

Java and C#: Language Nuances Make You Think Differently

July 18th, 2007

When you move from one programming language to another, do you eventually find yourself thinking differently?

After eight years of slinging Java code, I converted over to C#. The C# language borrows (steals?) heavily from Java, but it also has added some features. Some of C#’s most valuable introductions to the language have now been adopted by Java. Things like attributes, generics, and auto-boxing – which first appeared in C# – have now been added to the JDK as of 1.5. It’s only a matter of time until Java adopts using-blocks and the yield keyword, too.

Despite this back-and-forth trading of features and enhancements, each language still maintains its distinct flavor. Some facets of each language – many of which are quite subtle – will probably never be adopted by the other simply because their introduction would create such a fundamental shift in language concepts it would invalidate a lot of prior work.

So, I was careful about my approach to C#. My Java work had been preceded by seven years of C++, and I remember what that transition was like. Although Java is strikingly similar to C++, the similarities are deceiving. Seemingly minor differences between the two languages created a sea change in how I thought, how I designed code, and how I tested applications.

Read the rest of this entry »

Fixing BindingList Deserialization

July 17th, 2007

I previously blogged about how to use the C# INotifyPropertyChanged interface with BindingList<T> instances so that your lists properly fire the ListChanged event with a ListChangedType of ItemChanged.

In that post, I also alluded to the fact that BindingList<T> is flawed with regard to serialization of BindingList<T> subtypes. The problem has to do with the fact that BindingList<T> listens for PropertyChanged events on any of its list items that implement INotifyPropertyChanged. However, because event handlers are not serializable, those listener connections are lost during the serialization process for subtypes, and they don’t get rewired when the list is deserialized. It’s straightforward to do that, but the implementation is missing from the .NET SDK, so we have to write it ourselves.

Read the rest of this entry »