Naming Conventions



Valid Names - Valid identifier names consist of both uppercase and lowercase letters, numbers, and the underscore character '_'. Valid names do not contain spaces and begin with a letter. In all of the following, acceptable name characters are letters, numbers, and underscores "_". Periods, quotaion marks, or any sybbols are not appropriate.

Valid Classes Names
  • Must begin with an uppercase letter

  • Each new word after the first must begin with an uppercase letter

  • No spaces in between words


  • valid and
    follows conventions
    valid, but
    does not follow conventions
    invalid
    Car
    FunTime
    ZooBuilding
    ComputerSciencesBuilding
    GroceryStore
    BabyFishMouthBabyFishMouth
    Foo
    FooBar
    FooBarBazBan
    foo
    fooBar
    Foo_Bar
    Foo Bar
    FoObAr
    FOOBAR
    FOO_BAR
    1foo
    Foo Bar
    Foo#Bar
    f o o b a r
    Foo-Bar


    Instance (object) Reference Identifiers,
    Method Names, and
    Primitive Data Identifiers

  • Must begin with a lowercase letter

  • Each new word after the first must begin with an uppercase letter

  • No spaces in between words


  • valid and
    follows conventions
    valid, but
    does not follow conventions
    invalid
    car
    funTime
    zooBuilding1
    zooBuilding2
    zooBuilding3
    computerSciencesBuilding
    localGroceryStore
    townGroceryStore
    smallGroceryStore
    largeGroceryStore
    babyFishMouthIsSweepingTheNation
    pecanPie
    harry
    sally
    foo
    fooBar
    fooBarBaz
    Foo_Bar
    FoObAr
    FOOBAR
    FOO_BAR
    Foo
    Foobarbaz
    Foobarbazban
    1foo
    foo Bar
    foo#Bar
    f o o b a r
    foo-Bar


    Class (and some instance) Constants
  • Must be all capital letters

  • New words begin with

  • No spaces in between words


  • valid and
    follows conventions
    valid, but
    does not follow conventions
    invalid
    MAXIMUM_CAR_MILAGE
    MINIMUM_CAR_MILAGE
    HEARTS
    SPADES
    CLUBS
    DIAMONDS
    RED_ORANGE
    YELLOW_GREEN_BLUE
    FUSCHIA_TAUPE
    RESET_VALUE
    PI_TO_THREE_DIGITS
    PI_TO_FIVE_DIGITS
    PI_TO_TEN_DIGITS
    PI_TO_ONE_HUNDRED_DIGITS
    FOO
    FOO_BAR
    FOO_BAR_BAZ
    maximum_car_milage
    MaximumCarMilage
    maximumCarMilage
    maximum car milage
    MAXIMUM CAR MILAGE
    currentCarMilage
    GasTank
    Foo
    foo
    foo_Bar
    GasTank.Maximum
    #!/usr/bin/perl/
    1FOO
    FOO-BAR