Could I estimate, what would be the number of C++ LOCs in optimal code (desktop-application) given the number of LOCs in h-files?
The background: I'm doing an effort-estimation and a plan for porting a C++ software to C#.
My first idea was to create a rough estimation based on LOCs and to track the process using LOCs ported to LOCs remaining. Assuming, that the porting speed will be 200LOCs/day I came to 1,5 person-years. If I present this figure to the customer, I certainly won't get the contract.
After a closer look to the code I found out, that the code is very inefficient, uses many-many C&P code, implements own container-classes, etc. So the LOC-Number of C++ seems not to reflect the effort for implementing the same functionality. Now my assumption is, a header-file should reflect the functionality better.
Not with the same objective, however for my curiosity I once checked my LOCs with cloc
for a project in its intermediate (pre alpha) stage. It was not well documented and some of its places were slightly dirty coded or not well planned.
C++ 100 2545 3252 11680
C/C++ Header 108 2847 12721 9077
C 4 1080 971 6298
CMake 33 241 161 1037
Bourne Shell 4 16 0 709
Python 8 90 72 423
CSS 1 63 21 422
PHP 5 23 21 295
Javascript 5 42 23 265
JSON 4 0 0 183
XML 1 11 171 72
make 1 13 0 15
Bourne Again Shell 2 10 0 14
As you can see the ratio between header LOC and source LOC is 0.777
. However average
is not a good metric for anything. But along with other metrics e.g. comment lines some fuzzy lines may be drawn to indicate different parameters and stages of development. More studies of well known code bases are required to come up with a good huristics.
But at the end whatever measures you take, it can conclude an assumption which may be wrong.