• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: A few beginner questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >A few beginner questions (From: matty jones <email@hidden>)
 >Re: A few beginner questions (From: David Rowland <email@hidden>)

  • Prev by Date: Re: A few beginner questions
  • Next by Date: Re: A few beginner questions
  • Previous by thread: Re: A few beginner questions
  • Next by thread: Re: A few beginner questions
  • Index(es):
    • Date
    • Thread