- cross-posted to:
- windows_dev@programming.dev
- bleistift2 ( @bleistift2@feddit.de ) English13•4 months ago
I am a sky-high developer and know little of such low-level APIs. Please humor my ignorance: Isn’t it bad practice to write a god-method that sometimes uses these parameters, sometimes others? Isn’t this better refactored into multiple dedicated functions?
- aberrate_junior_beatnik ( @aberrate_junior_beatnik@midwest.social ) English3•4 months ago
Obviously taken to an extreme it’s bad, but I think it’s fine to have a function that can do one thing two or more different ways and ignore a certain parameter if one of the ways doesn’t need it. I’ve done some programming against the Win32 API and this is what jumped to mind for me, and I think it’s the typical case here. If I were designing from scratch I might split it into n functions that do it one way, but it’s such a small difference I wouldn’t fret over it. And of course making a change to the Windows API is an undertaking, probably not worth it in most cases.
- sim642 ( @sim642@lemm.ee ) 1•4 months ago
Yes, but with things like syscalls it’s easier to do this than require every high-level thing building on the syscall to be modified and recompiled. Very few people need to use such low-level APIs.
- eveninghere ( @eveninghere@beehaw.org ) 1•4 months ago
int dummy = 123; foobar(dummy);