Interfaces
Last updated
Last updated
Interfaces are a type of class that have a set of signatures for specific functions and it can even have some implemented functions. You can basically call an interface a signature map for the type of classes you want to create. In statically typed languages, they make a lot of sense since they can allow you to add/modify behavior of classes that the compiler can understand on how to link and compile. In a dynamic language, where functions can mutate or even be removed or injected at runtime, interfaces don't make soooo much sense. However, interfaces are a great way to provide documented signatures for developers to follow.
If you are developing frameworks, libraries or structured domain models where implementations can be done at a later point of time, or different strategies adapted; interfaces are king.
Interfaces are defined in a file template with a .bx
extension. For best practice you can start the name of the interface with a capital I,
example: IAnimal.bx, ILogger.bx, IAdapter.bx
Interfaces can extend other interfaces and classes that implement them can also implement many interfaces: