When Booleans Are Not Enough... State Machines?

  Переглядів 23,084

Next Day Video

Next Day Video

5 років тому

Harrington Joseph
www.pytexas.org/2019/talk/U2V...
Booleans are great to represent single states, but when it comes to multiple ones, they are far from ideal. This talk aims to explore cases where booleans are not the right solution, and how state machines may be a better approach when designing objects that describe multiple states and behaviors.
PyTexas2019
The PyTexas Foundation was organized as a Texas non-profit corporation in 2014 and received its 501(c)(3) recognition in early 2015. Although we cannot guarantee that your contribution to PyTexas will be tax-deductible (we aren’t tax attorneys and just don’t know), you can rest assured that any contributions to the organization will always be used to further the common goals of the Texas Python community, and never for personal benefit.
PyTexas is the annual, regional gathering for the Python community in Texas. PyTexas is organized and run by community volunteers. PyTexas, like most of the Python community, is focused on providing a diverse and enjoyable experience for everyone interested in Python. Please help us do that by following the code of conduct.
Produced by NDV: / @nextdayvideo
Python
Sat Apr 13 12:35:00 2019 at Special Event Center

КОМЕНТАРІ: 35
@madhavsingh7345
@madhavsingh7345 2 роки тому
That is very useful and exactly what I needed. A project I'm working on right now is polluted with flags, and this is going to help so much.
@EloiTeaching
@EloiTeaching 4 роки тому
Surprise of how small are the commentary count on this video. This video is amazing !
@csharp609
@csharp609 2 роки тому
The clearest explanation about the state machine, Thanks.
@spaceyfounder5040
@spaceyfounder5040 5 років тому
Freaking useful!
@derduskenga
@derduskenga 3 роки тому
Genius! Stumbled on this when I was almost giving up
@onlymecz
@onlymecz Рік тому
Exactly what I needed!! Thank you so much!
@lycantropos
@lycantropos 8 місяців тому
in the next iteration people using this pattern will understand that using separate classes to switch between states is a much better approach that can be checked by static type checkers like `mypy` in Python or a compiler in any of OO compiled languages
@lepidoptera9337
@lepidoptera9337 6 місяців тому
You must be joking... did I miss the sarcasm? Why in the world would you ever smear a state machine over several classes???? That makes it almost impossible to follow your program logic. The very beauty of a state machine with e.g. a switch statement is that it's all in one place... so you (and the people who have to maintain your legacy code!) can see immediately where things are going wrong. This also makes extending the state machine is nearly trivial. You are a good example of what's wrong with the OOP crowd.
@aleksandrkubar6255
@aleksandrkubar6255 2 роки тому
Great presentation, thanks!
@tienbui1106
@tienbui1106 3 роки тому
It's pretty helpful, thanks
@openroomxyz
@openroomxyz 2 роки тому
Love it thanks a lot!
@fringefringe7282
@fringefringe7282 2 роки тому
Marvelous.
@nikhilgoyal8340
@nikhilgoyal8340 2 роки тому
Nice explanation and use case.
@vladimirgorea8714
@vladimirgorea8714 3 роки тому
Ok, this is useful. Thanks
@madsxcva
@madsxcva 7 місяців тому
great talk
@ashwinmathews9859
@ashwinmathews9859 Рік тому
Excellent video
@eswarreddy6280
@eswarreddy6280 2 роки тому
great one
@user-uh2cr9so8l
@user-uh2cr9so8l 2 роки тому
Highlighted the use case of state machine really well, I needed that. Shame the implementation used a library though
@louaykhammar7268
@louaykhammar7268 2 роки тому
Thanks
@devtest8078
@devtest8078 2 роки тому
Excellent talk. State Machines very well explained. Well done Harrington Joseph.
@chikkai2432
@chikkai2432 Рік тому
👏
@alexanderkyei8947
@alexanderkyei8947 2 роки тому
Very great presentation👍🏿
@enzotriches7657
@enzotriches7657 3 роки тому
amazing
@geodome83
@geodome83 2 роки тому
NFA is probably the easiest way to express a state machine, but there are other kind of automata which may be used to model the state machine.
@lepidoptera9337
@lepidoptera9337 6 місяців тому
A state machine can be written easily with if-then-else or switch statements. No need to complicate things.
@brookestephen
@brookestephen Рік тому
Perhaps it's easier to make unavailable functions unavailable in the user interface, rather than generate an error when the user selects an unavailable function.
@lepidoptera9337
@lepidoptera9337 6 місяців тому
The better way is to give an explanation why the function is not available and what pre-requisites the user has to provide to make it available. Yes, there is the crowd that thinks that the user is a toddler who needs to be put into a tiny cage... that crowd tends to write highly unintuitive and frustrating software that leaves no room for growth, neither for the user nor the software designer. If you want to treat your user like an adult, tell him what the program needs to be able to do more for him. If you can't do that, then you don't understand either your user nor your own software.
@willculpepper9637
@willculpepper9637 Рік тому
1) Say what you're going to say. 2) Say it. 3) Say what you said. This is the way.
@ahmednabil5119
@ahmednabil5119 3 роки тому
But how does state machine library works? It checks the state (true or false) for every condition. He only abstract the code using an external library.
@rednafi
@rednafi 3 роки тому
Go read the source code of the pytransitions library. It's a 20 minutes talk. What do expect? I think the speaker did a fantastic job in explaining the problem and pointing the audience in the right direction.
@lapidations
@lapidations 2 роки тому
@@rednafi I agree. Even if I'm currently struggling to implement a state machine, I watched this to understand the use cases and design, not the implementation.
@yash1152
@yash1152 2 роки тому
umh, yeah, but abstraction is good. It's reusable, it's maintainable, it's flexible. it's less error prone. so, even if it's abstracted, it still fits the aim of the talk. by the way, thanks for the comment (:
@lepidoptera9337
@lepidoptera9337 6 місяців тому
@@yash1152 Abstraction for abstraction sake is a bad idea. Everybody who can touch your code understands if-then-else and switch... and almost nobody wants to read the documentation for your choice of state machine library. Moreover, you may be running into some serious performance problems with libraries that are too general for your particular use case.
@totrantien
@totrantien 2 роки тому
amazing
Building Docs like Code: Continuous Integration for Documentation
29:21
Next Day Video
Переглядів 10 тис.
Transforming Code into Beautiful, Idiomatic Python
48:51
Next Day Video
Переглядів 1 млн
MINHA IRMÃ MALVADA CONTRA O GADGET DE TREM DE DOMINÓ 😡 #ferramenta
00:40
How to get a FREE HYPERCHARGE SKIN!
02:07
Brawl Stars
Переглядів 14 млн
ИСПОЛЬЗОВАНИЕ STATE MACHINE В ПРИЛОЖЕНИЯХ
34:31
Видео с мероприятий {speach!
Переглядів 11 тис.
How to Program in Unity: State Machines Explained
18:56
iHeartGameDev
Переглядів 207 тис.
Graph databases: The best kept secret for effective AI
23:07
Web Summit
Переглядів 31 тис.
Mealy vs. Moore Machines Overview
12:26
Bruce Boatner
Переглядів 404 тис.
Introduction to finite state machines for digital logic
11:39
Steven Bell
Переглядів 7 тис.
Computers Without Memory - Computerphile
8:52
Computerphile
Переглядів 333 тис.
Programming a BETTER state machine
10:16
iHeartGameDev
Переглядів 56 тис.
Loop like a native: while, for, iterators, generators
29:15
Next Day Video
Переглядів 116 тис.
MINHA IRMÃ MALVADA CONTRA O GADGET DE TREM DE DOMINÓ 😡 #ferramenta
00:40