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

Why is $loop private? #40

Closed
SamMousa opened this issue Jun 8, 2016 · 5 comments
Closed

Why is $loop private? #40

SamMousa opened this issue Jun 8, 2016 · 5 comments
Labels

Comments

@SamMousa
Copy link

SamMousa commented Jun 8, 2016

When creating a subclass of the socket server I am forced to override the constructor if I want to access the loop. What is the argument for making $loop private instead of protected?

@staabm
Copy link

staabm commented Jun 8, 2016

because encapsulation.

@SamMousa
Copy link
Author

SamMousa commented Jun 8, 2016

So making $loop protected is breaking encapsulation too much, but having a public $master doesn't??

What is the practical downside of making a dependency that might be used by subclasses available to them?
Alternatively it could at least be made available via a getter.

@staabm
Copy link

staabm commented Jun 8, 2016

just capture it with __construct ... a lot easier then meaningless getters or anything.

I guess $master is public for performance reasons, but I dunno actually.

@SamMousa
Copy link
Author

SamMousa commented Jun 8, 2016

@staabm I know I can capture it and that's what I do now, I'd just rather not have to.
The goal of this ticket is not to solve my problem, but to possibly improve the library.

Anyway, feel free to close if you feel this would not be an improvement.

@clue clue added the question label Nov 13, 2016
@clue
Copy link
Member

clue commented Nov 13, 2016

The $loop is private because we don't want this to become part of our public API. Keeping this private allows us to change these implementation details without introducing BC breaks.

I agree that keeping this as-is encourages a cleaner design because it makes extending the server more difficult and encourages composition (DI) instead.

This has also already been covered in #12, #14 and #27.

I hope this helps 👍 I believe this has been answered, so I'm closing this for now. Please come back with more details if this problem persists and we may reopen this 👍

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

3 participants