Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



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...


That's another good way to do it for sure, and IMO badly underused within the Python ecosystem specifically.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: