Drupal 8 uses the PSR-4 standard developed by the PHP Framework Interoperability Group (PHP-FIG). The PSR-4 standard is for package-based PHP namespace autoloading. It defines a standard to understand how to automatically include classes based on a namespace and class name. Drupal modules have their own namespaces under the Drupal root namespace.
Using the module from the recipe, our PHP namespace will be Drupal\mymodule, which represents the modules/mymodule/src folder.
With PSR-4, files need to contain only one class, interface, or trait. These files need to have the same filename as the containing class, interface, or trait name. This allows a class loader to resolve a namespace as a directory path and know the class's filename. The file can then be automatically loaded when it is used in a file.