hello!
I am Hoang Ngoc TuI am here to present how my team is doing code review.
You can find me at @hoangngoctu
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.
““Code reviews are the single biggest
thing you can do to improve your code.”- Jeff Atwood, codinghorror.com
✘ 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
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 ^_^
Coding Standards
For most Magento projects✘ Zend Coding Standard✘ ECG Codesniffer Coding Standard
For general PHP projects✘ Framework-specific standard✘ PSR-1✘ PSR-2
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.
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!
Coding Common Senses
✘ https://magentotherightway.com/
✘ http://www.phptherightway.com/
✘ http://jstherightway.org/
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.
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
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.
Credits
Special thanks to all the people who made and released these awesome resources for free:✘ Presentation template by SlidesCarnival✘ Photographs by WallHaven