Skip to content

Make chaining available in Stargazers #522

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

Closed
wants to merge 1 commit into from
Closed

Conversation

Swader
Copy link

@Swader Swader commented Feb 6, 2017

Allows for:

$stargazers = $client->repo()->stargazers()->configure('star')->all('vuejs', 'vue');

instead of

$stargazers = $client->repo()->stargazers();
$stargazers->configure('star');
$stargazers = $stargazers->all('vuejs', 'vue');

Allows for:

```php
$stargazers = $client->repo()->stargazers()->configure('star')->all('vuejs', 'vue');
```

instead of

```php
$stargazers = $client->repo()->stargazers();
$stargazers->configure('star');
$stargazers = $stargazers->all('vuejs', 'vue');
```
@Nyholm
Copy link
Collaborator

Nyholm commented Feb 9, 2017

Do we really want a fluid interface here?

There are at least 6 other configure functions that also needs to be updated if we want this change.

@Swader
Copy link
Author

Swader commented Feb 9, 2017

What are the anti arguments, apart from other configure functions needing an update?

@Nyholm
Copy link
Collaborator

Nyholm commented Feb 9, 2017

Sorry for my empty post. Why fluid interfaces are bad is explained by Ocramius here: https://ocramius.github.io/blog/fluent-interfaces-are-evil/

It is also a matter of opinion. Im not sure if we should introduce it in this library or not. I will let others decide if we want fluid interfaces at all.

@Swader
Copy link
Author

Swader commented Feb 27, 2017

I appreciate that post, but do not agree with it. Regardless, I since there doesn't seem to be any interest from the public IRT this topic, you can close this I guess.

@acrobat
Copy link
Collaborator

acrobat commented Feb 28, 2017

I'm 👎 on this as it is not a bug just another way of calling the methods.

@sagikazarmark
Copy link

sagikazarmark commented Feb 28, 2017

Although I am also against fluent interfaces, I would probably make an exception in this case and I have two reasons for that:

  • there IS such thing as developer experience. In some cases sanity and well-designed API might not allow us to also make the developers happy, but in this case I don't see any reasons why it should not be fluent, on the other hand, it would obviously increase DX
  • I am not that familiar with the Github API client, but it seems to me that introducing immutability would be a good idea here, which would automatically make the interface fluent (that's also probably backwards compatible)

@acrobat
Copy link
Collaborator

acrobat commented Feb 28, 2017

DX is indeed a good point. We could allow fluent setter on the configure methods (other api methods make no sense to do this on)

@sagikazarmark
Copy link

I would also consider adding immutability together with making it fluent.

@Nyholm
Copy link
Collaborator

Nyholm commented Mar 23, 2017

I agree.
But adding immutability is a BC break.

@sagikazarmark
Copy link

I don't see why it's a BC break. configure returns an instance which is configured to do something. The fact that it's a new instance should not be a problem.

@Nyholm
Copy link
Collaborator

Nyholm commented Mar 23, 2017

I consider it a BC break because this code will not work anymore:

$stargazers = $client->repo()->stargazers();
$stargazers->configure('star');
$stargazers = $stargazers->all('vuejs', 'vue');

It would be the same as:

$stargazers = $client->repo()->stargazers();
$stargazers = $stargazers->all('vuejs', 'vue');

@Nyholm
Copy link
Collaborator

Nyholm commented Mar 24, 2017

Most of our APIs are stateful already. Lets make sure one can use a fluid interface. @Swader do you mind updating others APIs as well?

I've also added this to the 2.2 release. I would like to release that this Sunday.

@Nyholm Nyholm added this to the Release 2.2 milestone Mar 24, 2017
@Swader
Copy link
Author

Swader commented Mar 24, 2017

@Nyholm I'll do my best but I'm traveling right now and through next week and will not be at a code-friendly outlet until some time next week, so might be unable to do it. Sorry in advance if I fail to do it soon.

@acrobat
Copy link
Collaborator

acrobat commented Mar 24, 2017

I will see if I can make some time for it this weekend and send a PR for it (of course if you don't have the time for it!)

@Swader
Copy link
Author

Swader commented Mar 24, 2017

@acrobat I'm 90% sure I'm not going to be able to make it - I'll be on my phone for 95% of the time, so no code. You're welcome to it!

@acrobat
Copy link
Collaborator

acrobat commented Mar 25, 2017

I've created #544 to make the missing configure methods chainable!

@Nyholm Nyholm closed this in #544 Mar 26, 2017
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

Successfully merging this pull request may close these issues.

4 participants