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

Ideas for future versions #11

Open
juho-jaakkola opened this issue Dec 23, 2015 · 1 comment
Open

Ideas for future versions #11

juho-jaakkola opened this issue Dec 23, 2015 · 1 comment

Comments

@juho-jaakkola
Copy link
Contributor

Some ideas for future versions of the library:

Passing objects as arguments

Currently many of the methods take arbitrary arrays as parameters. This makes it difficult to understand what exact data each function is expecting. I think in the long-term the integration library should be refactored to pass objects instead of arrays as function arguments.

That way:

  • Type hinting could be used to clarify what arguments each method is expecting
  • Properties could be accessed with class methods instead of arbitrary array keys
// Fails if passed anything else but an object that implements the
// \H5P\Content interface. Therefore developers know exactly
// what they are supposed to pass into the method.
public function filterParameters(\H5P\Content $content) {
    // Also you now have easy access to content methods:
    if ($content->isFiltered()) {
        // Some logic here
    }
}

Splitting the framework logic to multiple interfaces

Currently the library requires a framework to implement only one interface: H5PFrameworkInterface.

This causes too much unrelated logic to be inserted into the same class. Splitting the implementation to multiple different interfaces would:

  • Make it clearer what is expected from each class and method
  • Increase the usefulness of input type hinting, as each class or method could define the exact object(s) that they need in order to do their job

Dependency injection

  • Reduces global state and global functions
  • Makes it possible to write unit tests with mocked dependencies
@icc
Copy link
Member

icc commented Jan 4, 2016

I agree, we should at least create interfaces for: Library, Content and File. And perhaps dependencies as well.

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

2 participants