Naming Convention
Aturan penamaan yang konsisten di seluruh platform mobile.
File Naming
| Platform | Convention | Contoh |
|---|---|---|
| Android (Kotlin) | PascalCase | UserViewModel.kt, HomeScreen.kt |
| iOS (Swift) | PascalCase | UserViewModel.swift, HomeView.swift |
| Flutter (Dart) | snake_case | user_view_model.dart, home_screen.dart |
| React Native (TS) | PascalCase (components), camelCase (hooks) | UserCard.tsx, useHomeScreen.ts |
Variable & Function Naming
| Tipe | Convention | Contoh |
|---|---|---|
| Variable | camelCase | userName, isLoading, itemCount |
| Constant | UPPER_SNAKE_CASE / camelCase | MAX_RETRY_COUNT, apiBaseUrl |
| Function / Method | camelCase | fetchUser(), onButtonTap() |
| Class / Type | PascalCase | UserRepository, HomeViewModel |
| Enum | PascalCase (type), camelCase (value) | UserRole.admin, LoadingState.idle |
| Interface / Protocol | PascalCase + suffix | UserRepository (Kotlin), UserRepositoryProtocol (Swift) |
| Private | underscore prefix (Dart) / private keyword | _userName, private userName |
Boolean Naming
Boolean variable wajib menggunakan prefix yang jelas:
✅ isLoading, isVisible, hasError, canSubmit, shouldRefresh
❌ loading, visible, error, submit, refresh
Screen / Page Naming
| Platform | Convention | Contoh |
|---|---|---|
| Android | *Screen | HomeScreen, ProfileScreen |
| iOS | *View | HomeView, ProfileView |
| Flutter | *Screen atau *Page | HomeScreen, ProfilePage |
| React Native | *Screen | HomeScreen, ProfileScreen |
API-Related Naming
| Tipe | Suffix | Contoh |
|---|---|---|
| API Service | *ApiService / *Api | UserApiService |
| DTO | *Dto / *Response | UserDto, UserResponse |
| Repository | *Repository | UserRepository |
| Use Case | *UseCase | GetUserUseCase |
| Data Source | *DataSource | UserRemoteDataSource |
Konsistensi
Pilih satu convention dan gunakan secara konsisten di seluruh project. Jangan campur *Page dan *Screen dalam satu project.