Skip to content

Instantly share code, notes, and snippets.

View zgjorge's full-sized avatar

Jorge Alfonso Zendejas Garcia zgjorge

View GitHub Profile
@zgjorge
zgjorge / clean_code.md
Created March 31, 2021 04:58 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

// Bonfire: Check for Palindromes
// Author: @zgjorge
// Challenge: http://www.freecodecamp.com/challenges/bonfire-check-for-palindromes?solution=function%20palindrome(str)%20%7B%0A%20var%20mystr%20%3D%20str.replace(%2F%5CW%7C_%2Fg%2C%20%22%22).toLowerCase()%3B%0Avar%20revstr%20%3D%20mystr.split(%22%22).reverse().join(%22%22)%3B%0Aif(mystr%20%3D%3D%3D%20revstr)%7B%0Areturn%20true%3B%7D%0Aelse%7B%0Areturn%20false%3B%7D%0A%7D%0A%0A%0A%0Apalindrome(%22eye%22)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function palindrome(str) {
var mystr = str.replace(/\W|_/g, "").toLowerCase();
var revstr = mystr.split("").reverse().join("");
if(mystr === revstr){
return true;}