Strategy to keep string constants in sync between java / flex?

Say you have a web application with lots of business rules built around if-then string constant comparisons. They are used both on the client side and on the backend code, and are currently hardcoded in both places with a lot of duplication, and sometimes with errors. What is a smart way to reorganize them? Unfortunately, in most cases they must exist, since the use of polymorphism would be much more disgusting. Anything specific for flex / java? Is there an easy way to save all these constants in one place and compile it both in the client code and on the server?

Edit: I'm really looking for a way to share string constants between flex and java with checking the compile time of everything. The only idea I can think of is a code generator.

+3
source share
3 answers

Code generation is easier than you think. If you really think what you need to do, I could give an example (the Ant user task, although it can be run as a regular Java application), which you could modify for your purposes (in particular, for string constants) if Do you want to.

, -, "" ( )? , .

+1

Flex Java .properties,

key1=value 1
key2=value 2

..

, .properties ? . , svn, .properties svn: externals, flex java-.

, , /:

Java: http://www.mkyong.com/java/java-properties-file-examples/

Flex: http://vatsalad.wordpress.com/2010/03/12/how-to-use-properties-fileresourcebundle-in-flex/

+1

Keep them in a project that is distributed as a can. You can also place all utility classes there to avoid code duplication.

0
source

Source: https://habr.com/ru/post/1758795/


All Articles