Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Expressive objects

316 views

Published on

Techniques to make expressive toStrings on your objects

Published in: Software
  • Be the first to comment

  • Be the first to like this

Expressive objects

  1. 1. @LlewellynFalco Expressive Objects @LlewellynFalco
  2. 2. @LlewellynFalco
  3. 3. @LlewellynFalco
  4. 4. @LlewellynFalco
  5. 5. @LlewellynFalco (LEFT SHIFT) << friend std::ostream &operator<<(std::ostream &os, const YourClassName &name) { os << "a: " << name.a; return os; }
  6. 6. @LlewellynFalco XML <book id="bk101"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date> <description>An in-depth look at creating applications with XML.</description> </book>
  7. 7. @LlewellynFalco JSON { "book": { “id": "bk101", "author": "Gambardella, Matthew", "title": "XML Developer's Guide", "genre": "Computer", "price": 44.95, "publish_date": "2000-10-01", "description": "An in-depth look at creating applications with XML." } }
  8. 8. @LlewellynFalco YAML book: id: bk101 author: Gambardella, Matthew title: XML Developer's Guide genre: Computer price: '44.95' publish_date: '2000-10-01' description: An in-depth look at creating applications with XML.
  9. 9. @LlewellynFalco SIMPLE (book: id: bk101, author: Matthew Gambardella, title: XML Developer's Guide, genre: Computer, price: '44.95’, publish_date: '2000-10-01’, description: An in- depth look at creating applications with XML.)
  10. 10. @LlewellynFalco SIMPLER Book(Matthew Gambardella, XML Developer's Guide, $44.95)
  11. 11. @LlewellynFalco FORMAT (author, title, price) = (Matthew Gambardella, XML Developer's Guide, 44.95)
  12. 12. @LlewellynFalco FORMAT (author, title, price) = (Matthew Gambardella, XML Developer's Guide, 44.95) (author, title, price) = (Woody Zuill, Mob Programming, 93.22) (author, title, price) = (Diana Larsen, Agile Retrospectives, 4.99) (author, title, price) = (Kent Beck, Test Driven Development, 24.15)
  13. 13. @LlewellynFalco CSV author, title, price Matthew Gambardella, XML Developer's Guide, 44.95 Woody Zuill, Mob Programming, 93.22 Diana Larsen, Agile Retrospectives, 4.99 Kent Beck, Test Driven Development, 24.15
  14. 14. @LlewellynFalco TABBED Author | Title | price Matthew Gambardella | XML Developer's Guide | 44.95 Woody Zuill | Mob Programming | 93.22 Diana Larsen | Agile Retrospectives | 4.99 Kent Beck | Test Driven Development | 24.15
  15. 15. @LlewellynFalco GIRD .......... .SSS...... .....B.... .....B.... ...._*_... .....B....
  16. 16. @LlewellynFalco (LEFT SHIFT) << friend std::ostream &operator<<(std::ostream &os, const YourClassName &name) { os << "a: " << name.a; return os; }
  17. 17. @LlewellynFalco
  18. 18. @LlewellynFalco FORMAT (author, title, price) = (Matthew Gambardella, XML Developer's Guide, 44.95)
  19. 19. @LlewellynFalco friend std::ostream &operator<<(std::ostream &os, const Book &book) { os << "(author, title, price) = (Matthew Gambardella, XML Developer's Guide, 44.95)“; return os; }
  20. 20. @LlewellynFalco friend std::ostream &operator<<(std::ostream &os, const Book &book) { os << "(author, title, price) = (" << "Matthew Gambardella" << ", XML Developer's Guide, 44.95)“; return os; }
  21. 21. @LlewellynFalco friend std::ostream &operator<<(std::ostream &os, const Book &book) { os << "(author, title, price) = (" << "Matthew Gambardella" << ", " << "XML Developer's Guide" << ", 44.95)“; return os; }
  22. 22. @LlewellynFalco friend std::ostream &operator<<(std::ostream &os, const Book &book) { os << "(author, title, price) = (" << "Matthew Gambardella" << ", " << "XML Developer's Guide" << ", " << "44.95" << ")"; return os; }
  23. 23. @LlewellynFalco friend std::ostream &operator<<(std::ostream &os, const Book &book) { os << "(author, title, price) = (" << book.name << ", " << "XML Developer's Guide" << ", " << "44.95" << ")"; return os; }
  24. 24. @LlewellynFalco friend std::ostream &operator<<(std::ostream &os, const Book &book) { os << "(author, title, price) = (" << book.name << ", " << book.title << ", " << "44.95" << ")"; return os; }
  25. 25. @LlewellynFalco friend std::ostream &operator<<(std::ostream &os, const Book &book) { os << "(author, title, price) = (" << book.name << ", " << book.title << ", " << book.price << ")"; return os; }
  26. 26. @LlewellynFalco <type> xml </type> { “type”: “json” } type: yaml (type: simple) (simpler) (type) = (formatted) Type, Csv , Type | Tabbed | Type = other? ?
  27. 27. @LlewellynFalco RESOURCES
  28. 28. @LlewellynFalco #ApprovalTests #.Net #Java #C++ #Python #Perl #Ruby #Go #Javascript Github.com/Approvals 21 episode YouTube series
  29. 29. @LlewellynFalco #MobProgrammingGuidebook
  30. 30. @LlewellynFalco Slides at: THANK YOU (PLEASE CONNECT VIA LINKEDIN AND TWITTER) @LlewellynFalco youtube.com/isidoreus LlewellynFalco.Blogspot.com approvaltests.com

×