-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Static method in interface? #25
Comments
This would be a question for @Nyholm. Although I will take responsibility (the blame?) for making it static. Mostly as it didn’t make a lot of sense (to me) to have a method that is basically a polyfill for My thought process on this method was something along these lines:
That said, I do understand where you are coming from with its use in an interface. What would be an intuitive way of requiring what is basically a polyfill? Preferably in such a way that it can easily be reused so people do not end up having multiple copies of the same polyfill in their code-base? Of course it can be dropped from the interface completely. But I would expect implementations to often end up putting such code inside their |
I don't have a problem with the fact that it's static - it's a pure functions, so that's fine.
A pure function, such as you have :-)
That's all I'm suggesting :-) My only point is that static methods in interfaces are generally meaningless - you can force somebody to implement a static method, but calling it in the abstract isn't really a thing. |
Any particular reason why
getHeadersFromServer
is part ofServerRequestCreatorInterface
?It's not like you can call it as
ServerRequestCreatorInterface::getHeadersFromServer()
- you always have to reference the implementation of a static method... static methods in interfaces don't generally make any sense - possibly except when you're just trying to make sure you implement a static method in the same way in several classes, but even then, it doesn't serve as any kind of abstraction, and you only have one implementation here, so...?The text was updated successfully, but these errors were encountered: