Code Review PHP Code Review Exa India Pvt. Ltd.
Code Review 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.
OTS ● Over the shoulder ● Suitable for small teams ● explain line by line code to reviewer
Tool-Assisted Review ● ● ● ●
PHPMD http://exawiki/index.php?title=PHPMD refactoring the code checklists
Pair Programming ● Dynamic type of code review ● One developer codes and other follows his progress by sitting beside him ● Pair Programming - Hotseat for two developers ● Effective in avoiding bugs, but costs twice the man power. ● Only suitable to certain type of team and people.
Best Practices for Code Review ● Know your common mistakes and actively fight them ○ Note slip-ups, Commenting, Filtering etc.. ○ Know that the code is going to be reviewed ○ Get the ego effect to drive you to improve your code before others even have a change to take a look at it.
OR
Best Practices for Code Review Peer code review means being reviewed by someone of equal or greater skill
Best Practices for Code Review ● Less Code with clear milestones means better reviews ○ Milestones should be small and should happen often. ○ OOP makes is doable and is very important ○ Keep it max to 800-900 lines of code at a time (including comments) for efficient reviews ○ Keep the code short, concise and independent. ○ Do the review as soon as possible after finishing while the ideas are still fresh in your mind. ○ Time is expensive, don't take too much of it either to review (set time aside for reviews as you will require to factor it in for delivery of module).
Best Practices for Code Review ● Collect Metrics ○ Number and Types of bugs and slip-ups, against number of lines of code and units of time. ○ Aggregate this data across developers and easily find out who needs the most help ○ Who breaches the most standards ○ Quantify the usefulness of code review and aim to have everyone in the team become actively intrigued by it.
Best Practices for Code Review ● Be mindful of the social aspect - finding bugs is good, not bad! ○ Imperative to remember that finding bugs is good and not bad. ○ Have people adapt to code review ○ Focus on future ○ Focus on what instead of who ○ Make it informal ○ Not a rule enforced by the company but as an improvement to their everyday workflow ○ Use tools in OTS as well
PHPMD - Sample
PHPMD - Sample xampp\htdocs\easf\application\controllers\examples.php
Questions if any? Thank You!