Re: [Wikitech-l] Declaring methods final in classes

2019-08-28 Thread Aryeh Gregor
On Tue, Aug 27, 2019 at 11:53 PM Daimona wrote: > Personally, I don't like these limitations in PHPUnit and the like. IMHO, > they should never be a reason for changing good code. I don't like these limitations either, but testing is an integral part of development, and we need to code in a way

Re: [Wikitech-l] Declaring methods final in classes

2019-08-28 Thread Daimona
> I don't like these limitations either, but testing is an integral part > of development, and we need to code in a way that facilitates testing. This is especially true for e.g. static methods, but here we'd be renouncing to a possibly useful feature. > Why do methods ever "have" to be final?

Re: [Wikitech-l] Declaring methods final in classes

2019-08-28 Thread Lucas Werkmeister
> > No, that's only what happens with mockery. The tool I found just strips > 'final' keywords from the PHP code - I believe, I still haven't looked at > the implementation. As far as I can tell, it actually strips final tokens from *any* PHP file that’s read, including by application code. It

Re: [Wikitech-l] Declaring methods final in classes

2019-08-28 Thread Daniel Kinzler
I see no good use for final methods or classes. Or rather: I see a very limited benefit and a pretty massive cost. Subclassing should be very limited anyway, and even more limited across module boundaries, which could even be enforced via static analysis. Method contracts should be enforced by

Re: [Wikitech-l] Declaring methods final in classes

2019-08-28 Thread Daimona
>Subclassing should be very limited anyway, and even more limited across module >boundaries I agree, but it doesn't offer a strict guarantee. > which could even be enforced via static analysis. Why not just use final, then? > Method contracts should be enforced by compliance tests. When

[Wikitech-l] Upcoming Search Platform Office Hours—September 4th

2019-08-28 Thread Trey Jones
The Search Platform Team usually holds office hours the first Wednesday of each month. Come talk to us about anything related to Wikimedia search! Feel free to add your items to the Etherpad Agenda for the next meeting. Details for our

Re: [Wikitech-l] Declaring methods final in classes

2019-08-28 Thread Daniel Kinzler
>> What benefits does it have to bind to a specific implementation that is > not >> guaranteed to stay as it is? > > If used properly, the final keyword should be for immutable > implementations. Otherwise, it could be a questionable use case. I think all the current uses of "final" in MW core

Re: [Wikitech-l] Declaring methods final in classes

2019-08-28 Thread Daimona
>> I agree, but it doesn't offer a strict guarantee. > > Do we need a strict guarantee more than we need unit tests? I think we need both. Or rather, we need unit tests more, but if that doesn't exclude using finals, we can have both. >> Why not just use final, then? > > Because it makes it

Re: [Wikitech-l] Declaring methods final in classes

2019-08-28 Thread Aryeh Gregor
On Wed, Aug 28, 2019 at 7:24 PM Lucas Werkmeister wrote: > As far as I can tell, it actually strips final tokens from *any* PHP file > that’s read, including by application code. Yes, but only if you turn it on, and we'd only turn it on for tests. > It seems to override the > standard PHP

Re: [Wikitech-l] Declaring methods final in classes

2019-08-28 Thread Daniel Kinzler
Am 28.08.19 um 16:48 schrieb Daimona: >> Subclassing should be very limited anyway, and even more limited across > module >> boundaries > > I agree, but it doesn't offer a strict guarantee. Do we need a strict guarantee more than we need unit tests? >> which could even be enforced via static

[Wikitech-l] [Tech Talks] Sept 4, 2019, 6 PM UTC, Documenting Wikimedia technical projects

2019-08-28 Thread Sarah R
Hi Everyone, It's time for Wikimedia Tech Talks 2019 Episode 7! This talk will take place *Sept 4, 2019 at 6PM UTC*. *Topic:* Documenting Wikimedia technical projects *Speaker:* Sarah R. Rodlund, Technical Writer -- Developer Advocacy *Summary: * This talk will discuss what technical writers

Re: [Wikitech-l] Declaring methods final in classes

2019-08-28 Thread Aaron Schulz
Well, changing something in core and breaking a production extenison doing something silly can't be waived away with "it's the extension's problem" ;) I mostly use "final" to enforce a delegation pattern, where only certain key bits of functionality should be filled in by subclasses. It mostly

Re: [Wikitech-l] Declaring methods final in classes

2019-08-28 Thread Krinkle
On Tue, Aug 27, 2019 at 6:55 PM Aryeh Gregor wrote: > I see that in some classes, like WANObjectCache, most methods are declared > final. Why is this? [..] > > The problem is that PHPUnit mocks can't touch final methods. [..] What did you want to assert in this test? I find there is sometimes