Enumerating The Reasons

If you’ve ever been surprised or delighted by enum in Swift, or have ever regretted typing @property BOOL in Objective-C, then this talk is for you!

Boolean state variables are the enemy of clean code. It starts with one variable to represent if something is connected or not. But there will probably be a dozen or more methods that need to check that variable, so now your code is dependent on it. New variables will emerge – with conflicting reasons for why each one should be set to true or false. The web of state gets tangled very quickly.

Keeping code clean is just more fun with enums. Enum cases can contain associated values, so your state variables are always available in the context where they are most relevant. And because enums can have method implementations and protocol conformances in Swift, all of your state checking and branching can happen right there in the enum itself!

I want this to be a talk that everyone can learn something from – and a focused topic like enums with very useful examples is what makes that possible. You should read the Swift language chapter on enums for how they work, and come to this talk for inspiration on where and when to use them!

Location: Mt. Sopris Date: August 27, 2018 Time: 11:30 am - 12:15 pm Conrad Stoll

Privacy Preference Center


Behavior tracking, to improve the site for visitors

Google Analytics, Facebook