| 1 | package Analizo::Metric::AfferentConnections; | ||||||||||
| 2 | 23 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 23 | ▶ | use parent qw(Class::Accessor::Fast Analizo::ModuleMetric); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | =head1 NAME | ||||||||||
| 6 | |||||||||||
| 7 | Analizo::Metric::AfferentConnections - Afferent Connections per Class (ACC) metric | ||||||||||
| 8 | |||||||||||
| 9 | =head1 DESCRIPTION | ||||||||||
| 10 | |||||||||||
| 11 | The metric calculation is based on the following article and calculates the | ||||||||||
| 12 | class connectivity. | ||||||||||
| 13 | |||||||||||
| 14 | PhD Thesis: I<Monitoramento de metricas de codigo-fonte em projetos de software livre> | ||||||||||
| 15 | by Paulo Roberto Miranda Meirelles. | ||||||||||
| 16 | |||||||||||
| 17 | See the adaptation of the paragraph about Afferent Connections per Class in | ||||||||||
| 18 | the article: | ||||||||||
| 19 | |||||||||||
| 20 | Measures the connectivity of a class. If a class C<Ci> access a method or | ||||||||||
| 21 | attribute of a class C<Cj>, consider C<Ci> a client of the supplier class | ||||||||||
| 22 | C<Cj>, denoting C<< Ci => Cj >>. Consider the follow function: | ||||||||||
| 23 | |||||||||||
| 24 | client(Ci, Cj) = 1, if (Ci => Cj) and (Ci != Cj) | ||||||||||
| 25 | client(Ci, Cj) = 0, otherwise. | ||||||||||
| 26 | |||||||||||
| 27 | So C<ACC(Cj) = (sum(client(Ci, Cj)), i = 1 to N)>, where C<N> is the total | ||||||||||
| 28 | number of system classes. If the value of this metric is large, a change in the | ||||||||||
| 29 | class has substantially more side effects, making maintenance more difficult. | ||||||||||
| 30 | |||||||||||
| 31 | =head1 REFERENCES | ||||||||||
| 32 | |||||||||||
| 33 | =over | ||||||||||
| 34 | |||||||||||
| 35 | =item * | ||||||||||
| 36 | |||||||||||
| 37 | L<Monitoramento de metricas de codigo-fonte em projetos de software livre|https://www.teses.usp.br/teses/disponiveis/45/45134/tde-27082013-090242> | ||||||||||
| 38 | |||||||||||
| 39 | =back | ||||||||||
| 40 | |||||||||||
| 41 | =cut | ||||||||||
| 42 | |||||||||||
| 43 | 23 | __PACKAGE__->mk_accessors(qw( model analized_module)); | |||||||||
| 44 | |||||||||||
| 45 | 31 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 46 | 31 | my ($package, %args) = @_; | |||||||||
| 47 | my @instance_variables = ( | ||||||||||
| 48 | model => $args{model}, | ||||||||||
| 49 | 31 | analized_modules => undef | |||||||||
| 50 | ); | ||||||||||
| 51 | 31 | return bless { @instance_variables }, $package; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 6 | ▶ | sub description { | ||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 55 | 6 | return 'Afferent Connections per Class (used to calculate COF - Coupling Factor)'; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 33 | ▶ | sub calculate { | ||||||||
|
Subroutine
calculate: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 59 | 33 | my ($self, $module) = @_; | |||||||||
| 60 | 33 | $self->analized_module($module); | |||||||||
| 61 | 33 | my $acc_result = $self->model->modules_graph->in_degree($module); | |||||||||
| 62 | 33 | ▶ | return $acc_result ? $acc_result : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 23 | 1; | |||||||||