Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Generic Code Review Checklist
- 1. Encapsulate conditional
- ```js
- //bad
- if (person.age > 21 && person.hasCar && person.hasHouse) {
- //marry him
- }
- //good
- function isEligibleBachelor(person) {
- return person.age > 21 && person.hasCar && person.hasHouse;
- }
- if (isEligibleBachelor(person)) {
- //marry him
- }
- ```
- 1. Avoid negative conditionals
- ```java
- //bad
- public boolean isCatNotGrumpy() {
- //...
- }
- if (!isCatNotGrumpy()) {
- //avoid the claws!
- }
- //good
- public boolean isCatGrumpy() {
- //...
- }
- if(isCatGrumpy()) {
- //avoid the claws
- }
- ```
- 1. Remove dead code
- ```js
- //bad
- // function prepareForBattle() {
- // buyArmor();
- // equipArmor();
- // sharpenWeapon();
- // makePactWithDevil();
- // }
- ```
Add Comment
Please, Sign In to add comment