1. Derek's naming convention for variables

Reading through various people's code recently, prompted me to ask about
Derek's convention for naming variables.
    pVar refers to a parameter variable - yes?
    lVar refers to a local variable?
    vVar would refer to ??
    I guess there's gVar for a global variable?

Are there others?

Secondly: What's the difference between a local and a private variable?

Many thanks

Alex Caracatsanis

new topic     » topic index » view message » categorize

2. Re: Derek's naming convention for variables

Alex Caracatsanis wrote:
> 
> Reading through various people's code recently, prompted me to ask about
> Derek's convention for naming variables.
>     pVar refers to a parameter variable - yes?
>     lVar refers to a local variable?
>     vVar would refer to ??
>     I guess there's gVar for a global variable?
> 
> Are there others?

Derek answered some of these questions a couple of years ago:
http://tinyurl.com/yu27hy

-- 
Craig

new topic     » goto parent     » topic index » view message » categorize

3. Re: Derek's naming convention for variables

Alex Caracatsanis wrote:
> 
> Reading through various people's code recently, prompted me to ask about
> Derek's convention for naming variables.
>     pVar refers to a parameter variable - yes?
>     lVar refers to a local variable?
>     vVar would refer to ??
>     I guess there's gVar for a global variable?
> 
> Are there others?
> 
> Secondly: What's the difference between a local and a private variable?
> 
> Many thanks
> 
> Alex Caracatsanis

I should let Derek answer this, but I've bookmarked the page where he discusses
it:
http://www.openeuphoria.org/cgi-bin/esearch.exu?fromMonth=6&fromYear=1&toMonth=2&toYear=B&postedBy=derek+parnell&keywords=%22naming+convention%22

I like it, but my preference would be for local variables to be undecorated.
Plus when I see 'p' I think of "pointer to".

I haven't adopted it myself, but I still like it.
--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Derek's naming convention for variables

Alex Caracatsanis wrote:
> 
> Reading through various people's code recently, prompted me to ask about
> Derek's convention for naming variables.

As pointed out, I've given a description before, but I don't think I've
explained why I like doing it this way.

I'm trying to solve a few (of the many) problems with writing and maintaining
code:
(1) Avoid accidently using reserved words.
Most reserved words in languages tend to be normal English words or commonly
used abbreviations for them. And they tend to be all in one case, mostly
lowercase. My scheme uses mixed case and avoids most English words.
(2) Where did I define that?
Using 'scope' as the prefix helps me narrow down where to look for a specific
declaration. Not always does one have access to an intelligent IDE to help find
stuff.
(3) What affects that?
When looking at a using a variable that has already been declared, I often need
to know what will be the side-effects, if any, of changing it's value. It helps
me to know the scope of the variable so I can target my search for side-effects.

This scheme is useful to me but I don't exect it to have universal appeal.

The down-sides include that lowercase 'L' looks a lot like the digit one with
many fonts, so I choose a font that makes the difference clear. (In fact I have
made modification to the Courier font to get it right). Another is that is a
manual system so sometimes I screw up and misname stuff.

Anyhow, I still prefer it to other schemes I've been exposed to.

-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

new topic     » goto parent     » topic index » view message » categorize

5. Re: Derek's naming convention for variables

Derek Parnell wrote:

> The down-sides include that lowercase 'L' looks a lot like the digit one with
> many fonts, so I choose a font that makes the difference clear. (In fact I
> have
> made modification to the Courier font to get it right). 

For that reason I use Monaco in my editors ...

http://www.wazu.jp/gallery/Monaco.gif

-- 
Craig

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu