Options for defining interface mapping code in the 21st century
Currently working on re-writing sev开发者_C百科eral interfaces and looking at what options there are for defining the mapping between the systems. We need to do things like filtering out records, remap 1 into 2 etc - but the core of it seems to be assigning to the new format from the old format and looking for a nice clear/easy to maintain way to do this.
Probably written in Java - but may try and throw in some JRuby if that makes the mappings cleaner...
Options that come to mind are:
- In code, lots of if/else and assignments
- Via generic system, store the mapping somewhere (eg DB) for the easy-ish items and then just process that in the interface
I am preferring 1. at the moment - with an array/map of the simple assignments so that code is fairly succinct. And at least things will be opaque as the mapping is in the code. Its anticipated that the interface will not change much over time...
As I write this, I am thinking I am making a mountain out of a mole hill... but since I have gone this far - what do you think?
What would you do/have you done for things like this?
Thanks in advance, Chris.
Swinging back towards option 2 now - storing the simple mappings in a config file/db (perhaps in a DSL format) for ease of access if a change is needed in future.
精彩评论