Following these conventions makes the repo easier to maintain and helps your pull requests get merged faster.
IDE Setup
Visual Studio Code (Recommended)
The repository contains VSCode configurations that automatically format your code.Install Visual Studio Code
Download from code.visualstudio.com
Install Haxe extension
Install the official Haxe extension from the VSCode marketplace.The extension will use the repo’s
hxformat.json to format code automatically.Whitespace and Indentation
The Haxe extension uses the repo’shxformat.json file to automatically format code.
Key formatting rules:
- Indentation: 2 spaces (not tabs)
- Line endings: LF (Unix-style)
- Trailing whitespace: Removed automatically
View hxformat.json configuration
View hxformat.json configuration
The repository’s
hxformat.json file controls all formatting rules. VSCode will apply these automatically when you save a file.Naming Conventions
Variables and Functions
Use lowerCamelCase for variables and functions:Classes and Types
Use UpperCamelCase for classes, interfaces, and type names:Constants
Use UPPER_SNAKE_CASE for compile-time constants:Descriptive Names
Code Comments
Function Documentation
Use JavaDoc-style comments for all public functions:- Automatic documentation generation
- IDE tooltips show function info
- Clear parameter and return value descriptions
Inline Comments
- DO ✓
- DON'T ✗
Good inline comments:What makes these good:
- Explain the “why”, not the “what”
- Clear and concise
- Proper capitalization and punctuation
Comment Guidelines
When to comment
When to comment
Only leave comments when code needs explanation:✓ Complex algorithms
✓ Non-obvious behavior
✓ Workarounds for known issues
✓ Important warnings✗ Self-explanatory code
✗ Obvious variable assignments
✗ Every single line
✓ Non-obvious behavior
✓ Workarounds for known issues
✓ Important warnings✗ Self-explanatory code
✗ Obvious variable assignments
✗ Every single line
Provide meaningful insight
Provide meaningful insight
Comments should explain:
- Why the code does something (not what it does)
- The purpose or reasoning behind a decision
- Edge cases being handled
Sign comments sparingly
Sign comments sparingly
Only sign your comments with your name when:
- Changes are complex and may require follow-up
- You’re introducing a temporary workaround
- Future developers might need to contact you
No Commented-Out Code
- Makes files longer and harder to read
- Confusing for other developers
- Old code can be found in Git history if needed
- Temporarily debugging (remove before committing)
- Documentation purposes (use clear explanations)
Imports
Imports should be:- Placed at the top of the file
- Grouped together
- Sorted alphabetically
- Conditional imports at the end
Function Arguments
Optional vs Default Arguments
- Use
?argumentwhen the argument should beNull<T>and default tonull - Use
argument = valuewhen the argument should have a default value but not be nullable - Never use both together
License Headers
The mainLICENSE.md file covers all code in the repository. Individual file headers are unnecessary and create clutter.
Quick Reference
Naming Cheat Sheet
| Type | Convention | Example |
|---|---|---|
| Variables | lowerCamelCase | playerHealth |
| Functions | lowerCamelCase | calculateScore() |
| Classes | UpperCamelCase | PlayState |
| Interfaces | UpperCamelCase | ISongLoader |
| Enums | UpperCamelCase | NoteDirection |
| Constants | UPPER_SNAKE_CASE | MAX_HEALTH |
Comment Cheat Sheet
✓ DO:- Use JavaDoc for public functions
- Explain why, not what
- Be clear and concise
- Use proper grammar and punctuation
- State the obvious
- Leave commented-out code
- Add personal opinions
- Use unclear abbreviations
VSCode Extensions
Recommended extensions for Haxe development:Haxe
Official Haxe language support
CodeDox
JavaDoc-style documentation comments
EditorConfig
Automatic formatting settings
GitLens
Enhanced Git integration
Next Steps
Contributing Guide
Learn how to submit code
Compilation Guide
Set up your dev environment
Troubleshooting
Fix common issues
GitHub Repository
View the source code
