Rob Farley

Rob Rob Farley has been consulting in IT since completing a Computer Science degree with first class honours in 1997. Before moving to Adelaide, he worked in consultancies in Melbourne and London. He runs the development department in one of Australia's leading IT firms, as well as doing database application consultancy and training. He heads up the Adelaide SQL Server User Group, and holds several Microsoft certifications.

Rob has been involved with Microsoft technologies for most of his career, but has also done significant work with Oracle and Unix systems. His preferred database is SQL Server and his preferred language is C#. Recently he has been involved with Microsoft Learning in the US, creating and reviewing new content for the next generation of Microsoft exams.

Over the years, Rob's clients have included BP Oil, OneLink Transit, Accenture, Avanade, Australian Electorial Commission, the Chartered Institute of Personnel and Development, the Royal Borough of Kingston, Help The Aged, Unisys, Department of Treasury and Finance (Vic), National Mutual, the Bible Society and others.

Did you mean to come here? My blog is now at http://msmvps.com/blogs/robfarley



20 March 2006

Bitwise reversing

The geek in me is clearly alive and strong. I found this post on reversing a string using bitwise XOR quite appealing.

Although really, it's not that different to storing a character and swapping them over (plus swapping the characters that way would be more 'obvious', which I think is always a feature of good code). The thing that makes a recursive function slow here is that you're building a new string. This function (and one where you swap characters) simply changes the string in-place. Plus it does it from both ends at once.

Personally I'd rather have the variables named better (instead of 'i' and 'len', why not use firstHalfCharPos and secondHalfCharPos, or something tediously long but descriptive like that?), but I do admire the 'fun' of the bitwise XOR, and it's a good way of demonstrating the principle of XOR.