• Home
    • View
    • Login
    This page
    • Normal
    • Export PDF
    • Page Information

    Loading...
  1. Dashboard
  2. Undefined Space
  3. HotSpot
  4. StyleGuide

Page History

Versions Compared

Old Version 13

changes.mady.by.user Stefan Karlsson

Saved on Sep 30, 2014

compared with

New Version 14

changes.mady.by.user John Rose

Saved on Mar 30, 2016

  • Previous Change: Difference between versions 12 and 13
  • Next Change: Difference between versions 14 and 15
  • View Page History

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. #Classes
    Anchor
    Classes
    Classes
    Encapsulate code within classes, factor the code, and make it easy to understand.
  2. #Accessors
    Anchor
    Accessors
    Accessors
    Use public accessor functions for instance variables accessed outside the class.
  3. #Arrays
    Anchor
    Arrays
    Arrays
    Use arrays with abstraction supporting range checks.
  4. #Switches
    Anchor
    Switches
    Switches
    Always enumerate all cases in a switch statement or specify default case. It is ok to have an empty default with comment.
  5. #Asserts
    Anchor
    Asserts
    Asserts
    Use assert(...), guarantee(...), ShouldNotReachHere(), Unimplemented() and comments wherever needed. (Performance is almost never a reason to omit asserts.)
  6. #SimpleC
    Anchor
    SimpleC
    SimpleC
    Use single inheritance, no operator overloading, no C++ exception handling, and no goto statements. (There are a few uses of operator overloading, but these should be rare cases.) Be sparing with templates. Use only C++ features which will work correctly on all of our platforms.
  7. #NamedCons
    Anchor
    NamedCons
    NamedCons
    Assign names to constant literals and use the names instead. Use enum to name integer constants inside class definitions.
  8. #Booleans
    Anchor
    Booleans
    Booleans
    Use bool for booleans (not int), use true & false (not 1 & 0); use NULL for pointers (not 0).
  9. #Names
    Anchor
    Names
    Names
    Instance variable names start with underscore "_", classes start with upper case letter, local functions are all lower case, all must have meaningful names.
  10. #Ifdefs
    Anchor
    Ifdefs
    Ifdefs
    Ifdefs should not be used to introduce platform-specific code into shared code (except for LP64). They must be used to manage header files, in the pattern found at the top of every source file. They should be used mainly for major build features, including PRODUCT, ASSERT, _LP64, SERIALGC, COMPILER1, etc.

...

  • Type names and global names are mixed-case (FooBar).
  • Local names (fields, variables) and function names are lower-case (foo_bar). (For these, avoid mixing in upper case letters.)
  • Constant names in upper-case or mixed-case are tolerated, according to historical necessity.
  • Constant names should follow an existing pattern, and must have a distinct appearance from other names in related APIs.
    • Inside class definitions, integer constants can be defined with "static const".  (Historically, enums have been also been used.)
  • Class and type names are noun phrases. Consider an "er" suffix for a class that represents an action.
  • Getter accessor names are noun phrases, with no "get_" noise word. Boolean getters can also begin with "is_" or "has_".
  • Setter accessor names prepend "set_" to the getter name.
  • Other method names are verb phrases, as if commands to the receiver.
  • Avoid leading underscores (as "_oop") except in cases required above. (Names with leading underscores can cause portability problems.)

...

Overview
Content Tools
ThemeBuilder

Terms of Use
• License: GPLv2
• Privacy • Trademarks • Contact Us

Powered by a free Atlassian Confluence Open Source Project License granted to https://www.atlassian.com/software/views/opensource-community-additional-license-offer. Evaluate Confluence today.

  • Kolekti ThemeBuilder Powered by Atlassian Confluence 8.5.23
  • Kolekti ThemeBuilder printed.by.atlassian.confluence
  • Report a bug
  • Atlassian News
Atlassian
Kolekti ThemeBuilder EngineAtlassian Confluence
{"serverDuration": 926, "requestCorrelationId": "6cbe00cc0c73b8cc"}