I want to be able to reliably take an ID and map it to the appropriate object type so I can query the object in question.
Before now I've tried using the global decsribe info, looping over the objects and comparing the value of
getKeyPrefix() witht the test value, but the problem is we're limited to 100 describe calls in the governor limits, and so this method breaks down in orgs with more than 100 objects.
The next best solution I can think of is to slowly build up map of prefix -> object inside a list custom setting, so if I miss an object first time around the second time I might get it and so on as each successive run will have a larger cache to test first. This doesn't seem ideal though, so I'm looking for other options.
Another might be to hard code the known prefixes 006 for Oppties etc. in a static apex map, but that feels dirty.