-
Notifications
You must be signed in to change notification settings - Fork 0
Programming Tips & Tricks
Robbie Hume edited this page Jul 24, 2024
·
2 revisions
- Code should be readable, reusable, and maintainable
- Try to limit comments, the code should be simple enough to speak for itself
- Example: Over-commented code vs Concise code
- Use guard clauses at top of function
- Guard clauses check if a condition is met and terminates if it isn't
- They help you see where the core logic is and doesn't enter into it unnecessarily
- Group conditions together and reduce nesting
- Validate / handle inputs
- Assume that the inputs aren't always going to be correct, and have cases to validate and handle them when they aren't