Suppose to have a library which is developed in two levels: a core, low-level one, and a high level one. My design is focused at reducing the coupling between the two.
One of the routines of the high level layer accepts an enumeration (say, FOO=0, BAR=1, BAZ=2). This enumeration is used directly by the low level routines for its final purposes.
To design this, I have three choices:
- The high level routine accepts an enumeration encapsulated to the high level module, and translates one-to-one the high level enum into the low-level enum values. Advantages: lower coupling. Disadvantages: I sort of repeat myself
- The high level routine accepts the enumeration values of the low level module, and pass it "as is". Advantages: less typing, less duplication. Disadvantages: higher coupling.
- I create an "enumeration module" which is external and both levels depend on this enumeration module. Advantages: conceptual clarity. Disadvantages: Uber catch-all module with enumerations that are not near to their code.
Do you have any experience on this case? I would go with 1, as it reduces coupling, but I would like to hear your experience as well.