Top Banner
Code Review
26
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Code Review

Code Review

Page 2: Code Review

hello!

I am Hoang Ngoc TuI am here to present how my team is doing code review.

You can find me at @hoangngoctu

Page 3: Code Review

1.

Basic Concepts

Let’s start with some classic theories

Page 4: Code Review

Broken Window

A criminological theory that a small damage will lead to a system corruption.

Page 5: Code Review

Technical Debt

We will spend a big extra effort eventually for a small shortcut now. Every minute spent on not-quite-right

code counts as interest on that debt.

Page 6: Code Review

Even the best will make mistakes

Most of the effort we spend on code, we spend fixing it.

Page 7: Code Review

““Code chạy được chưa chắc được chạy.”

- Nguyễn Thế Điền (A developer in my team)

Page 8: Code Review

““Code reviews are the single biggest

thing you can do to improve your code.”- Jeff Atwood, codinghorror.com

Page 9: Code Review

Our Jira process

In Progress

Code Review

Ready To Merge

Page 10: Code Review

Our code review steps

git code unit test

Page 11: Code Review

2.

Civilized Git Process

I have a separated presentation about this topic.

Page 12: Code Review

✘ Follow the civilized git branching model✘ Commit often, Perfect later - your branch must be “perfect” to be

reviewed:○ reset, re-committed with proper meaningful commits○ start from the correct base

✘ Prefix your commit messages with your JIRA ticket

Civilized Git Process

Page 13: Code Review

3.

Review the Code

If the programmers like each other, they play a game called “pair programming”. And if not, then the game is called “code review”.

.. er .. hmm .. okay .. I don’t like you ^_^

Page 14: Code Review
Page 15: Code Review

Coding Standards

For most Magento projects✘ Zend Coding Standard✘ ECG Codesniffer Coding Standard

For general PHP projects✘ Framework-specific standard✘ PSR-1✘ PSR-2

Page 16: Code Review

ECG Codesniffer Coding Standard

It is created by Magento Expert Consulting Group.Automatically check some common Magento and PHP coding issues, like:✘ raw SQL queries✘ SQL queries inside a loop✘ direct instantiation of Mage and Enterprise classes✘ unnecessary collection loading✘ excessive code complexity✘ use of dangerous functions✘ use of PHP superglobals✘ and many others.

Page 17: Code Review

Basic Principles

✘ MVC - yes, put your code to the correct place

✘ DRY - Don’t Repeat Yourself

✘ SRP - Single Responsibility Principle

✘ KISS - Keep It Simple, Stupid!

Page 18: Code Review

Coding Common Senses

✘ https://magentotherightway.com/

✘ http://www.phptherightway.com/

✘ http://jstherightway.org/

Page 19: Code Review

Code Readability is King!

A program that runs perfectly but is unchangeable because it has low readability is significantly less valuable than a clean and clear program

with some minor bugs that can easily be found and fixed.

Page 20: Code Review

Review the Code

InefficiencyErrors Improve-ments

Page 21: Code Review

4.

Unit Testing

I have a separated presentation about this topic.

Page 22: Code Review

What did we

discuss

today?

Page 23: Code Review

Let’s review some concepts

Broken Window Theory

Technical Debt Concept

git -> code -> unit test

Coding Standards

PHP_Codesniffer with ECGDRY

SRP

KISS

Commit often, Perfect later, but before Review

Readability is King

Page 24: Code Review

When will those concepts be obsolete?

When the application become an AI. It can analyze new business requirement and write new code for itself to self-improve.

Probably it will happen in next 20 years.

Page 25: Code Review

thanks!

Any questions?

You can find me at@hoangngoctu

Page 26: Code Review

Credits

Special thanks to all the people who made and released these awesome resources for free:✘ Presentation template by SlidesCarnival✘ Photographs by WallHaven