Preparing for the 0.2 draft
Mark Mahieu
markmahieu at googlemail.com
Sun Jan 31 16:40:19 PST 2010
On 29 Jan 2010, at 08:56, Alex Buckley wrote:
>
> It would be very interesting if list members could provide the following
> statistics for codebases with which they are familiar:
OK, I've gathered some figures on the codebase I work on. It's somewhere between 800K and 1.2M LOC right now, depending on how you measure these things. A good proportion is GUI code (mostly SWT, some Swing) so plenty of anonymous inner classes.
>
> - What %age of anonymous inner classes declare a single non-Object method?
There are 1387 which appear to meet that criteria, out of a total 4493 anonymous inner classes. So 31%.
> - What %age of single-method anonymous inner classes declare fields?
0.6% (9 classes)
> - What %age of single methods in anonymous inner classes use 'this'?
2.4% (33 classes), although all but 4 use a qualified this to refer to the enclosing class instance; 0.3% is probably the more useful figure.
> - What %age of single methods in anonymous inner classes recurse?
0%. There are recursive anonymous inner classes, but (apparently) no recursive single method anonymous inner classes.
> - Are the %ages different for anonymous inner classes that implement an
> interface v. that extend a class ?
>
Out of the 1387 single method AICs, only 22 extend a class (I thought it would be a low number, but not that low). Of those, 1 declares a field, none refer to 'this' or are recursive.
The top 5 single-method AICs are broken down as follows:
325 : org.eclipse.swt.events.ModifyListener
246 : java.lang.Runnable
190 : org.eclipse.swt.events.DisposeListener
148 : java.util.Comparator
142 : org.eclipse.swt.widgets.Listener
Interestingly, 1685 of the non-single-method AICs extend SWT's SelectionAdapter class which provides default no-op implementations of the dual-method SelectionListener interface. Of those, 1679 only elect to override one of the two methods.
Mark
More information about the lambda-dev
mailing list