Code reviews are what we are doing now: a run through of someone's code to check for correctness and code quality. They are useful because another pair of eyes can catch bugs and problems easier than the person writing the code.
Some considerations during code reviews:
Know what you are reviewing. Knowing the code context is important.
Look for bad code smells. Refer to the refactoring book in the description for this.
Factors for good code: readability, correctness, performance.
If you are unsure, do not sign off the review.
Expect tests backing up the author's claims.
Things to keep in mind:
Look for problems. Only suggest solutions.
Don't have long discussions of solutions with other reviewers here. Set a meeting or make a separate report. (Link it to the review later)
Don't try and score points during the review. Don't mention irrelevant or complex solutions to sound cool. (Especially for the fresher engineers)
Don't be nitpicky to sign-off. Fix the code yourself if you have a lot of nitpicky issues. Trust your teammates to improve themselves as they spend time looking at your code.
Offload general issues to the build manager. Styling, formatting, conventions etc… can be parser checks. Test coverage must be compulsory before sending a pull request, etc…
Some tricks for readability:
Use an IDE when doing the review.
Move magic numbers and strings to constants and Enums.
Complex maps should be objects. Nested loops should be broken into functions or graph searches.
Name variables and functions by what they do instead of how or why they do it.
Move common object conversions, validations and other pieces of code to common Utils.
Some tricks for performance:
Use singletons and resource pools where you can.
Constructing and Configuring a client is tricky. There should be dependency injection here.
IO calls are expensive. Use caching, request collapsing and batch queries to reduce load.
Some tricks for resource management:
Make sure resources are being released.
Make sure that race conditions are dealt with.
Logging is critical when handling resources. Log with context.
Designing Data Intensive Applications -
System Design Playlist:
Become a channel member!
You can follow me on:
#SoftwareEngineering #GoodCodingPractices #CodeReview