Interface-based design to prevent undefined behaviour