jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Schumacher <>
Subject Re: Usage of final methods in newly added report package
Date Tue, 22 Dec 2015 09:17:00 GMT
Am 20.12.2015 um 14:14 schrieb sebb:
> On 20 December 2015 at 10:52, Felix Schumacher
> <> wrote:
>> Am 13.12.2015 um 14:11 schrieb Philippe Mouawad:
>>> Hi Felix,
>>> Do you have an example where it does not seem justified ?
>> I wondered why they were (and sometimes were not) used.
>> I stumbled upon the usage (or non usage) of final when looking at a findbugs
>> report on CsvSampleWriter. That class uses a overridable method setWriter
>> from its constructor, which findbugs finds "scary".
>> In other classes I found a few methods declared final and other not, without
>> a documentation, why those final classes are closed for further inheritance
>> and the others not.
>> I haven't looked, whether they were justified or not, I was just curious.
> Final is required in some cases, e.g. methods called from constructor
> (*) or parameter passed to nested class.
> It is also potentially useful as a way of documenting that an item is
> not intended to be altered (although of course that doesn't stop a
> mutable object from being changed). This can be helpful when trying to
> follow code.
Right, but I think this usage of final should be documented in the class 
or methods.
> Some people like to make everything possible final; I think that can
> be distracting.
It looked just a bit random to me. All in all I tend to find, that 
making parameters final is a good idea (does only local harm), but 
making methods final should be done with documentation (is a design 
decision for the possible inheritance usages of the class).

> (*) if a sub-class overrides the method, it may be called before the
> class has been fully constructed so may fail in unexpected ways.
>> Regards,
>>   Felix
>>> Thanks
>>> On Sunday, December 13, 2015, Felix Schumacher <
>>>> wrote:
>>>> Hi all,
>>>> I see a lot of methods in the newly added report package, that are
>>>> declared final.
>>>> What is the reasoning behind this?
>>>> Regards,
>>>>    Felix

View raw message