Classes with the same name and description, but different location When I am looking for an information about any class in api documentation, I often encounter the situation when there are several classes with the same name and the same description, but different location.

For example, there are two classes with name YamlDiscovery and the same description.

How should one select a needed class for oneself? Can use any class? If so, what for they were added both into Drupal 8?
That's a bad example, it is then used as another name to avoid a name conflict use Drupal\Component\Discovery\YamlDiscovery as ComponentYamlDiscovery;.

Usually you can see the purpose of the class when you look at the namespace or the corresponding file location. It's OK to use the same class name in different namespaces. As you can see in this issue there can be different opinions how descriptive class names should be and how much you should rely on the namespace of the class to make the purpose clear:

https://www.drupal.org/node/2408667