How do you share configuration information or business rules between languages

巧了我就是萌 提交于 2019-11-28 10:11:59

Encode your data in JSON. There's a JSON library for pretty much any language you'd care to think of, or if not, it's pretty easy to code one up. If JSON is not enough, perhaps look at YAML.

XML is pretty globally used. Easy to read, easy to write, and human readable. If you're concerned about the space overhead (which you actually aren't if you want human readable) then just compress it before you send it out, XML compresses quite well.

Rafał Dowgird

See answers to this question. I think they are applicable here, especially the one with a DSL.

As much hate as they get, for sharing data validation rules, I'm going to have to say Regular Expressions.

I know, I know, everyone hates them, but they are (generally) language-agnostic.

  1. Use O/S Environment Variables (envvars) to store application configuration info (such as db passwords)

  2. Validation rules often require logic. You could write your rules in JavaScript, and then run them in the browser, server (using Nashorn), and database (PLV8 with Postgres).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!