Re: A few beginner questions
Re: A few beginner questions
- Subject: Re: A few beginner questions
- From: "Clark Cox" <email@hidden>
- Date: Mon, 7 Apr 2008 14:31:39 -0700
On Mon, Apr 7, 2008 at 1:17 PM, David Rowland <email@hidden> wrote:
>
> >
> > For those that may not know what this is, it is declaring the variable
> type in the name; for example dblNumberOne or intTempOne. I was just
> curious, this teacher seems to be pretty good but his code sometimes makes
> no sense or he do things certain ways, just because that is the way you are
> supposed to do them, giving us no reason for it.
> >
>
> The source code should BE the documentation as far as possible. Knowing the
> type of a variable is important, but even more important is knowing its
> purpose. If the name can reflect both, fine. Names like "dblNumberOne" or
> "intTempOne" are little help.
My personal feelings on this have always been:
1) If I cannot see an entire function/method in one screen-full, then
it is too long and needs to be broken up.
2) I always define local variables as close to their use as possible.
(in C++ and C99, variables can be declared anywhere inside a block;
not just at the start of it)
3) It follows from #2 and #3 that if I can see the definition of the
variable, then it is a local variable, and if not then it is an
instance variable.
and finally:
4) The names of variables should be descriptive enough that the type
of the variable should be obvious.
These rules have served me well, and also mean that hungarian-isms
indicating type are largely redundant, and can be avoided like the
warts that they are. :)
--
Clark S. Cox III
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden