| 1 | package Analizo::Metric::NumberOfMethods; | ||
| 2 | 21 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 21 | ▶ | use parent qw(Class::Accessor::Fast Analizo::ModuleMetric); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | Analizo::Metric::NumberOfMethods - Number of Methods (NOM) metric | ||
| 8 | |||
| 9 | =head1 DESCRIPTION | ||
| 10 | |||
| 11 | The metric calculation is based on the following article and calculates the | ||
| 12 | number of methods per class to measure the size of the classes in terms of its | ||
| 13 | implemented operations. | ||
| 14 | |||
| 15 | Article: I<Monitoring of source code metrics in open source projects> by Paulo | ||
| 16 | Roberto Miranda Meirelles. | ||
| 17 | |||
| 18 | See the adaptation of the paragraph about Number of Methods in the article: | ||
| 19 | |||
| 20 | ... This metric is used to help to identify the potential reuse of a class. In | ||
| 21 | general, the classes with a large number of methods are harder to be reused, | ||
| 22 | because they are more likely to be less cohesive (Lorenz and Kidd, 1994). Thus, | ||
| 23 | it's recommended that a class don't have a excessive number of methods (Beck, | ||
| 24 | 1997). | ||
| 25 | |||
| 26 | =cut | ||
| 27 | |||
| 28 | 21 | __PACKAGE__->mk_accessors(qw( model )); | |
| 29 | |||
| 30 | 15 | ▶ | sub new { |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||
| 31 | 15 | my ($package, %args) = @_; | |
| 32 | my @instance_variables = ( | ||
| 33 | model => $args{model} | ||
| 34 | 15 | ); | |
| 35 | 15 | return bless { @instance_variables }, $package; | |
| 36 | } | ||
| 37 | |||
| 38 | 4 | ▶ | sub description { |
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 39 | 4 | return "Number of Methods"; | |
| 40 | } | ||
| 41 | |||
| 42 | 10 | ▶ | sub calculate { |
|
Subroutine
calculate: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 43 | 10 | my ($self, $module) = @_; | |
| 44 | 10 | my @functions = $self->model->functions($module); | |
| 45 | 10 | return scalar(@functions); | |
| 46 | } | ||
| 47 | |||
| 48 | 21 | 1; | |
| 49 | |||