Monthly Archives: February 2012

Bizarre code of the day from Stackoverflow

Code: unsigned char* _pos = …; double result; *((int*)&result) = *((int*)_pos); Let’s see: taking int size bytes and moving them to a double. One can only view with amazement and contemplate the horror a maintainer will experience. Oh BTW, it … Continue reading

Posted in Uncategorized | Leave a comment

Fast Enumeration

I was looking at some client code and saw essentially this: NSArray *items = [NSArray arrayWithObjects:@"one", @"two", @"three", @"four", nil]; MyClass *myClass = [[MyClass alloc] init]; for (int i=0; i<4; i++) {     myClass.thing = @”test”;     myClass.widget … Continue reading

Posted in Uncategorized | Tagged | Leave a comment

Code Clarity

Code clarity is the ability to easily understand what code does. Clarity is the single most important issue when writing code.Inevitably code to increase performance degrades from code clarity. Speed, size and memory usage are all secondary. After the code … Continue reading

Posted in Uncategorized | Tagged | Leave a comment

Unit Testing

When testing private methods the compiler generates warning messages such as: “Instance MethodheaderEncodingFromXML:not found.” The solution is to add an Informal Protocol: @interface SegmentedParse (TestingInformalProtocol) – (NSString *)headerEncodingFromXML:(NSString *)xml; @end

Posted in Uncategorized | Tagged | Leave a comment