Swift and SwiftUI conventions
File organization
Organize Swift files with clear MARK comments to separate logical sections:Naming conventions
Classes and structs use PascalCase:Property declarations
Use explicit types when the type is not obvious from the initializer:Access control
Be explicit about access levels:Async/await usage
Prefer async/await over completion handlers:SwiftUI view structure
Structure views with clear body composition:Comments and documentation
Use comments to explain why, not what. The code should be self-explanatory for what it does.- π Battery optimization
- π Performance optimization
- π΅ Playback-related
- πΎ Persistence/storage
- π Search-related
Error handling
Handle errors gracefully with user-friendly messages:State management
Use@Published properties for observable state:
Python conventions
File structure
Organize Python files with clear sections:Function and method naming
Use snake_case for functions and methods:Type hints
Always use type hints for function parameters and return types:Error handling
Use try-except blocks with specific error messages:Logging
Use appropriate log levels:Docstrings
Write clear docstrings for classes and public methods:Battery optimization comments
Use emoji prefixes for optimization-related code:Project organization
Directory structure
Maintain clear separation of concerns:File naming
- Swift files:
PascalCase.swift(e.g.,PlaybackManager.swift) - View files:
DescriptiveNameView.swift(e.g.,SearchResultsView.swift) - Model files: Plural for collections (e.g.,
MusicModels.swift) - Python files:
snake_case.py(e.g.,ytmusic_service.py)
Version control
Git ignore patterns
Donβt commit:- Build artifacts (
build/,DerivedData/) - Python virtual environments (
venv/,music_env/) - User-specific files (
.DS_Store,*.xcuserstate) - API keys and secrets (
.env,credentials.json)
Commit practices
- Make atomic commits (one logical change per commit)
- Write clear commit messages
- Donβt commit commented-out code
- Remove debug print statements before committing
Performance best practices
Battery efficiency
Memory management
Network efficiency
Testing guidelines
When testing your changes:- Test with all three music services (YouTube Music, Tidal, JioSaavn)
- Test playback controls (play, pause, seek, next, previous)
- Test queue management (add, remove, reorder)
- Test persistence (app restart, state restoration)
- Monitor console for errors and warnings
- Check memory usage in Instruments
- Test on different macOS versions if possible