Документация
HTML CSS PHP PERL другое

Section 3.7.  Abbreviations

 
Previous
Table of Contents
Next

3.7. Abbreviations

Abbr idents by prefx.

If you choose to abbreviate an identifier, abbreviate it by retaining the start of each word. This generally produces much more readable names than other approaches. Fr xmpl, bbrvtng wrds by rmvng vwls cn prdc mch lss rdbl nms[*].

[*] Dmttdly, ts nt mpssbl t dcphr dsmvwld dntfrs r thr bbrvtn schms, bt t ds tk mch mr ffrt wtht cnfrrng ny clr bnfts (prt frm mby llwng y t ptch cd v SMS, nd pssbly csng yr pnty-hrd bss's hd t xpld!). Lk hw mch tm yv lrdy wstd jst nrvllng ths ftnt!

This example is easily comprehended:


    use List::Util qw( max );

    DESC:
    for my $desc (@orig_strs) {
        my $len = length $desc;
        next DESC if $len > $UPPER_LIM;
        $max_len = max($max_len, $len);
    }

This usage is not nearly as simple to decipher:

    use List::Util qw( max );

    DSCN:
    for my $dscn (@rgnl_strgs) {
        my $lngh = length $dscn;
        next DSCN if $lngh > $UPPR_LMT;
        $mx_lngh = max($mx_lngh, $lngh);
    }

Note that, when you're abbreviating identifiers by prefixing, it's acceptableand often desirableto keep the last consonant as well ($orig_strs, prefx( ), and so on), especially if that consonant is a plural suffix.

This rule need not be applied to identifiers that are well-known standard abbreviations. In such cases, it's better to use the "native" abbreviation strategy:


    $ctrl_char = '\N{ESCAPE}';

    $connection_Mbps  = get_bitrate( ) / 10e6;

    $is_tty = -t $msg_src;

"Ctrl" is preferable because it appears on most keyboards, whereas $con_char could be misread as "continuation character". "Mbps" is the standard unit, and the alternative ($connection_Mbits_per_sec) is far too unwieldy. As for "tty", "src", and "msg" (or "mesg"), they're all in common use, and the alternatives"term", "sou", or "mess"are either ambiguous, obscure, or just plain silly.

    Previous
    Table of Contents
    Next
    © 2000- NIV