cc @bshaffer, as asked I move the discussion to an issue.
As already discusses in
The current fact that client like TranslationServiceClient are final have the current drawback of
- not being able to be extended
- therefor not being able to be mocked for tests
While I do understand that google does not want such service to be extended (and I don't see a real need personally), on the contrary it's annoying to me to not being able to mock such external-client service in tests.
The current proposed solution is to use https://github.com/dg/bypass-finals in order to remove the final keyword at runtime.
I encounter the following (at least two) issue with this bypass library:
The two possible solutions I have in mind would be:
- Removing
final hard keyword and use the soft one with phpdoc @final.
- Or introducing an interface for each existing client, listing every public method of the client.
While the second one seems to be the right one, I understand google might not want to introduce 100 new interfaces with tons of methods and prefer the first one as a quickwin.
Quoting:
I don't want to be stubborn on this, however. If there's more support from our developers that bypass-finals is not sufficient, and using final is too much of a pain, I'm happy to remove it from the client libraries!
So if you encounter any issue with those final classes, please share a word !
cc @bshaffer, as asked I move the discussion to an issue.
As already discusses in
The current fact that client like
TranslationServiceClientare final have the current drawback ofWhile I do understand that google does not want such service to be extended (and I don't see a real need personally), on the contrary it's annoying to me to not being able to mock such external-client service in tests.
The current proposed solution is to use https://github.com/dg/bypass-finals in order to remove the final keyword at runtime.
I encounter the following (at least two) issue with this bypass library:
The two possible solutions I have in mind would be:
finalhard keyword and use the soft one with phpdoc@final.While the second one seems to be the right one, I understand google might not want to introduce 100 new interfaces with tons of methods and prefer the first one as a quickwin.
Quoting:
So if you encounter any issue with those final classes, please share a word !