Subject: Re: [xsl] Standards checkers for XSLT From: Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx> Date: 24 Nov 2006 17:23:02 +0000 |
>>>>> "Dimitre" == Dimitre Novatchev <dnovatchev@xxxxxxxxx> writes: I agreed with all of that except: Dimitre> 3. Consistent use of naming rules: Yes, certainly, but not: Dimitre> -- camelCase notation This is a very bad convention. In general, the naming convention should be consistent with both the convention for the programming language as a whole (if there is one), and with the natural language used for names and comments. In the case of XSLT written in English, for instance, using hyphens seems the most consistent style: XSLT itself uses hyphens, e.g. generate-id (), xsl:strip-space English actually uses spaces where XSLT uses hyphens, but as most (all?) programming languages use spaces to separate tokens, and don't allow multi-token names, either the hyphen, or (preferably) something that resembles the effect of a space (such as an underscore) but is easily distinguihed from it is best. So for XSLT I recommend hyphens for multi-word identifiers. In a language like Java, which uses camelCase in it's standard libraries, you really have to go along with it, but it is a really bad convention. In a language like C++, which traditionally uses the underscore, you should certainly not consider and other convention. Unfortunately certain libraries (notably the entire win32 API) use the abysmall CamelCase stuff, so your source can't be 100% consistent in this case. Use the underscore. To see why camelCase is so bad compare: aLongAndRatherUnreadableIdentifier with: an_even_longer_but_perfectly_clear_choice_of_name (example comes from OOSC 2nd Edition p.880 *) Dimitre> -- pParameter, vVariable, ... etc. Hungarian Dimitre> notation examples. If such a convention is to be used (and I prefer it on the whole), again use hyphens (I prefer underscores again, but consitency with the XSLT/XPath style mandates hyohens): a-argument-names (for xsl:function) g-global-variable-or-parameter-names l-local-variable-or-parameter-names This avoids shadowing global names, which should never be done. No should you shadow any local names. Such a practice is a bug waiting to hapen. Don't follow the Hungarian notation practice of including the type in the name - declare your types - and keep the routines (templates and functions) short enough to be readable without scrolling. * Object Oriented Software Construction 2nd Edition. Copyright 1997 by Professor Bertrand Meyer. I recomend every programmer, no matter what language (s)he uses, to read this book at least once. -- Colin Adams Preston Lancashire
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Standards checkers for XS, Dimitre Novatchev | Thread | RE: [xsl] Standards checkers for XS, Michael Kay |
Re: [xsl] Standards checkers for XS, Dimitre Novatchev | Date | RE: [xsl] Standards checkers for XS, Michael Kay |
Month |