Artwork

Content provided by Elecia White and Logical Elegance. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Elecia White and Logical Elegance or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.
Player FM - Podcast App
Go offline with the Player FM app!

273: Off the Topic of My Jammies

59:47
 
Share
 

Manage episode 224839705 series 1341770
Content provided by Elecia White and Logical Elegance. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Elecia White and Logical Elegance or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.

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)

  continue reading

533 episodes

Artwork

273: Off the Topic of My Jammies

Embedded

64 subscribers

published

iconShare
 
Manage episode 224839705 series 1341770
Content provided by Elecia White and Logical Elegance. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Elecia White and Logical Elegance or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.

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)

  continue reading

533 episodes

All episodes

×
 
Loading …

Welcome to Player FM!

Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.

 

Quick Reference Guide