rwnobrega@lemmy.world to Python@programming.dev · 1 year agoPython interfaces: abandon ABC and switch to Protocolslevelup.gitconnected.comexternal-linkmessage-square11fedilinkarrow-up114
arrow-up114external-linkPython interfaces: abandon ABC and switch to Protocolslevelup.gitconnected.comrwnobrega@lemmy.world to Python@programming.dev · 1 year agomessage-square11fedilink
minus-squareconst void*@lemmy.worldlinkfedilinkarrow-up1·1 year agoPersonally I prefer functional architectures + callbacks (better) / closures (tolerable),they tend to scale a bit better. If a a dog needs to eat, then invoke the eat function with dog data and the dog eat function. Explicit (this data is dog so I feed it with the dog eat function) vs implicit (I have no idea, I ask my data to eat as it pleases). Explicit design tends to have fewer bugs my conjecture. Protocols are a halfway point, at least you know “hey this thing eats … uh … something.” However, if doing that, just take it all the way - systems are better explicitly linking a verb to a noun vs assuming the noun knows how to verb. It is also easier to test and debug.
Personally I prefer functional architectures + callbacks (better) / closures (tolerable),they tend to scale a bit better.
If a a dog needs to eat, then invoke the eat function with dog data and the dog eat function.
Explicit (this data is dog so I feed it with the dog eat function) vs implicit (I have no idea, I ask my data to eat as it pleases).
Explicit design tends to have fewer bugs my conjecture. Protocols are a halfway point, at least you know “hey this thing eats … uh … something.”
However, if doing that, just take it all the way - systems are better explicitly linking a verb to a noun vs assuming the noun knows how to verb.
It is also easier to test and debug.