Talk in English - US at php[world] 2019
Track Name:
Ash Grove B
Checkout the code: https://github.com/andysnell/enums-phps-missing-data-type
View Slides: https://slides.com/andysnell/php-world-enums
Short URL: https://joind.in/talk/e65d5
(QR-Code (opens in new window))
PHP may not have a native data type for an enumerated type (“enum”), like other programming languages, but there are userland solutions we can leverage to get access to this powerful data type. We’ll see how representing things like statuses with enums provides immutability, improved readability, and type safety — preventing the kind of errors that happen with “magic strings” and class constants. In this Talk, we’ll be making our own immutable enums from scratch in order to explore the concept, but we’ll also introduce two libraries for use in your production code. We’ll also demystify the imposing-sounding “finite state machine” by using using immutable enum objects to regulate the transitions between statuses.
Comments
Comments are closed.
Speaker is really knowledgable on the subject and makes clear explanation, use cases and demonstration. Gives code sample and compare alternative. Great talk, Good job!
Clearly knowledgeable and a great resource for enums. I will definitely be considering writing my own enum or using an existing library moving forward until one is provided inherently with PHP.
Loved it. Well prepared and Andy really knew the topic!
Andy is one of my favorite presenters of the conference. Contents and flow were well thought out. I liked how he created a custom enum type, explaining possible issues and solutions at each step.