I JUST WANNA HAVE INTERFACES IN MY PROJECT, I GOTTA USE PYTHON SINCE I'M SCRIPTING FOR ITERM2, WHAT DO YOU MEAN I HAVE TO IMPORT THE ABILITY TO INTERFACE :kitty-cri-screm:

  • WhyEssEff [she/her]
    hexagon
    ·
    edit-2
    2 years ago

    it's an abstract class without any defined functionality, which allows for use of implementation of multiple on a single class. Basically, what it's saying is 'hey, everything that uses me has to use these functions taking in these inputs, but each of them might do something different with the input, but you can still mass invoke that named function if you need, say, something to loop over everything relevant that implements me and do something with something. I'm also a way of self-documenting responsibility cleanly at the top of a class, because I'm a contract that is designed to simply yell at you if you don't implement your declarations"

    lets say you have a button. if you are in front of alice, pressing this button does x. if you are in front of bob, pressing the button does y. If alice and bob both implement the IButtonPressObserver interface with the declared abstract method OnPress(), you can write one function that takes in an IButtonPressObserver in front of you and tells it to run their respective OnPress method instead of one function that takes in alice and one function that takes in bob