This week we’re drawing a line in the sand between objects and data structures. Who will win? Take a listen and decide for yourself!
For the full show notes visit:
tommyrush, DoNotAsk, nullthecode, El_Programmador, tommysnacks, KetillAntoníusÁgústsson, spoonraker, TheyToldMeToWriteAReview, Connor Phee
Winners of last contest – episode 49 – viney
O’Reilly discount code – 50% off print, 40% off most e-books. See the ad on this page!
Follow us on twitter, or join the mailing list!
Want a Coding Blocks sticker?
Send us a SASE – http://www.codingblocks.net/swag
Clean Code – Drawing for ep49 winner
- Hiding implementation is about abstractions
- Not just exposing internal data via getters and setters – don’t just blanket do this
- Objects hide their data behind abstractions but expose functions to operate on their data
- Data structure expose their data and have no meaningful functions
Users should manipulate the “essence” of the data, not the implimentation (for example, setting X/Y coordinates together)
What…what do you mean by “Data Structure”?
“Procedural code (code using data structures) makes it easy to add new functions without changing the existing data structures. OO code, on the other hand, makes it easy to add new classes without changing existing functions.”
A method of a class, should only call…
…methods/properties in it’s own class
…objects created in the method
…objects passed into the method via arguments
Don’t talk to strangers!
Promotes loose coupling
Code with lots of dots…
But wait…what about fluent interfaces?
Half Object / Half Data Structure
Worst of both worlds?
(aka DTO / Beans)
Clean Code http://amzn.to/2cryvJR
- Atom – Sync tree to file – CTRL+SHIFT+\
- Table Valued Parameter from C# – jbelina in slack
- OpenAI videos! https://www.youtube.com/watch?v=mGYU5t8MO7s