Friday, July 17, 2009

Object-Oriented Naming Convention

Object oriented programming languages (Java, C#, etc.) follow some fairly standard naming conventions with respect to classes, variables and methods.

Class names always start with a capital letter, and objects/variables and methods start with a lower case.
  • Classes: Object, Action, Date, GregorianCalendar
  • Objects: size (of class Dimension), date (of class Date), name (of class String)
  • Variables: year, month, length
  • Methods: indexOf, substring
Normally, spaces (even if syntactically allowed) and underscores are not used. Instead, names consisting of multiple words are delimited by using a capital letter to start each word. This is sometimes refer to as "camel case" because it looks like a camel with humps. An exception is variable meant to be constants.
  • Constants: BorderLayout.BEFORE_FIRST_LINE, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS
Method names often start with a verb (action) followed by the target object name.
  • Method names that start with a verb or action: setVisible, isSelected

1 comment:

  1. bet365 casino and sportsbook - Jordan13 Sports
    Bet365 replica air jordan 18 retro red is a privately held company show to buy jordan 18 white royal blue based new air jordan 18 retro men red in London, England. air jordan 18 retro yellow online site The firm offers sports betting, bingo, casino, poker, 슈어맨 bingo and gambling. Bet365 is