Another rule of modular programming is to reduce the number of relationships between functions. This is referred to as function coupling. Functions that have few, or no, relationships between them are loosely coupled. Loosely coupled functions provide simple, visible interfaces to the function. This makes the functions easier to use and modify. For example, the Cicode function TimeCurrent() is a loosely coupled function. To use this function, a user need only call its name, and the function will return with the desired result. The user does not need to be aware of any relationships because there are no parameters passed to the function, and it does not read from, or write to, any global data. There is very little likelihood of error with this function; it only returns a time/date variable and does not support error codes. In the unlikely event that the function did not return the time/date variable, it would be through no error of the calling function because it has no relationship to it.
Functions that have many relationships between them are tightly coupled. For example, a user written function like AddCustomerRecord(hDatabase, sFirstName, sSurname, sAddress, sAge, sPhone) has a higher level of coupling than the function TimeCurrent(). Tightly coupled functions are inflexible in their use, less robust, and harder to maintain. The AddCustomerRecord() function is less robust because it could experience an error of its own accord, or if the function calling it passes bad data to it. Tightly coupled functions are harder to maintain because modifying a function with many relationships in it may result in modifications to other functions to accept the data.
The different types of function relationships are listed below: