Dear Peter,

I suggest to change the parameter passing of library routines like
NfSenRRD::SetupRRD.

Now caller have set up several trivial params in fixed order:
        NfSenRRD::SetupRRD("$NfConf::PROFILESTATDIR/live", $new_source,
                $tstart - 300, 0);

Now I plan to add Holt-Winters forecasting into RRDs and probably
I'd will have other developments. This may make some parameter lists
long and messy therefore easy to get it wrong.

Hash-line named parameters are more readable:

        NfSenRRD::SetupRRD(
                path    =>      "$NfConf::PROFILESTATDIR/live",
                db      =>      $new_source,
                start   =>      $tstart - 300,
# No 'force => 0' required because this is the default value
                hw      =>      1,      # add Holt-Winters
                alpha   =>      0.4,
# Other optional parameters here
        );

Then function's head could look like this:

sub SetupRRD {
        my %args = @_;
         my $path  = $args{path};
        my $db    = $args{db};
        my $start = $args{start};
        my $hw    = $args{hw};          # undef (=false) if missing
        my $force = $args{force};       # undef (=false) if missing
        my $alpha = $args{alpha} || 0.3;
        my $beta  = $args{beta}  || 0.002;
        my $gamma = $args{gamma} || 0.05;

What is your opinion?

Regards

Gabor

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Nfsen-discuss mailing list
Nfsen-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfsen-discuss

Reply via email to