+ All Categories
Home > Software > Code Review

Code Review

Date post: 17-Aug-2015
Category:
Upload: tu-hoang
View: 213 times
Download: 0 times
Share this document with a friend
Popular Tags:
26
Code Review
Transcript

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

1.

Basic Concepts

Let’s start with some classic theories

Broken Window

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

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.

Even the best will make mistakes

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

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

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

““Code reviews are the single biggest

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

Our Jira process

In Progress

Code Review

Ready To Merge

Our code review steps

git code unit test

2.

Civilized Git Process

I have a separated presentation about this topic.

✘ 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.

Review the Code

InefficiencyErrors Improve-ments

4.

Unit Testing

I have a separated presentation about this topic.

What did we

discuss

today?

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.

thanks!

Any questions?

You can find me at@hoangngoctu

Credits

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


Recommended