GETTIN META

with Ruby




by Salman Ansari

ABOUT ME



  • I am a walking ad for United Colors of Benetton
  • I did the startup thing (involver) in San Francisco
  • I moved to NYC after Oracle acquisition
  • I teach the BEWD class @ GA
  • I'm an audiophile who DJs for fun
  • I'm obsessed with Halal Cart (chicken & rice)
  • I'm not related to Aziz Ansari

AGENDA


  1. Learning to Read
  2. Under the Hood of Rails
  3. Walkthrough: Writing a DSL
  4. Review

Learning by Reading


  • Reading code effectively is a critical skill
  • Concise code is great, but we need to be able to read anything we see so we can:
    • Understand what is going on
    • Extend / refactor / rewrite code as necessary
    • Learn new syntax & techniques
  • The Rails framework is some of the best Ruby code out there
    • Reading it is a great learning tool!

UNDER THE HOOD OF RAILS


  • Let's take a deeper dive into some Rails code
  • We expect to be confused. A lot.
  • Our goal is to know enough to navigate through it
  • Then, we will follow the general example to build our own

DSL?


  • DSL: Domain Specific Language
  • Ideal way to simplify your code and enable code reuse
  • Let's build a simple DSL to help us serialize an array w/ Redis
  • The DSL's API should be the same as an array
  • It should be simple and easy to drop in (gem-worthy!)

LET'S BUILD


Time to write a DSL!

REVIEW


  • Reading code is a great way to learn
  • Ruby is dynamic & powerful; use it!
  • Remember to test :)
  • Share your code

THANKS!



Questions?



Connect:

RESOURCES

GETTIN META

By Salman Ansari

GETTIN META

This talk is about using Ruby metaprogramming to yield fun and powerful benefits. The Resources slide at the end includes some valuable links, as well as a link to the recording, which unfortunately cut out half-way through the talk. Cset la vie...

  • 2,156