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)

Det här avsnittet är hämtat från ett öppet RSS-flöde och publiceras inte av Podme. Det kan innehålla reklam.

Avsnitt(584)

537: Quiet Time Innovation

537: Quiet Time Innovation

Christopher and Elecia catch up on life, firmware consulting, daydreams, and projects.  Elecia thinks aloud about low-stimulation education toys. Christopher shares his experience using AI tools to bu...

29 Okt 1h 19min

536: I've Seen a Giraffe

536: I've Seen a Giraffe

David Such joins us to discuss his new book, Embedded AI: Intelligence at the Deep Edge. We explore the boundary between classical signal processing, heuristics, and edge machine learning; IMU process...

15 Okt 59min

535: The You in the Machine

535: The You in the Machine

Adam Smith from UC Santa Cruz joins us to discuss local Small Language Models (SLMs) and building open, autonomous tools. We explore his BayLeaf AI counterplatform, transagency (the "me-and-the-car" c...

1 Okt 1h 29min

534: I Think We'll Add a Head

534: I Think We'll Add a Head

Aaed Musa joins us to talk about building robot dogs, custom actuators, and his YouTube channel. He shares how he moved from 3D-printing servo robots in his parents' garage to designing capstan drives...

17 Sep 1h 13min

533: The Garage Is Open

533: The Garage Is Open

Author Susan Lammers joins the show to discuss the 40th anniversary edition of her classic book, Programmers at Work. We discuss what it was like to interview young and pioneering software developers ...

4 Sep 59min

532: It's Still Real Fire

532: It's Still Real Fire

Kevin Santo Cappuccio, founder of Architeuthis Flux, joins the show to discuss creating Jumperless, an open-source breadboard that replaces physical jumper wires with software-controlled analog crossb...

20 Aug 1h 9min

531: Sequestering the Mess

531: Sequestering the Mess

Elecia and Christopher celebrate winning the IEEE Educational Activities Board Meritorious Achievement Award in Outreach and Informal Education! A huge thank you to Mark Omo and the wonderful listener...

6 Aug 1h 7min

530: A Living Highlighter

530: A Living Highlighter

Marine biologist Dr. Steven Haddock joins the show to share the alien, glowing, and transparent wonders of the deep ocean. We discuss his beautiful new book, The Radiant Sea, and explore the complex e...

25 Juli 1h 8min

Populärt inom Vetenskap

dumma-manniskor
p3-dystopia
angestpodden
allt-du-velat-veta
rss-ronden
doden-hjarnan-kemisten
rss-ufobortom-rimligt-tvivel
rss-vetenskapsradion-2
kapitalet-en-podd-om-ekonomi
halsorevolutionen
paranormalt-med-caroline-giertz
det-morka-psyket
medicinvetarna
rss-vetenskapsradion
svd-nyhetsartiklar
sexet
bildningskomplexet
hacka-livet
rss-experimentet
ideer-som-forandrar-varlden