Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ICYMI: Enums Are... by Jessie Linden

ICYMI: Enums Are... by Jessie Linden

2 facts about me: I am obsessed with enums, and I am a professional drummer and percussionist 🎵

For this talk, I'd like to marry these great loves by

1. sharing my curiosity about enums with the SwiftLeeds community
2. leveraging my musical skills as the backdrop for a sample app called PocketPerc: Beat Generator

In the app, a user would be able to toggle on any number of instrument samples to build a unique groove all their own, with samples largely recorded by me 🥁

To build up to the beat part (obviously the Grand Finale), I’d like to showcase enums in all their glory, aka possibly/hopefully using them way too much and inspiring some wild ideas about what they can do 🤗 The static data we would need is a perfect opportunity to eclipse structs and classes as the go-to data types, and instead rely heavily on enums to build views and stay categorized! To make it extra fun, I plan to limit myself as much as possible to only that data type, see what boundaries we bump up against, and discuss where and why we might want to pivot to another structure for production.

Here’s a non-exhaustive list of the power moves I’ve been exploring:

Protocol conformance CaseIterable, Equatable and Comparable conformances Associated values (with and without default values) Pattern matching Screen management Static properties Computed properties Interaction with ObservableObjects Custom raw types

Recorded at SwiftLeeds: https://www.youtube.com/watch?v=EANs31LTH6A

Avatar for James Sherlock

James Sherlock

October 10, 2023

Other Decks in Technology

Transcript

  1. John Sundell “Depending on who you ask, enums are either

    , or in Swift.” under-utilized over-used
  2. Horns Fill RepeatMode PlaybackControls Rhythm Track Mallets Latin Category SheetState

    SortStyle PlaybackState Mix SoloMode TrackControls SheetType TimeConstant ViewState SelectionState 20
  3. 0 & 1 : true & false Boolean Using Enums

    to Increase Coherence isEmpty var
  4. Streamlining Multiple States false true 0 false true ??:?? isPlaying

    currentTime disabled default false false 5:24… or whatever
  5. Streamlining Multiple States false true 0 false true ??:?? isPlaying

    currentTime disabled default false false 5:24… or whatever