When working with objects and methods in ERP, we traditionally implement them directly. In other words, we implement tight coupling. The class calls the method, and the method only accepts calls from the object. We cannot run a Codeunit with a record that it does not relate to. This ensures a contract, the table, between the class and the method, allows the compiler to check integrity and prevents the software from being wrongly used.
In C/AL Code, this would look like:
SalesPost.RUN(SalesHeader), which ensures a tight contract between the Codeunit (
SalesPost) and the table (
In OOP, we can also implement loose coupling. When this is implemented, we implement an intermediate class in between the object and the method. This allows flexibility, but it increases the risk of the wrong use of the software. At design time, the method does not know its caller, and the caller may not know the method.