News for hackers. Stuff that matters.
Re:Push ifs up and fors down by tetha on Thursday November 16, 2023 @11:36AM (#38291692)
Something I've seen a few times in Go and java: Make login() a constructor for the AppClient, or declare what's essentially a factory called "AppClientConfig" with a login() function to create the AppClient.

I've only recently started to think about using factories like that, so I'm very sure there are patterns of dynamic state I wouldn't have a recipe for, but it's a prety appealing idea to me.

Re:Push ifs up and fors down by nerdponx on Thursday November 16, 2023 @01:24PM (#38293365)
That's another good way to do it for sure, and IMO badly underused within the Python ecosystem specifically.
Re:Push ifs up and fors down by paholg on Friday November 17, 2023 @06:00AM (#38301894)
That's called RAII, and I'm a big fan (not of the name, though. It's a terrible name).

https://en.m.wikipedia.org/wiki/Resource_acquisition_is_init...