Re: Hungarian notation pros vs cons
- From: "Ronald S. Cook" <rcook@xxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 14:19:26 -0700
All good points.. thanks.
But what about in the database where you can't organize by namespace? In my
example, "System" is an entity in our design. Cable companies are called
MSOs: Multiple System Operators, so a "System" is owned by an "MSO".
If you don't have a tblSystem type of naming convention, then you must get
creative and name the object other than what best fits the need
("CableSystem" (blech)).
So if this situation warrants a prefix, why not go ahead and do throughout?
I do it on columns too (colID, colFirstName) so that when you need a column
named Date, you don't have the problem there as well.
"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1e49c96b4b77fa4398cd96@xxxxxxxxxxxxxxxxxxxxxxx
> Ronald S. Cook <rcook@xxxxxxxxxxxx> wrote:
>> An ongoing philosophical argument, I would like your opinions. With the
>> release of .NET, Microsoft spoke of moving away from the notation as a
>> best
>> practice. I'm a believer for a few reasons:
>>
>> 1) Consistency throughout and knowing which objects are yours
>> (clsEmployee, tblEmployee, frmEmployee, etc).
>
> The fact that you can tell which types are yours proves it
> *inconsistent* with the rest of the framework.
>
>> 2) Not having to name an employee form EmployeeForm.aspx because the
>> mane is already taken by your class named Employee.cs
>
> You mean you have your forms in the same namespace as your business
> objects? Even if namespaces didn't solve this, Employee would be a bad
> name for a form, because in no way does "Employee" indicate the actual
> purpose of the type.
>
>> 3) We once had a major entity "System" in our model. Because it's
>> reserved name, would have to alias somehow anyway.
>
> That's no reason to use Hungarian notation - you can rename it
>
>> 4) I just created a form "Login.aspx" in an ASP.NET 2.0 app. That's
>> now
>> a conflict with the new "Login" control.
>
> LoginForm then?
>
>> Does anyone disagree with using Hungarian notation?
>
> Very much so.
>
>> If so, I'd be
>> interested to hear specific bullets of why you don't like it (and also
>> what
>> you would do to avoid naming conflicts).
>
> 1) It makes the code hard to read "out loud" in your head. This is my
> main bugbear.
>
> 2) You can change types without having to change variable and type
> names everywhere. (If your class becomes a struct or vice versa, why
> should the name need to indicate that?)
>
> 3) It's not actual true Hungarian in the first place. True Hungarian
> notation was meant to make it obvious that although you might store
> both a height and a weight in float variables, they were effectively
> different units. (That's just an example, obviously :)
>
> 4) It's inconsistent with the rest of the framework. Ideally, your own
> code should just blend in with the framework code - you should be able
> to use the framework classes and your own classes as easily as each
> other, and transparently.
>
> 5) What use is "cls" anyway, when almost everything is a class? There
> are far more possible types than memorable abbreviations.
>
> 6) Reinforcing point 1 in a way, but in a slightly different tack - it
> keeps the details of the underlying implementation of the code too
> tightly coupled with what the code is trying to achieve. Most of the
> time, when I'm reading code, I want to just see what it's doing. I'll
> assume the types are sensible - if I see a variable called "name" I'll
> assume it's probably a string unless I see anything to the contrary,
> for instance. The extra type information in every identifier just adds
> to the "noise".
>
> --
> Jon Skeet - <skeet@xxxxxxxxx>
> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
> If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: Hungarian notation pros vs cons
- From: Jon Skeet [C# MVP]
- Re: Hungarian notation pros vs cons
- References:
- Hungarian notation pros vs cons
- From: Ronald S. Cook
- Re: Hungarian notation pros vs cons
- From: Jon Skeet [C# MVP]
- Hungarian notation pros vs cons
- Prev by Date: RE: how to set the value in html select control
- Next by Date: Re: Member variables style questions
- Previous by thread: Re: Hungarian notation pros vs cons
- Next by thread: Re: Hungarian notation pros vs cons
- Index(es):
Relevant Pages
|