my blue etching

Dec 27, 2011 03:38

My contract job with the Canadians is over. Thank god ( Read more... )

Leave a comment

Comments 4

agmsmith December 27 2011, 17:11:41 UTC
Looks like student coding. Someone who didn't read any of the language (or other) documentation. At least they did try printing out values to see what they were doing, though you'd think they'd clue in that it is unusual for the array always to have 4 elements. I wonder if the boss will ever notice that their software is mal-functional, but then there are many commercial programs which have a pretty interface but garbage inside (first time something unusual happens, untested of course, lack of error handling will crash them). Customers even buy them ( ... )

Reply

johnnyfavorite December 31 2011, 17:03:04 UTC
your assessment of the exact nature of the broken-ness of his code was a little different than mine. but that's the beauty of extremely stupid code, isn't it? because, dang, how the hell can you guess what was going through his mind.

every time i look in on haiku, it seems that they are getting a little closer. you have to give them props for persistence. can't imagine what i'd do with it myself, though.

Reply


udokeir December 31 2011, 00:11:11 UTC
Curiosity prompted me to look at how I would have done it. A single Google query for NSArray gave me my answer. This took me less than 30 seconds. http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html#//apple_ref/occ/instm/NSArray/count

And I don't know anything about iOS or Objective-C...

Reply

johnnyfavorite December 31 2011, 17:00:08 UTC
yep, that is exactly the method he should have used. that he couldn't find this out for himself is troubling.

bonus chatter: there's a reason i wrote an inline function to perform more or less the same thing. given the dynamic nature of objective-c, it's not too uncommon that, even though you've got a pointer to something that ought to be an NSArray, it is actually some other type of object. in that case, calling the 'count' method on such an object could cause a crash, or at the very least, it indicates that things in your program have gone horribly wrong. or maybe your pointer is nil, i.e., it doesn't point to anything at all. so rather than write this fairly complicated sequence of tests every time, i packaged it all up into an inline function. that's all an "extra for experts" type thing, though. for his purposes, just calling 'count' would have been close enough.

Reply


Leave a comment

Up