English 中文(简体)
如何转换/翻译信息?
原标题:How to convert/translate information?

我必须“修改”代码,并附上一个相应的换算表:

| symbol | translation |  
|   1    |      3      |
|   2    |      4      |
|   3    |      6      |
|   4    |      5      |
|   5    |      2      |
|   6    |      1      |
|   7    |      1      |

My first idea was to use a Map associating each symbol to its translation and to load the table from a database or a text/xml file. Is there a better way? Doesn t have to be lightning fast, just easy to maintain and test. TIA.

最佳回答

地图是理想的,除非你在地图上填满之后可能发生变化。

换言之,如果您的协会相当静态,并且可以同意在申请变更时重新开始申请,就有一个简单的地图。

否则,你就不得不考虑某种通知机制,以便能够更新(甚至仅仅重载)地图,而不重新启用。

视具体情况而定,你可能要暴露一个简单的外部呼吁,以更新,或定期对基本文件/表格进行投票,或对其中的一些组合进行投票。

问题回答

编码 那么理想就好了。 易于维护和测试(如果你从数据库或XML中提取数据,并利用模拟数据提供不会改变的测试值,那么你就可以在单位测试中放弃数据库。

我也将采用地图方法。 我认为,这是最简单的,因此最容易维持和测试。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签