The Julia programming language has been evolving in many complex scientific fields. The rising adhesion of the language is a great opportunity to make Julia production-suitable. As an additional endeavor, I present a Design By Contract interface built entirely in Julia using its many features for Metaprogramming. My work takes the praised method of defining contracts to enforce interfacing between methods from Eiffel and hopes to extend it to different structures available in Julia.
Design By Contract is a method recommended in several Software Engineering best practices books such as the "Pragmatic Programmer" and "Clean Code". Design By Contract uses the paradigm of failing as fast and as often as possible to make sure we can detect the majority of bugs and unexpected behavior inside our code. This is done by ensuring the program in development will maintain state by executing a given set of assertions in every function, loop, or even data type, i.e. by making sure some conditions will always be true. Different from Unit Testing, Design by Contract will run all these assertions in runtime, reaching edge cases that are only found when using the program daily. It also makes the code cleaner and more literate by expressing the bounds of every structure, helping out when reading and unit testing it. Our implementation can disable the assertions for a more efficient runtime in production. Our Julian implementation of DBC uses macros and multiple dispatch, enabling for cohesive software development and review.