Writing Robust Code, Code Reviews, and Collaborative Development Flashcards
What defines robust code?
Robust code:
Handles unexpected situations gracefully.
Resilient to errors and recovers without crashing.
Maintainable and adaptable over time.
Why does robustness matter in software development?
Enhanced Reliability: Builds user trust.
Reduced Maintenance Costs: Fewer bugs to fix.
Improved User Experience: Smoother software performance.
What is defensive programming?
An approach to anticipate and handle errors to ensure resilience and maintain system stability.
What are best practices for error handling?
Catch and handle exceptions gracefully using try-catch.
Provide clear, meaningful error messages.
Apply the Fail-Fast Principle to detect and stop errors early.
Why is input validation important?
It prevents invalid or malicious data by ensuring inputs meet the required range, format, and type.
What is the purpose of logging?
Records significant events and errors.
Aids in debugging and post-mortem analysis.
Helps understand software behavior.
What are the goals of code reviews?
Catch bugs early.
Promote knowledge sharing.
Ensure adherence to standards.
Enhance code quality and maintainability.
What are the essentials of a good code review?
Consistent coding style.
Readability and documentation.
Comprehensive error handling.
Adequate test coverage.
What tools support automated code analysis?
Linters: Detect errors (e.g., ESLint).
Static Analyzers: Find vulnerabilities (e.g., TypeScript).
Code Formatters: Enforce styling (e.g., Prettier).
What are best practices for version control?
Use Git or similar tools.
Employ branching strategies:
-Main Branch: Stable code.
-Feature Branches: New features.
-Release Branches: Finalizing versions.
What are the steps in a collaborative Git workflow?
Create repository.
Clone locally.
Create a branch.
Write and commit code.
Push changes and open a pull request.
Run automated tests.
Conduct a code review.
Merge when approved.