Statistics for E-Commerce system
Stephen Colebourne
scolebourne at joda.org
Fri Apr 24 10:25:48 PDT 2009
1.3 million LOC
Old sourcebase, lots of refactoring down the years
Java EE, Servlets but not EJB
Two parts - low level utilities, and main E-commerce codebase
Low level utilities
-------------------------
all catchs : 549
all conditionals : 297
all ifs : 1521
all integer literals : 4863
big integer literals(undescores): 326
byte literal : 0
catch in finally : 14
elvis : 86 --> correct value 36
instanceof switch : 27
loop with remove : 5 --> correct value 33
multi catch : 31
object switch : 81
rethrow clause : 271
string in switch : 23
Files:564
while \(.+?\.hasNext\(\)\)
all hasNext() while : 39
for \(Iterator
all iterator() for : 68
for \(int
all int for : 375
for \(
all for : 631
Elvis-conditional = 36/297 = 12.1%
Loop-remove = 33/631 = 5.2%
Multi-catch = 31/549 = 5.6%
Main E-Commerce system
---------------------------------------
(counted in three parts to avoid out of memory in the tool, and to
demonstrate how different types of code affect the results)
Main code (most of the business logic:
all catchs : 2592
all conditionals : 2185
all ifs : 7431
all integer literals : 45473
big integer literals(undescores): 5738
byte literal : 0
catch in finally : 35
elvis : 600 --> correct value ?
instanceof switch : 159
loop with remove : 88 --> correct value 430
multi catch : 39
object switch : 379
rethrow clause : 859
string in switch : 117
Files:5822
Sub part 1 (code generated beans):
all catchs : 753
all conditionals : 10244
all ifs : 4955
all integer literals : 145405
big integer literals(undescores) : 25957
byte literal : 0
catch in finally : 0
elvis : 4058 --> correct value, probably 0
instanceof switch : 9
loop with remove : 0 --> correct value 0
multi catch : 0
object switch : 15
rethrow clause : 1
string in switch : 0
Files:1553
Sub part 2 (presentation layer):
all catchs : 370
all conditionals : 366
all ifs : 1622
all integer literals : 2632
big integer literals(undescores) : 39
byte literal : 0
catch in finally : 6
elvis : 33
instanceof switch : 47
loop with remove : 8 --> correct value 20
multi catch : 0
object switch : 112
rethrow clause : 61
string in switch : 35
Files:1160
while \(.+?\.hasNext\(\)\)
all hasNext() while : 256
for \(Iterator
all iterator() for : 536
for \(int
all int for : 4530 *not all loops around lists
for \(
all for : 8248 *not all loops around lists
Elvis-conditional = ?/2185 =
Loop-with-remove = 450/8248 = 5.5%
Multi-catch = 39/3715 = 1.0%
The Elvis number currently needs manual work to calculate, so I passed
for the size of the main sourcebase. However, 12% of all conditionals
in the low level library is a reasonable number of hits.
The loop-with-remove is between 5 and 5.5% (of all loops, which
includes loops around things other than lists, like strings). I can't
easily determine how often the loop index is needed, or whether it is
the first/last loop, each of which would push up the %age.
Multi-catch has about 1% of all catch statements in the main
E-Commerce, but 5.6% in the low level libraries. This perhaps
indicates where the sweet spot for the feature is - libraries and
frameworks.
Stephen
More information about the coin-dev
mailing list