code review for ios
DESCRIPTION
Hi I’m Cris, iOS Developer in KLabCyscorpions. In this post, I want to share with you my presentation on Code Review guidelines for iOS. But, what is Code Review? According to Wikipedia: “Code Review is systematic examination (often known as peer review) of computer source code. It is intended to find and fix mistakes overlooked in the initial development phase, improving both the overall quality of software and the developers’ skills. Reviews are done in various forms such as pair programming, informal walkthroughs, and formal inspections.” Want to review code? Then First things first! For you to review code effectively, you need the basic know-how of reviewing code as both the developer and the reviewer. These slides will give some guidelines on how to think in both these roles when reviewing code.TRANSCRIPT
![Page 1: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/1.jpg)
Code ReviewCris Uy
![Page 2: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/2.jpg)
Agenda• Goals• Types of Code Review• Tips for Developers during Code Review• Tips for Reviewers during Code Review• General Guidelines• Control Structures• Error Handling• Resource Leaks• Performance• Maintainability and Reusability
![Page 3: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/3.jpg)
Goal
![Page 4: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/4.jpg)
• To spot and fix defects early in the process
![Page 5: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/5.jpg)
• Helps to maintain a level of consistency in design and implementation
![Page 6: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/6.jpg)
• Better shared understanding of the code base as team members learn from each other
![Page 7: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/7.jpg)
Types of Code Review
![Page 8: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/8.jpg)
Formal Code Review
• Involves software developers meeting together and reviewing relevant code line by line many times taking the opportunity to analyze printed copies of the materials
![Page 9: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/9.jpg)
Peer Code Review
• Can be done over the shoulder where the reviewer looks over the author’s shoulder as the other goes through the code
• Or can be done via email or version control system like Git and online conference
![Page 10: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/10.jpg)
Tips for Developers during Code Review
![Page 11: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/11.jpg)
• The primary reviewer is the author. • You
![Page 12: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/12.jpg)
• Create a checklist for yourself of the things that the code reviews tend to focus on
![Page 13: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/13.jpg)
• Understand and accept that you will make mistakes
![Page 14: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/14.jpg)
• No matter how much your knowledge is, someone else will always know more than you
![Page 15: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/15.jpg)
• Don’t rewrite code without consultation
![Page 16: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/16.jpg)
• The only constant thing in this world is change
![Page 17: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/17.jpg)
• Fight for what you believe, but gracefully accept defeat
![Page 18: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/18.jpg)
• Please note that review meetings are not problem solving meetings
![Page 19: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/19.jpg)
• Helping to maintain the coding standards
![Page 20: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/20.jpg)
Tips for Reviewers during Code Review
![Page 21: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/21.jpg)
• Critique code instead of people – be kind to the coder, not to the code
![Page 22: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/22.jpg)
• Treat people who know less than you with respect, deference and patience
![Page 23: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/23.jpg)
• Ask questions rather than make statements
![Page 24: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/24.jpg)
• Avoid the why questions
![Page 25: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/25.jpg)
• Remember to praise
![Page 26: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/26.jpg)
• Make sure you have good coding standards to reference
![Page 27: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/27.jpg)
• Remember that there is often more than one way to approach a solution
![Page 28: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/28.jpg)
• You should not rush through a code review – but also, you need to do it promptly
![Page 29: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/29.jpg)
• Review fewer than 200 – 400 lines of code at a time
![Page 30: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/30.jpg)
General Guidelines
![Page 31: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/31.jpg)
• Is the code following coding guidelines and naming conventions?
• Reviewer should have a reference for coding guidelines and conventions
![Page 32: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/32.jpg)
• Are all compiler warnings fixed?
![Page 33: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/33.jpg)
• Are there leftover code for testing/development?
![Page 34: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/34.jpg)
• Is the code complexity under the maximum allowable threshold for a given metric?
• *a class is less than 500 lines• *a method does not contain more than 15
control structures
![Page 35: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/35.jpg)
Control Structures
![Page 36: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/36.jpg)
• Check for infinite loops?
![Page 37: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/37.jpg)
• Does the loop iterate the correct number of times?
![Page 38: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/38.jpg)
Error Handling
![Page 39: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/39.jpg)
• Does the code check for null exceptions?
![Page 40: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/40.jpg)
• Does the code check for array out of bounds exceptions?
![Page 41: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/41.jpg)
Resource Leaks
![Page 42: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/42.jpg)
• Are all allocated memory freed?
![Page 43: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/43.jpg)
• Do all classes perform thorough cleanup on its destructor (dealloc)?
![Page 44: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/44.jpg)
• Are all notification observers, event listeners, message receivers or gesture recognizers removed when not needed?
![Page 45: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/45.jpg)
• Does the code accurately keep track of reference counting?
![Page 46: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/46.jpg)
Performance
![Page 47: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/47.jpg)
• Are you using blocking system calls when performance is involved?
![Page 48: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/48.jpg)
• Will the same data be reloaded often?
![Page 49: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/49.jpg)
• Will caching data improve performance?
![Page 50: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/50.jpg)
• Is a large number of big objects being created and destroyed in a small amount of time?
![Page 51: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/51.jpg)
• Will reusing objects improve performance?
![Page 52: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/52.jpg)
• Was this optimization really needed?
![Page 53: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/53.jpg)
Maintainability and Reusability
![Page 54: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/54.jpg)
• Is the code using magic numbers and magic strings?
![Page 55: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/55.jpg)
• Does the code comply with the DRY (Don’t Repeat Yourself) principle?
![Page 56: Code Review for iOS](https://reader034.vdocuments.site/reader034/viewer/2022051411/546fd69baf7959ae0a8b46b6/html5/thumbnails/56.jpg)
Thank you!