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)

Denne episoden er hentet fra en åpen RSS-feed og er ikke publisert av Podme. Den kan derfor inneholde annonser.

Episoder(576)

529: The Narwhal Looked Amazing

529: The Narwhal Looked Amazing

Chris Svec returns to the show to discuss the messy, non-linear realities of engineering management and onboarding new college graduates. We explore why companies should bother hiring fresh grads in t...

9 Jul 1h 22min

528: Goldfish Chunks

528: Goldfish Chunks

Tyler Hoffman returns to the show to discuss diagnostics and observability data in embedded systems. We catch up on his life after startup acquisition, explore the hows and whys of keeping product dat...

25 Jun 1h 10min

527: At The Jellyfish Conference

527: At The Jellyfish Conference

Chris and Elecia talk about pushing out of their comfort zone, networking advice, adding STARs and action verbs to resumes, using rust, thermo forming plastics, soldering together audio gear, and winn...

12 Jun 1h 9min

526: Take A Taste Of Engineers

526: Take A Taste Of Engineers

Dr. Victoria Serrano spoke with us about STEM outreach, fostering curiosity, and inspiring students with engineering education. Victoria is a professor at the Technological University of Panama (her ...

28 Mai 1h 1min

525: Some Sort of Metal

525: Some Sort of Metal

Dr. Tom Williams spoke with us about robots, ethics, teaching, and books. Then we talked about mines, umpires, water, and more books. Tom is the author of Degrees of Freedom: On Robotics and Social J...

14 Mai 1h 3min

524: This Isn't a Movie

524: This Isn't a Movie

Nathan Jones spoke with us about hardware security, motivation, conference talks, and writing. Nathan wrote an in-depth series of posts about the benefits of superloops vs RTOS: You Don't Need an RTOS...

16 Apr 1h 14min

523: Bad Experience With Donuts

523: Bad Experience With Donuts

Chris and Elecia chat about Leapfrog toys, things they like, large company politics, awards, and open source governance.  The Toy Story 5 Trailer with LilyPad toy which is suspiciously similar to the ...

2 Apr 1h 10min

522: The Information Is In Poop

522: The Information Is In Poop

Sonia Grego speaks with us about a topic no one likes to talk about, but could be used to monitor personal dietary health and widespread disease outbreaks. Toilets! Sonia leads Duke University's Smart...

6 Mar 54min

Populært innen Vitenskap

fastlegen
tingenes-tilstand
jss
forskningno
liberal-halvtime
sinnsyn
rekommandert
dekodet-2
abels-tarn
tomprat-med-gunnar-tjomlid
villmarksliv
hva-er-greia-med
rss-kunstig-intelligens-med-elisabeth-maren-og-morten
rss-nysgjerrige-norge
fjellsportpodden
rss-rekommandert
kvinnehelsepodden
vett-og-vitenskap-med-gaute-einevoll
katastrofe-i-hjernen
nordnorsk-historie