Implementing TypeState Pattern in Pythonby@0xc0ff3370c0d3
910 reads
910 reads

Implementing TypeState Pattern in Python

by 10mMay 4th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

TypeState pattern is a generic pattern that could be used in multiple languages. I encountered this pattern first while developing software using Rust in Python. The basic idea behind TypeState Pattern is to encode the state information inside types. The connection can exist in two states: the connection to remote end has not been established, and the connection between remote and remote ends has been established. The following shows an approach to implement a similar logic without using the pattern, by maintaining the state info inside an attribute.

Company Mentioned

Mention Thumbnail

Coin Mentioned

Mention Thumbnail
featured image - Implementing TypeState Pattern in Python
undefined HackerNoon profile picture

@0xc0ff3370c0d3

Share Your Thoughts

About Author

undefined HackerNoon profile picture
@0xc0ff3370c0d3

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
L O A D I N G
. . . comments & more!