Cocoa's NSMutableArray changes implementation based on the size of the dataset
ridiculousfish.com
ridiculousfish.com
Ok, not so much predict, as read in the CFArray.c sources from Darwin.
http://www.google.com/codesearch/p?hl=en#pFm0LxzAWvs/darwins...
I think people forget that huge portions of OS X are available under the APSL. It saved me hours of debug time when I was writing a PKCS#8 certificate that openssl was happy with, but Keychain could not import. (openssl will happily use encryption methods that are probably not part of PKCS#8. But the RFC is cloudy.)
What's interesting to me is that this uses the standard Objective-C [[class alloc] init] mechanism, which is more intuitive than using a nonstandard class method (because in most other languages new will only allocate one class). When you look at Apple's (NeXTStep's) APIs, there's a lot of evidence of thought in the design process there.
Now that's simply not true.
In C++-derived languages it will (and mandates that a new object be created to boot), and C++-derived languages are the most common for Enterprise Programming, but that's a far cry from "most other languages".
class Test
{
Test( int count ) {
if ( count > 5000 ) return new Implementation();
return new OtherImplementation();
}
}
you'd have to use a class method, whereas you can do that with the standard alloc/init in Objective-C.I remember ASP.NET used a weird collection class to store javascript snippets that were to be included in the page being generated. The class internally used an array and then switched to a hashtable once the number of items in the collection went beyond some pre-tuned limit. As a result, if you tried to register too many javascript blocks to be included on the page, you found that they got included out of order, because the internal storage was now a hashtable with a non-deterministic order for keys.
I spent an entire night debugging this issue.