[Koha-devel] Koha, Style, and Perltidy
paul POULAIN
paul.poulain at free.fr
Tue May 13 00:36:08 CEST 2003
Mike Hansen wrote:
>Hello everyone,
>
> Now, there are a number of options that we should decide on before we
>can effectively use perltidy. I will present some of the major options
>here along with their alternatives and some sample pieces of code
>formatted with the various options.
>
Good.
My 2cts :
As i've coded 95% of the MARC stuff and a lot of other scripts too, my
opinion and how i use to do will probably decide what we do.
Note I don't want to begin a war, but there is no "best" solution,
otherwise everybody would use it.
>1. Line length: This setting will prevent lines of code from exceeding
>a maximum number of characters. The default length is 80 columns. Do
>we want it do be more or less or the same?
>
I don't worry with this.
>2. Indentation: There are a number of ways that perltidy handles
>indentation. First, you can specify a number of spaces to ident code
>blocks. Shown below is the indentation set to 4 spaces:
> if ( $flag eq "a" ) {
> $anchor = $header;
> }
>We can change this value to anything we would like. We can also set it
>to use tabs instead of spaces to indent.
>
I prefer using tabs => ppl can decide the size of the tab in their
editor. It's only a problem with tabbed comment at end of line, but
that's not a major pb, as there are only a few of such comments.
We can decide to prefer a "4 char tab" anyway.
Not I've "tabbed" a lot of scripts I haven't written (on the fly)
>3. Opening Brace Right or Left: This setting controls where the
>opening brace for code blocks go. Below is an exmaple with them on the
>right:
> if ( $flag eq "h" ) {
> $headers = 0;
> }
>Which one of these should we use?
>
I always use right one.
>4: Cuddled Else: The cuddled else style is shown below:
> if ( $flag eq "h" ) {
> $headers = 0;
> } elsif ( $flag eq "f" ) {
> $sectiontype = 3;
> } else {
> print "invalid option: " . substr( $arg, $i, 1 ) . "\n";
> dohelp();
> }
>Which one is preferable.
>
I usually use cuddled else.
>5. Horizontal Tightness: This controls the spacing for items in
>"containers." Here are the various options:
> if ( ( my $len_tab = length( $tabstr ) ) > 0 ) { # -pt=0
> if ( ( my $len_tab = length($tabstr) ) > 0 ) { # -pt=1 (default)
> if ((my $len_tab = length($tabstr)) > 0) { # -pt=2
>Note that that was for parentheses. There are similar options for
>square brackets, curcly braces, and code block curly braces.
>
No rules for me. Probably pt=2 most of the time. Not that when the
condition is complex, I sometimes use multi-line writting.
>Those are a few of the major ones; however, there are more options at
>http://perltidy.sourceforge.net/stylekey.html. If you can think of
>anything else that would be beneficial style-wise, let me know. If you
>would please give me your comments and opinions (preferably along with
>why you think that way would be best for Koha), I would greatly
>appreciate it. Hopefully we will be able to get a standard style for
>Koha from this thread.
>
Usually, I prefer less line-eating form of coding. For example :
Opening Vertical Tightness
$dbh = DBI->connect( undef, undef, undef,
{ PrintError => 0,
RaiseError => 1
}
);
and NOT :
$dbh = DBI->connect(
undef, undef, undef,
{
PrintError => 0,
RaiseError => 1
}
);
--
Paul POULAIN
Consultant indépendant en logiciels libres
responsable francophone de koha (SIGB libre http://www.koha-fr.org)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-devel/attachments/20030513/1d35fce3/attachment-0002.htm>
More information about the Koha-devel
mailing list