Over at How to get term name from a tid? the accepted answer for "how do I get the name for a Term" is this:
use Drupal\taxonomy\Entity\Term; ... $term = Term::load($tid); ...
That's really nice, easy to read code (and very easy to remember). It's also, as it turns out, applicable to all entity types in Drupal (just substitute the Term class for the type of entity you want).
Why then, do the overwhelming majority of the code examples and tutorials published around the place seem to advocate this monstrosity? ...
$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($tid);
That approach bakes in one of my [many] grievances with PHP in general - it's full of magic strings! How the hell am I supposed to know at "compile time" whether 'taxonomy_term' is the right argument to
getStorage()?? There's not a PHP IDE in the land that'll catch me sticking 'taxonomy' in there instead.
Looking at the contents of that ::load method (which is defined in \Drupal\Core\Entity\Entity and shared by all Drupal entities), it's got all the dependency-injection cleverness of that second-approach - plus it fills in the right argument to
getStorage() for you automatically!
So why does more of the Drupal community not use it? Is there something I'm missing? Or is it just to teach us "first principles" so that we can write shared code that works with any entity type? (you'd need the long-hand way in a hook that was intended to work across all entity types).