I think the developer documentation covers it in a lot more detail than I can write here: https://docs.moodle.org/dev/Automatic_class_loading
Short version: namespace the file (with the full plugin type + name), don't include the plugin name in the class name (the old version - no namespace, include the plugin name in the class, but not the filename - is strongly discouraged).