Saturday, 11 May 2013

What Is Hungarian?


Hungarian notation:

It is one of the naming conventions followed by the sun micro system for naming predefined, class/interface/predefined methods and data methods.

Hungarian

Rule 1 for class and interface


"If any class name or interface name", is containing either one word or more than one word. All words first letter must be capital.
EX:


       Normal Notation
          
         Hungarian  Notation
  System
 Action event
Number formal exception array index out  of bounds exception.
  System
  Action event
 Number formal exception array index out of bounds exception.
          

Hungarian Rule 2 for the methods


If any method is containing either one word or more then one word, then one word first letter is small and rest of sub-sequence words first letter must be capital.
EX:

              Normal notation
         Hungarian  notation
  Print/n()
Action perform()
Item state change()
  Print/n()
Action perform()
Item state change()

Hungarian Rule 3 for the methods:

If we are using any predefined data members then all the data member must be  in capital letter.
 If the data member contains more than one word, than they be separated by underscore (-).

               Normal
Hungarian
  PI
MAX-PREORITY
SCROLLBARS-VERTICAL ONLY.
   PI
MAX-PREORITY
SCROLLBARS-VERTICAL ONLY.


The above rules are mandatory for predefined Class/Interface, method and data members.

The above rules are optional for user defined Class/Interfaces, method and data members. Software industry is always recommended to Java programmers apply the Huainan rules even for user defined class/interfaces, methods and data members.

1 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More