anthropics / anthropic-sdk-csharp
Unit Size

The distribution of size of units (measured in lines of code).

Intro
  • Unit size measurements show the distribution of size of units of code (methods, functions...).
  • Units are classified in four categories based on their size (lines of code): 1-20 (small units), 20-50 (medium size units), 51-100 (long units), 101+ (very long units).
  • You should aim at keeping units small (< 20 lines). Long units may become "bloaters", code that have increased to such gargantuan proportions that they are hard to work with.
Learn more...
  • To learn more about unit size, the Sokrates recommends the following resources:
    • Function Length, MartinFowler.com
      • "If you have to spend effort into looking at a fragment of code to figure out what it's doing, then you should extract it into a function and name the function after that 'what'."
    • Stack Overflow Discussion on Unit Size, stackoverflow.com
      • "Use common sense, stick to small function sizes in most instances but don't be dogmatic about it if you have a genuinely good reason to make an unusually big function."
    • Coding Smells, codinghorror.com
      • "All other things being equal, a shorter method is easier to read, easier to understand, and easier to troubleshoot. Refactor long methods into smaller methods if you can."
    • Clean Code: A Handbook of Agile Software Craftsmanship, by Robert Martin
      • "The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that. Functions should not be 100 lines long. Functions should hardly ever be 20 lines long."
Unit Size Overall
  • There are 10,008 units with 111,173 lines of code in units (57.4% of code).
    • 56 very long units (14,550 lines of code)
    • 193 long units (13,732 lines of code)
    • 523 medium size units (14,765 lines of code)
    • 1,776 small units (26,573 lines of code)
    • 7,460 very small units (41,553 lines of code)
13% | 12% | 13% | 23% | 37%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cs13% | 12% | 13% | 23% | 37%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
src13% | 12% | 13% | 23% | 37%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
1739 241 3
1502 213 1
670 104 3
670 104 3
670 104 3
458 71 3
427 68 3
354 73 3
354 73 3
330 53 3
329 53 3
329 53 3
327 50 3
290 44 3
239 38 3
232 38 3
232 38 3
231 52 3
231 52 3
206 16 1
183 29 3
174 26 3
174 29 3
157 23 3
157 23 3
147 35 34
147 2 1
147 35 34
147 2 1
147 35 34
147 2 1
143 19 1
143 27 6
138 20 3
133 20 3
132 20 3
132 20 3
132 7 2
129 20 3
122 1 43
122 1 43
117 17 3
117 17 3
115 17 3
115 17 3
115 12 1
114 17 3
114 17 3
114 17 3
114 17 3