Re: To Richard Heathfield: enough's enough

From: Richard Heathfield (dontmail_at_address.co.uk.invalid)
Date: 12/28/03


Date: Sun, 28 Dec 2003 12:58:10 +0000 (UTC)

Gerry Quinn wrote:

<snip>

> Personally I use Hungarian-like constructs quite often. I would use
> "nLayers" rather than "layers" to refer to a number of layers, even when
> it's in the same function. Buttons have names like "but_Quit".

Well, this is more in the original spirit of Hungarian notation, where the
prefix denotes not the /type/ of the data, but the /purpose/ of the data.
In your example, the but_ prefix refers not to the data type of the object,
but to its purpose - i.e. "this is the thing you click when you want to
quit".

You could reasonably change the type of this button (perhaps from a Button
into an ImageButton) without changing the name, since it would still be a
button of some kind. Indeed, by choosing a slightly more general prefix
(e.g. "cmd"), you could justify retaining the name even if you changed it
from, say, a button into a menu entry. Furthermore, the chances are very
low that you might change it to something so radically different (such as a
TreeView) as to justify a prefix change without having to rewrite much of
the code anyway. So there's no huge downside here. In such circumstances,
there is a certain amount to be said for the prefix.

-- 
Richard Heathfield : binary@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton


Relevant Pages

  • Re: What is the standard for naming objects?
    ... When the prefix is not enough to determin an object's type then the variable name should pick up the slack. ... Example: A method for making the dog bark could be called: MakeDogBark(), ... Examples: storing someone's age in a byte: Dim iAge As Byte ... There is no need for data typing on local variables because functions/properties/etc are usually small enough that you can refer to the data type by simply looking up a few lines. ...
    (microsoft.public.dotnet.general)
  • Re: Run the Same Macro on Multiple Files
    ... which is all it needs for compilation. ... In JavaScript a "$" prefix is ... using the prefix to indicate data type). ... are the more serious issue (I've never had problems debugging type ...
    (microsoft.public.word.vba.general)
  • Re: Boolean Naming Conventions
    ... do you prefix every database column with the data type? ... all are fairly clear on the data type without saying it. ... why imply datattype in the name? ...
    (microsoft.public.sqlserver.programming)
  • Re: Boolean Naming Conventions
    ... do you prefix every database column with the data type? ... all are fairly clear on the data type without saying it. ... why imply datattype in the name? ...
    (microsoft.public.dotnet.languages.csharp)