Post B2xfSSj71P0PJZiCH2 by pervognsen@mastodon.social
 (DIR) More posts by pervognsen@mastodon.social
 (DIR) Post #B2xfSSj71P0PJZiCH2 by pervognsen@mastodon.social
       2026-02-03T23:54:32Z
       
       0 likes, 0 repeats
       
       Maybe I'm too harsh but this is like nails on chalkboard: https://ratatui.rs/tutorials/json-editor/app/#the-full-application-state. Since it's a beginner tutorial maybe it's driven by the (IMHO misguided) notion that beginners would be confused by using enum fields properly to make invalid states unrepresentable.
       
 (DIR) Post #B2xfSTqar4aGn4DgZc by pervognsen@mastodon.social
       2026-02-04T00:12:46Z
       
       0 likes, 0 repeats
       
       Although it's a ready-made homework exercise you can give to students telling them to refactor the example so the state machine is properly represented with no fake degrees of freedom.
       
 (DIR) Post #B2xfSV0CYprcN9isBk by wolf480pl@mstdn.io
       2026-02-04T00:49:40Z
       
       0 likes, 0 repeats
       
       @pervognsenI don't know the full context, but if enuns with fields inside haven't been introduced yet, I think it could be a good idea to first show this code, then show the problems it has, then introduce enums with fields, and show how the code can be made better.Like I think it's valuable to show the students that code doesn't have to be right the first time, but refactoring it multiple times until you're happy with it is a worthwile thing to do.
       
 (DIR) Post #B2xfVOaYrYJ5Ll6wDI by pervognsen@mastodon.social
       2026-02-04T00:50:13Z
       
       0 likes, 0 repeats
       
       @wolf480pl Right, except that never happens in this case. :)
       
 (DIR) Post #B2xfaGtosZ9ewwRa9w by wolf480pl@mstdn.io
       2026-02-04T00:51:10Z
       
       0 likes, 0 repeats
       
       @pervognsenAlthough the last part is already being taught by everything with a leaderboard, from algorithmics classes / competitive programming, to Zachtronics games.
       
 (DIR) Post #B2xfe9zqUAAmhQ7IVk by wolf480pl@mstdn.io
       2026-02-04T00:51:50Z
       
       0 likes, 0 repeats
       
       @pervognsenyeah, the last part not happening sucks.Also, they're already using Option which is an enum with a field...