Code reviews, styles and solutions with Software Engineer @sudocode

Gaurav Sen
Gaurav Sen
97.1 هزار بار بازدید - 4 سال پیش - Code reviews are what we
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.


Code repository: https://github.com/coding-parrot/yout...
System Design Video Course: https://interviewready.io
System Design book - https://amzn.to/2yQIrxH
System Design Playlist: System Design Playlist

You can follow me on:
Github: https://github.com/InterviewReady/
LinkedIn: LinkedIn: gaurav-sen-56b6a941
Twitter: Twitter: gkcs_

#SoftwareEngineering #GoodCodingPractices #CodeReview
4 سال پیش در تاریخ 1399/02/27 منتشر شده است.
97,163 بـار بازدید شده
... بیشتر