Reversible routes are a mechanism for a URL dispatcher to provide a mapping from some name or handle and a set of arguments back to a URL in a way that does not expose the particular route configuration to the rest of the application. Ideally this means that any name is unique for the route configuration to allow predictable reversal.
Composable routes allow small routing configurations to be combined together to form a larger routing configuration. For instance you may combine multiple application configs into a site wide configuration. At the extreme end of this scale, as seen in Compojure for instance, middleware and route configuration are indistinguishable, and routes can be defined parametrically.
Is it possible to have a system that allows for both, or must you concede some amount of reversibility and composabiltiy in any system with both? The two areas I see as being difficult to overcome are that:
- When routes (especially parametric routes) are composed together, it becomes difficult to ensure uniqueness of naming of routes. Without uniqueness, predictability is compromised. This is especially true with parametric routes where the configuration comes from an opaque function or constructor.
- Even if you can ensure uniqueness, you can no longer trivially know what arguments need to be supplied to the reverser for a given name/handle. This in turn will cause specific details of the application's routes to be coupled to other areas (views, templates, etc) of the application.