
汚いコードを書けないように、コーディングスタイルをここでもとめます。
- Objectsとmodulesの名前は大文字で始まります (eg:
My::Module
). - Methods は "_" でスペースと代わります (eg:
get_value()
,set_value()
,print_report()
). - return TRUE/FALSEのmethods/subsの名前は"is" で始まります(eg:
is_valid_type()
,is_valid_age()
) - sub/methodが一つのargumentだけだったら、arrays、hashes、referencesを使わず、直接に引き出します (eg:
is_valid_type($type)
) - sub/methodが一つ以上の argumentを持ってる場合、hash や hash referenceという形で引き出します (eg:
print_report({-colored=>1, -monthly=>0})
) - sub/methodがstaticやprivateの場合、 "_" で名前を付けます (eg:
sub _internal{}
) - Moduleにはスペースが入らなくて、大文字でセグメントします (eg:
MixedCaseNoUnderscores
) - Constants はスペースの代わりに"_" にして、全部大文字にします (eg:
UPPERCASE_WITH_UNDERSCORES
) - Package はスペースの代わりに"_" にして、大文字でセグメントします (eg:
Mixed_Case_With_Underscores
) - Function variablesはスペースの代わりに"_" にして、全部小文字にします (eg:
lowercase_with_underscores
)
0 留言:
發佈留言