Verzeihung, dieser Artikel ist derzeit nicht auf Deutsch verfügbar.

Programming With Beef

Veröffentlicht:

I recently worked on a project that made use of Globally Unique Identifiers (GUID).  Programming should be fun, so I had some fun creating the GUID 21454154-4D4F-5245-BEEF-214D4F4F4F21 for some test data.  Something that might jump out at you is that this GUID contains the word BEEF, which is a valid hexadecimal value.

The other developers found this amusing, but what they probably didn't realize is that if you take the hexadecimal value 21454154-4D4F-5245-BEEF-214D4F4F4F21 and convert it to ASCII you get “!EATMORE¾ï!MOOO!” which could also be read as “!Eat more beef! Mooo!”

For unit testing, when I needed a non-zero GUID that's guaranteed to not match any generated values, I defined a constant with the value beefbeef-beef-beef-beef-beefbeefbeef, which is also a valid hexadecimal value.

For extra fun, any GUID I hardcoded was actually a a silly phrase convertered from ASCII to hexadecimal.  (Don't worry, none of it was anything which anybody without a sense of humor might take offense at.)