What is the current best-practice method to register a user backend with an app?

I started writing an app for a user backend and would like to know what the currently preferred method for registering a user backend is.

I was looking at the user_external app for inspiration first. As far as I can see it uses a hardcoded user_external config parameter (in …legacy/user.php) that seems to be deprecated.

Another app user_sql uses

$backend = new \OCA\user_sql\OC_USER_SQL;
\OC::$server->getUserManager()->registerBackend($backend);

Is this the way to go or is there something better?

Edit: After digging more into the code I have a related question. Should I add an user backend by extending \OC\User\Backend or implementing \OCP\UserInterface. Afaics only the latter works with registerBackend() because it expects this type.