Search code examples
c++oopheader-filesdesign-by-contract

Headers in non-C++ OOP Languages


I have been wondering for a while, why non-C++ OOP languages (not sure if there are other some that uses headers) doesn't have header files?

Well, what concerns me the most is that in C++ I can code a class header, and sends it to my mate to compile other code against it, while I am happy coding the actual implementation of the class on my own pace.

How can this be achieved in languages that doesn't have headers? Or maybe, is there something I am missing in my understanding?

How can I make a class contract with other colleagues, so that both can code in their pace? Should I just do some mock class without any implementation for methods, just with mock returns, to satisfy this need or how?


Solution

  • Header files are a legacy thing from the time compilers did not have the power necessary to compile all your source files without the hints from the developer.

    Modern languages (and in fact C++ can do so, too) use interfaces or base classes to implement design-by-contract.