Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find a better name for RegistrationHub, and add an interface #14

Open
donquixote opened this issue Jul 17, 2013 · 1 comment
Open

Find a better name for RegistrationHub, and add an interface #14

donquixote opened this issue Jul 17, 2013 · 1 comment

Comments

@donquixote
Copy link
Owner

Currently the RegistrationHub is an object that wraps the class loader, with two responsibilities:

  • Originally: To provide methods to register PSR-0 namespaces, etc.
    The architectural goal is to separate convenience registration adapter logic from the class lookup logic.
  • Later, a method buildSearchableNamespaces() was added, to start class discovery.

A general goal is to heavily rely on composition internally, to nicely separate concerns, but to provide convenient facade objects for the library user, hiding most of the composition details.

During integration with Drupal, I realized that it will be useful for a library user to have one central object for "everything you may want to do with the class loader after bootstrap".

Typically this is not the loadClass() or register() methods. This stuff is dealt with at bootstrap, and then silently does its job.
What is relevant is namespace registration and discovery stuff. So the buildSearchableNamespaces() ended up in the class.

What we could do:

// Registration stuff
interface RegistrationHub_Interface
class RegistrationHub implements RegistrationHub_Interface
// Discovery stuff
interface RegistrationIntrospectionHub_Interface extends RegistrationHub_Interface
class RegistrationInspectionHub implements RegistrationIntrospectionHub_Interface
@donquixote
Copy link
Owner Author

What about we name this "Adapter" instead?

// Registration stuff
interface Adapter_ClassLoader_Interface {..}
class Adapter_ClassLoader implements Adapter_ClassLoader_Interface {..}
// Discovery stuff
interface Adapter_NamespaceInspector_Interface extends Adapter_ClassLoader_Interface {..}
class Adapter_NamespaceInspector extends Adapter_ClassLoader implements Adapter_NamespaceInspector_Interface {..}

(I slowly get to the point where I find the underscores annoying. On the other hand, it still allows for FQCNs with minimum redundancy.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant