Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Parallelism and Symmetry

Alex Tercete
November 02, 2018

Parallelism and Symmetry

Like in writing, parallelism and symmetry can make your coding effective, classy, and certain to impress anyone who reads it.

Alex Tercete

November 02, 2018
Tweet

More Decks by Alex Tercete

Other Decks in Programming

Transcript

  1. Olympic athletes usually like practicing, competing, and to eat ice

    cream sandwiches. DON'T Alice Underwood @ Grammarly <https://www.grammarly.com/blog/parallelism/>
  2. Olympic athletes usually like practicing, competing, and eating ice cream

    sandwiches. or Olympic athletes usually like to practice, compete, and eat ice cream sandwiches. DO Alice Underwood @ Grammarly <https://www.grammarly.com/blog/parallelism/>
  3. For dinner we like lamb chops and to fry brussel

    sprouts. DON'T Alice Underwood @ Grammarly <https://www.grammarly.com/blog/parallelism/>
  4. For dinner we like lamb chops and brussel sprouts. or

    For dinner we like to grill lamb chops and fry brussel sprouts. DO Alice Underwood @ Grammarly <https://www.grammarly.com/blog/parallelism/>
  5. Public transit such as buses or a train can help

    reduce air pollution. DON'T Alice Underwood @ Grammarly <https://www.grammarly.com/blog/parallelism/>
  6. Public transit such as buses or trains can help reduce

    air pollution. DO Alice Underwood @ Grammarly <https://www.grammarly.com/blog/parallelism/>
  7. DON'T function getThings(): Thing[] { const things = getFirstHalfOfThings(); const

    secondHalfOfThings = getSecondHalfOfThings(); things.push(...secondHalfOfThings); return things; }
  8. DON'T function getThings(): Thing[] { const things = getFirstHalfOfThings(); const

    secondHalfOfThings = getSecondHalfOfThings(); return things.concat(secondHalfOfThings); }
  9. DO function getThings(): Thing[] { const things: Thing[] = [];

    things.push(...getFirstHalfOfThings()); things.push(...getSecondHalfOfThings()); return things; }
  10. DO function getThings(): Thing[] { const firstHalf = getFirstHalfOfThings(); const

    secondHalf = getSecondHalfOfThings(); return firstHalf.concat(secondHalf); }
  11. DO function getThings(): Thing[] { const firstHalf = getFirstHalfOfThings(); const

    secondHalf = getSecondHalfOfThings(); return [...firstHalf, ...secondHalf]; }
  12. DON'T export default const thing = createThing(); // Doesn't compile

    export const thingWithSomething = createThingWithSomething();