Code Style Guide
This guide covers coding standards for contributing to DNS-MNS.General Principles
- Keep it simple - DNS-MNS should be easy to understand and modify
- Be consistent - Follow existing patterns in the codebase
- Comment wisely - Explain the why, not the what
- Test thoroughly - Verify changes work on multiple platforms
Bash Script Standards
Indentation
Use 4 spaces for indentation (not tabs):Variable Naming
Use descriptive, lowercase names with underscores:Quoting
Always quote variables to prevent word splitting:Function Definitions
Use descriptive function names with lowercase and underscores:Local Variables
Uselocal for function variables:
Conditionals
Use[[ ]] for bash conditionals (more features, safer):
Error Handling
Check command results and handle errors:Comments
When to Comment
Comment on:- Complex algorithms
- Non-obvious logic
- Platform-specific workarounds
- Important decisions
Function Documentation
Document complex functions:File Organization
Script Structure
Organize scripts in this order:- Shebang and header
- Constants and configuration
- Utility functions
- Core functions
- Main menu functions
- Main execution