Re: Hungarian notation pros vs cons

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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


.



Relevant Pages

  • Re: globals?
    ... Do you think that Tom knowes the namespace of "Turf"? ... Where a VisualBasic assembly method or constant has a Framework ... a Visual Basic programmer has a choice. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Hungarian notation pros vs cons
    ... be in a different namespace than Employee. ... typing, but only when you declare the object or are tryign to cast it. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: image filtering using .NET Compact Framework
    ... Framework) to a WinCE embedded development board (which only ... the developed application then converts these images (image processing ... this namespace is available when using the complete .NET ... but isn't supported in the .NET Compact Framework. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: U/LBound & copying arrays
    ... The only valid reasson i ever found to abandon the VB namespace completely was when i discovered that it wasn`t suported on the X-Box 360 ... In all other situations the VB namespace is part of the default framework and thus you have no extra dependancy or whatever it is there if you use it or not ... Be aware that VB6 has probably more in common with VB10 then with VB1 although some persons sometimes want you to believe something else. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Microsoft Losing Interest in C#?
    ... It should be in the framework so all .Net langs and MSH could ... My is a combination of a namespace within Microsoft.VisualBasic.dll and some ... My's functionality isn't *entirely* available in other ... I suspect many C# devs would either shun the namespace entirely or not be as ...
    (microsoft.public.dotnet.languages.csharp)