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

interface extends="other_interfaces"{

    any function returnAny( required numeric obj, boolean why=false )
    function sayHello()

    ILogger function logEvent( required logEvent )

    // You can implement default behavior
    function getCacheKey(){
        return "default_key";


Interfaces can extend other interfaces and classes that implement them can also implement many interfaces:

class implements="ILogger,IAdapter"{
    any function returnAny( required numeric obj, boolean why=false ){
        // implementation here.
    function sayHello(){
        return "Hola";

    ILogger function logEvent( required logEvent ){
       // log this...
       return this;

Last updated


Copyright & Register Trademark by Ortus Solutions, Corp & Ortus Software, LLC