Re: Private variables question
- From: "Bruce McGee" <bmcgee@xxxxxxxxxxxx>
- Date: 30 Apr 2008 06:30:38 -0700
Phill Harvey-Smith wrote:
Hi,
This is more from a mater of interest than any technical reason, but
there seems to be a lot of code around where the private variables
are called FSomething e.g.
TYPE TSomeType=class(object)
PRIVATE
FLocalVar : INTEGER;
PUBLIC
PROPERTY LocalVar : INTEGER READ FLocalVar;
END;
What I guess i'm asking is why prefix it with 'F' ? I have been
tending to use 'Pr' in my own code for Private, I guess the compiler
does not care, just wondered why it seemed to be a convention ?
Some developers (like me) prefix private variables or _fields_ in a
class to make them easier to spot. I picked it up a long time ago
because it seemed to be a fairly common convention that made sense.
Kind of like prefixing classes with T, interfaces with I or arguments
with A (less common?).
I've also gotten into the habit of prefixing local variables with L.
This isn't so much to make them easier to spot (which it does), but to
make it less likely that a logically named local variable name won't
inadvertently hide another identifier with a higher scope and avoiding
difficult to find bugs.
Use whatever you feel comfortable with as long as you're consistent.
--
Regards,
Bruce McGee
Glooscap Software
.
- Follow-Ups:
- Re: Private variables question
- From: Dave Keighan
- Re: Private variables question
- From: Tom Corey
- Re: Private variables question
- References:
- Private variables question
- From: Phill Harvey-Smith
- Private variables question
- Prev by Date: Re: in-house development versus packaged solutions
- Next by Date: Re: Private variables question
- Previous by thread: Private variables question
- Next by thread: Re: Private variables question
- Index(es):
Relevant Pages
|