273: Off the Topic of My Jammies
Embedded11 Jan 2019

273: Off the Topic of My Jammies

Chris and Elecia chat with each other about the new year. All is fine until she starts quizzing him about some language details of his new project.

Many object-oriented resources suggest using composition (has-a) over inheritance (is-a-type-of) (wiki). Where do swift extensions fit in? It seems to me (Elecia here) that extension is invisible composition that allows adding of functions.

For example, say you want a TiltSensor and you already have an ImuSensor object so you need to add a function for TiltComputation.

You could make the TiltSensor contain an ImuSensor (composition). You call the ImuSensor functions to check the readings when running TiltComputation function. You don't need to know what is in ImuSensor, only what the API is.

You could have TiltSensor be a child class of ImuSensor (inheritance) so that TiltSensor responds to all ImuSensor functions as well as its new TiltComputation function. You could use the variables in ImuSensor directly for TiltCompulation but you will need to know what is in ImuSensor for that to work.

Or, in Swift, you could have TiltSensor be an extension of ImuSensor. Except it wouldn't be called TiltSensor, it would be part of ImuSensor: any file that had access to your extensions would be able to create an ImuSensor instance and call TiltComputation as if it was part of the original ImuSensor API. The TiltComputation function would only have access to its extension's variables and ImuSensor's API. You get to add new functionality without breaking backward compatibility.

Some more resources on this topic:

Swift Programming: The Big Nerd Ranch Guide by Matthew Mathias and John Gallagher

iOS Programming: The Big Nerd Ranch Guide by Christian Keur and Aaron Hillegass

LinkedIn Learning Courses

Blender Beta with EEVEE renderer

The Clean Coder: A Code of Conduct for Professional Programmers by Robert C. Martin

Code Complete: A Practical Handbook of Software Construction by Steve McConnell

Gelly Roll Glitter Pens (by Sakura)

Google Podcast Link (or see the Subscribe page)

Avsnitt(569)

514: Just Turn Off All the Computers

514: Just Turn Off All the Computers

Philip Koopman joined us to talk about embedded systems becoming embodied and intelligent. We focus on the safety considerations of making an intelligent and embodied device.  Phil's new book is Embo...

14 Nov 20251h 10min

513: I'm Sorry You Learned Something

513: I'm Sorry You Learned Something

Jason Turner of C++ Weekly and Empty Crate spoke with us about the joy of puzzles, the changing directions of an interesting career, and the C++ programming language. I mean, of course we talked about...

30 Okt 20251h 17min

512: What if I Didn't Stop?

512: What if I Didn't Stop?

Katherine "Smalls" Connell spoke with us about making thin and flexible circuits, making stretchable electronics, and running a successful Kickstarter. Katherine's Kickstarter: Sprite Lights LED Body...

16 Okt 20251h 5min

511: Forty Trillion Divides

511: Forty Trillion Divides

Chris and Elecia talk about the show overflowing to another bit, fight over vim vs nano, consider awards, discuss writing (and self-motivation), consider linear algebra on AI cores, encourage remote d...

2 Okt 20251h 22min

510: The Secret Chip

510: The Secret Chip

Christina Cyr spoke with us about building cell phones, entrepreneurship, social purpose corporations, awards, lithium recycling, and her interesting career path. We talked about Christina's Cyrcle P...

19 Sep 20251h 4min

509: Swarmed by Engineers

509: Swarmed by Engineers

Steve Hinch wrote a book about engineering, innovation, and business. He shares decades of wisdom gleaned from his career at Hewlett-Packard and Agilent as an engineer, manager, marketing director, an...

5 Sep 20251h 13min

508: Descartes' Demon

508: Descartes' Demon

William Griffin spoke to us about hardware-in-the-loop testing, simulation, terminology, learning complex topics, and books. We don't usually expand upon the show title but Wikipedia has a rabbit hole...

21 Aug 20251h 22min

507: Turn Our Data Into Predators

507: Turn Our Data Into Predators

Chris and Elecia chat about books, courses, alternate podcasts, electronics, statistics, kidnapping Roo, and journaling failures. The Embedded Patreon book club is reading Data-Driven Science and Eng...

7 Aug 20251h 14min

Populärt inom Vetenskap

p3-dystopia
dumma-manniskor
svd-nyhetsartiklar
doden-hjarnan-kemisten
allt-du-velat-veta
rss-ufo-bortom-rimligt-tvivel-2
bildningspodden
det-morka-psyket
rss-vetenskapsradion
kapitalet-en-podd-om-ekonomi
rss-vetenskapsradion-2
sexet
rss-experimentet
medicinvetarna
paranormalt-med-caroline-giertz
har-vi-akt-till-mars-an
dumforklarat
hacka-livet
naturmorgon
halsorevolutionen