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
( ... )
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.
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.
Comments 4
Reply
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
And I don't know anything about iOS or Objective-C...
Reply
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