Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
This is a Windows idea, known as Hungarian Notation. One of the holy wars of how to program. It is not very widely use outside of Windows programming, but it is used a lot there. Even at Microsoft it is not universally used, apparently the applications division likes it, and the OS division hates it.

In languages with static type-checking it makes little sense. Why? Well the compiler already did the work for you, and you have scattered your type decisions through your code. If later it is found that your byte needs to be an int, are you really going to rename everything? No. What will happen is that the type will get changed and people will then be living with a landmine because the variable names will now be documenting the wrong API.

In languages without static type-checking, it makes a bit more sense because (as you say) the language doesn't immediately do the type-checking for you. But not having type-checking is a design decision - you are being encouraged to let the language figure out how to handle your types. If you are designing things that care about types in a language that doesn't, then that is an impedance mismatch between you and the language. Either you need to figure out how to come up with type-agnostic designs, or else you need a language that suits your tastes better. But fighting the language design is always going to cause problems.

Personally I almost never use types in my naming schemes except as a way to produce a temporary variable which really has no better name. For instance $href will pop up when I need an anonymous hash for a short while. But anything longer will almost definitely get a real name. And if it deserves it, it gets its own class.

Incidentally I recommend Dominus's article on strong type-checking. It is quite interesting, if a bit off the current discussion.


In reply to Re (tilly) 3: Favorite Descriptive Variable Name by tilly
in thread Favorite Descriptive Variable Name by vroom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-19 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found