Tuesday, 4 July 2017

Naming Conventions in JAVA


  • Java follows camel-case syntax for naming the class, interface, method and also variables.

This shows how to maintain naming conventions when we are using JAVA.(Must and should follow)

    Type                                      Rules                                                                                        example

Packages : The prefix of a unique package name is always written in all-lowercase               : book, project


Classes    : Class names should be nouns, in mixed case with the first letter of each
    (or)        internal word capitalized. Try to keep your class names simple and descriptive.   : Class Project, MyFunction etc.
Interfaces


Variables : Methods in mixed case with the first letter lowercase, with the first letter of          : myFunction(); run(); getContent(); etc
     (or)      each internal word capitalized.
Methods


Constants: These should be in uppercase letter only.                                                           : WHITE, GREEN, MIN_PRIORITY etc.

Advantage:

  1. By using standard Java naming conventions, we could make code look much easier to read the program to yourself and also to other programmers.
  2. Why we are stressing is, in Java Readability is the main thing to consider.
  3. It makes user understand code in LESS time.