Last active
August 29, 2015 13:55
-
-
Save douglas-mason/8757721 to your computer and use it in GitHub Desktop.
Readability Tip #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myCar = new Car({color: 'black', style: 'Police Car'}); | |
var theirCar = new Car({color: 'red', style: 'Sports Car'}); | |
var isRedSportsCar = theirCar.color === 'red' && theirCar.style === 'Sports Car'; | |
if(isRedSportsCar){ | |
myCar.chase(theirCar); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myCar = new Car({color: 'black', style: 'Police Car'}); | |
var theirCar = new Car({color: 'red', style: 'Sports Car'}); | |
if(theirCar.color === 'red' && theirCar.style === 'Sports Car'){ | |
myCar.chase(theirCar); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Abstracting out the conditional logic into a well named variable will greatly increase readability of your code for other programmers or your future self.