Commit d6d981

2026-01-15 16:26:15 Melisha Dsouza: Android Coding Standards
/dev/null .. CMMI/Guidelines/Coding Standard/Android Coding Standards.md
@@ 0,0 1,96 @@
+ # **Android Coding Standards**
+
+ ### **1. Objective**
+ To ensure all Android applications developed at Enovate follow a consistent, high-quality, and maintainable coding approach that aligns with organizational and industry best practices.
+
+ ### **2. Scope**
+ Applies to all Android development projects using Kotlin or Java, developed in Android Studio, and maintained under Enovate’s repositories.
+
+ ### **3. Architecture & Project Structure**
+ * Adopt MVVM or Clean Architecture.
+
+ Maintain a consistent project folder structure:
+ ```
+ app/
+ ├── data/
+ │ ├── models/
+ │ ├── network/
+ │ ├── repository/
+ ├── ui/
+ │ ├── activities/
+ │ ├── fragments/
+ │ ├── adapters/
+ │ ├── composables/
+ │ ├── viewmodels/
+ ├── utils/
+ ├── di/
+ ├── resources/
+ ```
+ * Separate business logic from UI logic.
+ * Avoid placing all logic inside Activities/Fragments/Composables.
+
+ ### **4. Naming Conventions**
+
+ | Element | Convention | Example |
+ | -------------- | -------------------------- | --------------------------- |
+ | Class names | PascalCase | `UserProfileActivity` |
+ | Variable names | camelCase | `userName`, `isActive` |
+ | Constants | UPPER_SNAKE_CASE | `MAX_RETRY_COUNT` |
+ | XML IDs | lowercase_with_underscores | `btn_submit`, `tv_username` |
+ | Packages | lowercase | `com.enovate.appname.ui` |
+
+ ### **5. Code Formatting & Style**
+ * Indentation: 4 spaces
+ * Maximum line length: 120 characters
+ * Avoid unused imports, variables, or commented code.
+ * Add KDoc/Javadoc for all public classes, methods, and complex logic.
+ * Use `val` instead of `var` wherever possible for immutability.
+ * Follow Kotlin official style guide: https://developer.android.com/kotlin/style-guide
+
+ ### **6. UI/UX & Resource Management**
+ * Use Jetpack Compose for new apps
+ * Use ConstraintLayout for flexible designs (if opting for XML).
+ * Define colors, strings, and dimensions in XML resources (no hardcoding).
+ * Use themes and styles consistently.
+ * Follow accessibility guidelines (content descriptions, contrast).
+
+ ### **7. Networking & Data Handling**
+ * Use Retrofit + OkHttp for REST APIs.
+ * Use Room / DataStore for local storage.
+ * Handle API responses using sealed classes or Result wrappers.
+ * Centralize API endpoints and keys (e.g., in `Constants.kt`).
+ * Avoid network calls on the main thread.
+
+ ### **8. Error Handling & Logging**
+ * Use `try-catch` only where needed.
+ Log using Timber:
+ ```
+ Timber.d("Loading user profile...")
+ Timber.e(exception, "Error loading user profile")
+ ```
+ * Disable logs in production builds.
+
+ ### **9. Security & Performance**
+ * Don’t store sensitive data in plain text or shared preferences.
+ * Use ProGuard/R8 for code obfuscation.
+ * Optimize image and JSON parsing.
+ * Avoid memory leaks (use ViewBinding, avoid static context references).
+
+ ### **10. Testing**
+ * Write Unit Tests for ViewModels and business logic.
+ * Write UI Tests using Espresso.
+ * Maintain at least 70% coverage for core modules.
+ * Use MockK or Mockito for mocking.
+
+ ### **11. Automation & CI/CD Integration**
+ * Integrate static analysis tools:
+ * ktlint – Formatting and style.
+ * Detekt – Code smell detection.
+ * Android Lint – XML and resource validation.
+ * CI/CD should fail the build if violations are detected.
+
+ ### **12. References**
+ - Jetpack Compose
+ - Android Developers Style Guide
+ - Google Java Style Guide
+ - Clean Architecture for Android
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9