SLOC in Smalltalk

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

SLOC in Smalltalk

hernanmd
Hi there,
Guys, what are you using to measure logical lines of code (LOC) in Pharo?
Given I am measuring a script, is there any other software measure you may recommend?
Cheers,

Hernán

Reply | Threaded
Open this post in threaded view
|

Re: SLOC in Smalltalk

Janko Mivšek
Hi Hernán

I once did some code statistics for our web frameworks, by counting:

  - Nr of packages, categories, classes, methods
  - lines of code
  - Avg methods/class
  - Avg lines/method

  - Nr of test methods
  - Avg tests/class

  - % of commented methods
  - % of commented classes

Then three graphs were drawn:

  - Methods in classes
  - Class inheritance depth
  - Lines in methods

Results can be seen here:

https://docs.google.com/spreadsheet/ccc?key=0Atnb1W9vuq9ndG4wbUpxNXpKQnFZRlFyQXpHclhZa2c#gid=1

The code measuring all above is here:

   http://www.squeaksource.com/WebCodeStats.html


Hope this helps
Janko


Dne 31. 03. 2013 09:23, piše Hernán Morales Durand:
> Hi there,
> Guys, what are you using to measure logical lines of code (LOC) in Pharo?
> Given I am measuring a script, is there any other software measure you
> may recommend?
> Cheers,
>
> Hernán
>

--
Janko Mivšek
Aida/Web
Smalltalk Web Application Server
http://www.aidaweb.si

Reply | Threaded
Open this post in threaded view
|

Re: SLOC in Smalltalk

hernanmd
Hi Janko. Thanks for your useful package.

Apparently there is some issue with #linesOfCode. The dummy expression
below return 5 instead of 4 in Pharo 1.4 and 2 because is counting the
autogenerated 'DoIt' selector.

(UndefinedObject evaluatorClass new
        compileNoPattern: '| oc |
oc := OrderedCollection new: 20.
oc add: 1.
oc size'
        in: UndefinedObject
        context: nil
        notifying: nil
        ifFail: []) generate linesOfCode

Hernán

El 31/03/2013 10:17, Janko Mivšek escribió:

> Hi Hernán
>
> I once did some code statistics for our web frameworks, by counting:
>
>    - Nr of packages, categories, classes, methods
>    - lines of code
>    - Avg methods/class
>    - Avg lines/method
>
>    - Nr of test methods
>    - Avg tests/class
>
>    - % of commented methods
>    - % of commented classes
>
> Then three graphs were drawn:
>
>    - Methods in classes
>    - Class inheritance depth
>    - Lines in methods
>
> Results can be seen here:
>
> https://docs.google.com/spreadsheet/ccc?key=0Atnb1W9vuq9ndG4wbUpxNXpKQnFZRlFyQXpHclhZa2c#gid=1
>
> The code measuring all above is here:
>
>     http://www.squeaksource.com/WebCodeStats.html
>
>
> Hope this helps
> Janko
>
>
> Dne 31. 03. 2013 09:23, piše Hernán Morales Durand:
>> Hi there,
>> Guys, what are you using to measure logical lines of code (LOC) in Pharo?
>> Given I am measuring a script, is there any other software measure you
>> may recommend?
>> Cheers,
>>
>> Hernán
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-project] SLOC in Smalltalk

Janko Mivšek
Hernán,

It would be nice if you patch the WebCodeStats by yourself. I just set a
read-write access to the http://www.squeaksource.com/WebCodeStats.html.

Best regards
Janko

Dne 02. 04. 2013 04:54, piše Hernán Morales Durand:

> Hi Janko. Thanks for your useful package.
>
> Apparently there is some issue with #linesOfCode. The dummy expression
> below return 5 instead of 4 in Pharo 1.4 and 2 because is counting the
> autogenerated 'DoIt' selector.
>
> (UndefinedObject evaluatorClass new
>     compileNoPattern: '| oc |
> oc := OrderedCollection new: 20.
> oc add: 1.
> oc size'
>     in: UndefinedObject
>     context: nil
>     notifying: nil
>     ifFail: []) generate linesOfCode
>
> Hernán
>
> El 31/03/2013 10:17, Janko Mivšek escribió:
>> Hi Hernán
>>
>> I once did some code statistics for our web frameworks, by counting:
>>
>>    - Nr of packages, categories, classes, methods
>>    - lines of code
>>    - Avg methods/class
>>    - Avg lines/method
>>
>>    - Nr of test methods
>>    - Avg tests/class
>>
>>    - % of commented methods
>>    - % of commented classes
>>
>> Then three graphs were drawn:
>>
>>    - Methods in classes
>>    - Class inheritance depth
>>    - Lines in methods
>>
>> Results can be seen here:
>>
>> https://docs.google.com/spreadsheet/ccc?key=0Atnb1W9vuq9ndG4wbUpxNXpKQnFZRlFyQXpHclhZa2c#gid=1
>>
>>
>> The code measuring all above is here:
>>
>>     http://www.squeaksource.com/WebCodeStats.html
>>
>>
>> Hope this helps
>> Janko
>>
>>
>> Dne 31. 03. 2013 09:23, piše Hernán Morales Durand:
>>> Hi there,
>>> Guys, what are you using to measure logical lines of code (LOC) in
>>> Pharo?
>>> Given I am measuring a script, is there any other software measure you
>>> may recommend?
>>> Cheers,
>>>
>>> Hernán
>>>
>>
>
>
>

--
Janko Mivšek
Aida/Web
Smalltalk Web Application Server
http://www.aidaweb.si

Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-project] SLOC in Smalltalk

Marcus Denker-4
In reply to this post by hernanmd

On Apr 2, 2013, at 4:54 AM, Hernán Morales Durand <[hidden email]> wrote:

> Hi Janko. Thanks for your useful package.
>
> Apparently there is some issue with #linesOfCode. The dummy expression below return 5 instead of 4 in Pharo 1.4 and 2 because is counting the autogenerated 'DoIt' selector.
>
> (UndefinedObject evaluatorClass new
> compileNoPattern: '| oc |
> oc := OrderedCollection new: 20.
> oc add: 1.
> oc size'
> in: UndefinedObject
> context: nil
> notifying: nil
> ifFail: []) generate linesOfCode

Hello,

I do not think that this is wrong. The doit *does* contain a selector. if #linesOfCode would contain a special
case for doits, it would be inconsistent.

E.g. print this:

thisContext method sourceCode

-->

 'DoIt
        ^ thisContext method sourceCode'

There is a Doit. There is even a return in the that is generated… and the doit is actually pretty-printed:



thisContext
method
linesOfCode

--> 2

So in short: dots are special, there is no need to change #linesOfCode, as there is no thinkable change
that would make any sense.

In general, LOC as a metric is not that good. It is better than nothing, but it makes more sense to count
e.g. message sends or use more advanced metrics on the AST (not every statement adds the same
to complexity, e.g. conditionals versus simple statements).


        Marcus
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-project] SLOC in Smalltalk

hernanmd
Hi Marcus,

Thanks for the information. I couldn't answer before because of the
flooding in my city[*].

Can you recommend a package for more advanced metrics?
Cheers,


[*] http://www.bbc.co.uk/news/world-latin-america-22023196
http://www.bbc.co.uk/news/world-latin-america-22019841

El 02/04/2013 11:01, Marcus Denker escribió:

>
> On Apr 2, 2013, at 4:54 AM, Hernán Morales Durand <[hidden email]> wrote:
>
>> Hi Janko. Thanks for your useful package.
>>
>> Apparently there is some issue with #linesOfCode. The dummy expression below return 5 instead of 4 in Pharo 1.4 and 2 because is counting the autogenerated 'DoIt' selector.
>>
>> (UndefinedObject evaluatorClass new
>> compileNoPattern: '| oc |
>> oc := OrderedCollection new: 20.
>> oc add: 1.
>> oc size'
>> in: UndefinedObject
>> context: nil
>> notifying: nil
>> ifFail: []) generate linesOfCode
>
> Hello,
>
> I do not think that this is wrong. The doit *does* contain a selector. if #linesOfCode would contain a special
> case for doits, it would be inconsistent.
>
> E.g. print this:
>
> thisContext method sourceCode
>
> -->
>
>   'DoIt
> ^ thisContext method sourceCode'
>
> There is a Doit. There is even a return in the that is generated… and the doit is actually pretty-printed:
>
>
>
> thisContext
> method
> linesOfCode
>
> --> 2
>
> So in short: dots are special, there is no need to change #linesOfCode, as there is no thinkable change
> that would make any sense.
>
> In general, LOC as a metric is not that good. It is better than nothing, but it makes more sense to count
> e.g. message sends or use more advanced metrics on the AST (not every statement adds the same
> to complexity, e.g. conditionals versus simple statements).
>
>
> Marcus
>


Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-project] SLOC in Smalltalk

Tudor Girba-2
Perhaps you could give Moose a try :).

For a quick experiment:
1. Download
https://ci.inria.fr/moose/job/moose-latest-dev-4.8/lastSuccessfulBuild/artifact/moose-latest-dev-4.8.zip
2. Execute
((MoosePharoImporterTask new
        addClasses: {Morph};
        run)
                allModelClasses entityNamed: #'Smalltalk::Morph')
                        openInMoose
3. Look in the second tab

Cheers,
Doru

 
On Apr 7, 2013, at 11:01 PM, Hernán Morales Durand <[hidden email]> wrote:

> Hi Marcus,
>
> Thanks for the information. I couldn't answer before because of the flooding in my city[*].
>
> Can you recommend a package for more advanced metrics?
> Cheers,
>
>
> [*] http://www.bbc.co.uk/news/world-latin-america-22023196
> http://www.bbc.co.uk/news/world-latin-america-22019841
>
> El 02/04/2013 11:01, Marcus Denker escribió:
>>
>> On Apr 2, 2013, at 4:54 AM, Hernán Morales Durand <[hidden email]> wrote:
>>
>>> Hi Janko. Thanks for your useful package.
>>>
>>> Apparently there is some issue with #linesOfCode. The dummy expression below return 5 instead of 4 in Pharo 1.4 and 2 because is counting the autogenerated 'DoIt' selector.
>>>
>>> (UndefinedObject evaluatorClass new
>>> compileNoPattern: '| oc |
>>> oc := OrderedCollection new: 20.
>>> oc add: 1.
>>> oc size'
>>> in: UndefinedObject
>>> context: nil
>>> notifying: nil
>>> ifFail: []) generate linesOfCode
>>
>> Hello,
>>
>> I do not think that this is wrong. The doit *does* contain a selector. if #linesOfCode would contain a special
>> case for doits, it would be inconsistent.
>>
>> E.g. print this:
>>
>> thisContext method sourceCode
>>
>> -->
>>
>>  'DoIt
>> ^ thisContext method sourceCode'
>>
>> There is a Doit. There is even a return in the that is generated… and the doit is actually pretty-printed:
>>
>>
>>
>> thisContext
>> method
>> linesOfCode
>>
>> --> 2
>>
>> So in short: dots are special, there is no need to change #linesOfCode, as there is no thinkable change
>> that would make any sense.
>>
>> In general, LOC as a metric is not that good. It is better than nothing, but it makes more sense to count
>> e.g. message sends or use more advanced metrics on the AST (not every statement adds the same
>> to complexity, e.g. conditionals versus simple statements).
>>
>>
>> Marcus
>>
>
>

--
www.tudorgirba.com

"Speaking louder won't make the point worthier."