Author Topic: Code %, just want to know :D  (Read 2588 times)

Offline Tjaalie

  • Multiple posting newcomer
  • *
  • Posts: 40
Code %, just want to know :D
« on: October 25, 2005, 07:48:55 pm »
Hi (all people who read this),

While I was downloading the new version of CB today I began to read the
list of new features. When I saw the CodeStatics plugin I began to wonder if
there would be some kind of rithm in my coding, and what I found out was
a big shock becouse I expeted the results from different projects of mine
to be close but when I ran the plugin on serveral different projects I found out
that there is no more then 1% difference between my project (percent of pure code)
namly I get 59% or 60% of pure code. Now I was wondering if you quys could post
some of there results so we can compare :D .

PS: Im a great fan of Comments so I 'over' comment my code :D

Offline darklordsatan

  • Almost regular
  • **
  • Posts: 132
    • http://eviltrend.sf.net
Re: Code %, just want to know :D
« Reply #1 on: October 26, 2005, 05:38:48 am »
Well, I just got home from work, and installed RC2 like 15 minutes ago. (Read: Havent thinkered with it too much)
I opened several projects o' mine (spanking the oldies), and the Statistics shown differ a lot.

Im gonna give ya some examples:

My old CB::Profiler code = 59% Code Only
My old OpenGL screensaver = 22% Code Only  :lol:
My old ancient 3D Engine (I was young and learning  :)) = 70% Code Only  :shock:
Some old plugin I was developing for Aston Desktop (aka a DLL) = 54% Code Only

So, as you can see, the results show a lot of difference between several projects.
Maybe you use that Ctrl+C, Ctrl+V a lot?  :lol: (joking)

Oh, BTW, you gotta wait for Zlika to come here and enlighten you, because he is the author of the plugin.
« Last Edit: October 26, 2005, 05:40:32 am by darklordsatan »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Code %, just want to know :D
« Reply #2 on: October 26, 2005, 11:49:30 am »
Whatever results you get, you should be aware that there is a good chance for a significant bias.

For example, most people start every source file with a more or less fixed size block comment (usually 400-500 characters). Thus, the code/comment ratio greatly depends on the size of your files and the number of files.
If you have 10 files 50 kB each, then this head comment has a relative size of 1%.
If you have 100 files 5 kB each, then this head comment has a relative size of 10% !
A typical header file in a small to medium project has 1-2k, so the head comment alone may make up to 50% of the file - this does not include a single "real" comment. The smaller your files, the bigger the bias.

So only because your results differ from someone else's results, this does not mean that your code is overcommented (or any worse for that matter).


EDIT: typo.
« Last Edit: October 26, 2005, 11:57:12 am by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Zlika

  • Plugin developer
  • Multiple posting newcomer
  • ****
  • Posts: 59
Re: Code %, just want to know :D
« Reply #3 on: October 26, 2005, 01:31:40 pm »
Hi all
I have tested this plugin firstly with a simple C file of a dozen of lines (testing the robustness with complex imbricated single/multi-lines comments) and finally with a more complex project of something like around 30 files and 10000 lines, and comparing the results with a Java tool (I can't remember the name, it's not installed on this computer). The results are matching, so I'm quite confident in the plugin.
By the way, if you have some ideas of improvement for the plugin for the next release...

Zlika