realbasic-betas.mbox
[Top] [All Lists]

Re: auto-complete doesn't understand local vs. global variables

To: REALbasic Betas <realbasic-betas at lists dot realsoftware dot com>
Subject: Re: auto-complete doesn't understand local vs. global variables
From: Chris Little <cslittle at mac dot com>
Date: Sat, 29 Jun 2002 14:24:49 -0400
on 6/29/02 12:17 PM, Matt Neuburg at matt at tidbits dot com wrote:

> I would deny that. I always use self if I don't mean a local ("Implicit
> Self Called Harmful", don't get me started), and I frequently use a pattern
> where I dim myThing locally, calculate and set its value, then pass it up
> to self.myThing. It works fine. If it's a bad thing the compiler should
> flag it. If it's not then autocomplete should work the same way as the
> compiler.

As I gingerly step into discussion of coding styles (bordering on religion
for some)...

I think that having local variables with the same name as properties leads
to code that is fragile and could create maintenance problems later.

Always writing self does help but when others read your code and don't know
your style guidelines it would be easy for them to misread your code.

When I write code I always try to write as it I had to read the code out
loud.  Plain english names, avoid abbreviations.  Properties get prefixed
with 'm' (for member, a hold over from my c/c++ programming), 'a' for local
variables and 'g' for globals.

Class names get a two or three letter prefix (the prefix usually relates to
the project or team that made the class) in an attempt to avoid collisions
with classes from other projects and improve code reuse.

Constants get prefixed with a 'k' and then a two or three letter prefix
(usually the same prefix used by the class names).

As with any coding standard, transparency and consistency are the most
important things.

Chris



<Prev in Thread] Current Thread [Next in Thread>