• bleistift2 ( bleistift2@feddit.de ) 
    link
    fedilink
    English
    arrow-up
    13
    ·
    3 years 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?

    • 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 ) 
      link
      fedilink
      arrow-up
      1
      ·
      3 years 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.