This document describes the Java coding style of the Android Mobile SDK team. This guideline is recommended for compliance with all Java implementations of our products.
Beyond the guidelines defined in this document, we also recommend reviewing the Android official coding guidelines.
For more information about the Android Mobile SDK, see the developer documentation.
All code should be properly documented. Code documentation should adhere to JavaDoc format.
- Class and modules names are written in CamelCase.
- Classes that extend Android components should end with the name of the component, e.g. MASLoginFragment, MASEnterpriseWebApplicationActivity.
- Developer facing interfaces should start with MAS, e.g. MASUser, MASSecureLocalStorage.
- Resource file names are written in lowercase with underscores, e.g. mas_main_layout.xml, otp_validation.xml, ca_logo.png.
- Default Android Studio code style.
- Prefer constants over enums, unless you need enum-specific features.
- Use annotation @IntDef or @StringDef to represent a logical type and that its value should be one of the explicitly named constants.
- All UI related features should be located within the MASUI module. Tag parameters or return values with appropriate annotations such as @LayoutRes and @MenuRes if methods return or expect these types.
- Use Parcelable instead of Serializable when passing objects to activities or fragments.
- Avoid unnecessary logging.
- Include the class name as a tag for logging. e.g.
private static final String TAG = MAS.class.getCanonicalName();