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

Fluent API for ViewLoader #82

Closed
manuel-mauky opened this issue Jul 11, 2014 · 3 comments
Closed

Fluent API for ViewLoader #82

manuel-mauky opened this issue Jul 11, 2014 · 3 comments
Assignees
Labels
Milestone

Comments

@manuel-mauky
Copy link
Collaborator

The ViewLoader should get an optional fluent API so that the user are not forced to use the method with multiple params

@manuel-mauky
Copy link
Collaborator Author

With issue #64 we have added controller and root to the viewLoader. At the moment this adds State to the ViewLoader.

When creating the Fluent-API we need to take care that it is clear that a ViewLoader may not be reused after loading a view. Instead there needs to be a new viewLoader instance for every loading action. In the Fluent-API this can be archived.

@manuel-mauky manuel-mauky added this to the 0.3.0 milestone Jul 24, 2014
@manuel-mauky manuel-mauky self-assigned this Jul 24, 2014
@manuel-mauky
Copy link
Collaborator Author

The FluentAPI could look something like this:

ViewLoader.view(TestFxmlView.class).load();
ViewLoader.view(TestJavaView.class).withResources(resourceBundle).withRoot(root).withController(controller).load();

We need to decide which style of method naming we use. .withResources() vs .resources().
Is it ok to name the initial method call view and the last one load or are there other suggestions?

Additionally we have to decide what will happen with the existing ViewLoader.
Here are some proposals:

  1. Deprecate/Remove existing ViewLoader with its overloaded methods. The new ViewLoader will only have the fluent API. This means that the user will not have any instance of the ViewLoader but only access the fluent API by static methods. This means that we have to break the existing API.
  2. Keep the existing ViewLoader and let the user the choice
    In this case we have to clear some Questions:
    • Do we integrate the Fluent-API in the ViewLoader class or do we create a new one? How would this new one be named?
    • At the moment the existing ViewLoader as 2 params with it's load methods (view type and resource bundle) and 2 that are set before the loading with setters (codeBehind and root). We should unify this:
      1. Make the ViewLoader stateless: This means that the setters are removed and there are overloaded methods with which the user can define the codeBehind and root. The main advantage of this proposal is that we don't need to break the existing API (the setters are not part of Version 0.2.0 but were added only to 0.3.0 which is not released yet so we can still change it)
      2. Make the ViewLoader completely statefull: All params have to be set by setter methods. After that a param-less load method would be called. This also means that for every loading a fresh instance of the ViewLoader has to be created.
      3. Remove the codeBehind and root params from the existing ViewLoader. We could simply say that the existing ViewLoader is only suitable for the 95% usecases where you only load a view. For the missing 5 % usecases where you need the codeBehind or root param you have to use the Fluent-API.

@sialcasa
Copy link
Owner

  • Naming: the prefix "with" makes it difficult to find exactly the method I want to find (IDE), so I prefere the plain style
  • because of inconsistency in the API I would avoid option c, because we would not need a fluent API in this case
  • currently I prefer option a)

Lets have a call on monday :-)

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

No branches or pull requests

2 participants