underscore prefix on method parameters

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

underscore prefix on method parameters

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:09 pm

by cnwep1 >> Wed, 17 Jul 2002 7:04:39 GMT

Hello,

Danger! Trivia ahead!

I've noticed an alarming increase in the practice of using underscores to prefix parameter names in methods e.g. issileLauncher::doSomethingExciting( _atomBomb : AtomBomb; _city : Target );

Now call me old fashioned but I thought there was an unwritten convention in Jade that hidden methods and features of classes defined in RootSchema etc. were prefixed with '_' e.g. Btree::_values. If this is so then shouldn't we really be using some other prefix (if one is needed) to indicate to readers that we're referencing a parameter?

What conventions do others use for this kind of thing?

Anyone for 'p'?

Time for bed,

Cheers,

Eric in Dunedin (dark and calm and cool and clear)

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: underscore prefix on method parameters

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:09 pm

by JensRichnow >> Wed, 17 Jul 2002 8:31:51 GMT

Hi,

yes, the underscores are on the move. I have to admit I don't use it, probably more for 'aesthetic' reasons and clear naming conventions. Since unwritten coventions are not enforceable we will see the underscores more often. I noticed the use of underscores more frequently in Java circles, especially books, whereby underscored fields often represent private members of a class. The identical not-underscored name is then used as argument to methods. In some sense it is not a bad idea since often enough you face the situation were you have to name an argument and would like to name it according to its purpose - but you had the idea already with an attribute on the class (especially SETter methods, etc.). I often end up with some weird abbreviated name.

So, I feel it is a matter of personal preference and, for some developers, also a matter of conveying a clear intention.

P.S. Does living in Duniden has repercussion on finding poignant examples!?

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: underscore prefix on method parameters

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:09 pm

by cnwep1 >> Wed, 17 Jul 2002 21:14:05 GMT
<SNIP>

P.S. Does living in Duniden has repercussion on finding poignant examples!?

I think the example was inspired by the military hardware on view from my office - the formidable HMNZS Moa - see http://www.navy.mil.nz/reserve/boats.cfm

Eric in Dunedin (frosty, sunny start to the day, high cloud coming over)

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: underscore prefix on method parameters

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:09 pm

by cdshearer >> Wed, 17 Jul 2002 20:43:39 GMT

Hello Eric

I've taken to using a 'p' to prefixing all parameters to methods. It soon becomes habit.

Craig

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: underscore prefix on method parameters

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:09 pm

by cnwdad1 >> Wed, 17 Jul 2002 21:15:02 GMT

Yes, there is a definite risk of conflicting with JADE features in subsequent versions. In fact, I've heard a rumour that in a future release of JADE, the use of the underscore *may* be prevented.

A prefix of "p" is the most common alternative that I've seen, and I use it myself.

regards,
darrell.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: underscore prefix on method parameters

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:09 pm

by JensRichnow >> Wed, 17 Jul 2002 23:08:05 GMT

If there are discussions regarding naming conventions why not have an 'official' guideline similar to Java and other languages saying identifier names have to start with a letter, an underscore or a dollar sign - period (example from Java). This avoids confusion, rumour, unwritten conventions, etc. and clearly separates the plant's naming space from that of the rest .....

cheers

Jens

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: underscore prefix on method parameters

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:09 pm

by allistar >> Thu, 18 Jul 2002 5:13:04 GMT

I hope not as we use underscore prefixes almost exclusively in our Schema. The reason is that we have "set" and "change" methods on each class, and the parameters in the method signature are identical to the corresponding database property with the inclusion of this prefix. It makes it very easy to tell what parameters will update which
properties.

If it does get prevented I hope that Jade will somehow convert all existing methods to something that still works instead of leaving it
up to us to change (somewhat time consuming in a 1.2 million lines of code Jade system).

Allistar. ------------------------------------------------------------------
Allistar Melville
Software Developer
Auckland, NEW ZEALAND

Greentree International,
Developer of Greentree Financial Software. ------------------------------------------------------------------

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: underscore prefix on method parameters

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:10 pm

by torrie >> Mon, 12 Aug 2002 12:41:10 GMT

There has been several discussions about prefixing name of properties and classes in base schemas. Card schema for example uses cn as a prefix to class names and method names. This allows people using the card schema not to conflict with names. We are doing similar things with our schemas as well.

If Jade are going to use _ to prefix their system names then it would be helpful if they publish a list of their naming standards to allow us to design systems with object, constant and method names that will not conflict with the Jade system ones.

If they have allowed us to use underscores up until now, then they shouldn't stop us, but just inform us that we may conflict on their names.

I find _ is a little more readable than p but if I may conflict with Jade then I'll have to change my ways!

Torrie


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 14 guests