stephen has asked for the wisdom of the Perl Monks concerning the following question:
I have a system where I have a constants class in Perl like so:
Which is fine... the constants are handy, self-documenting, and keep me from making typos. Problem: I have this Java interface class they have to stay in sync with, like so:package FooConstants; ## ISA exporter and so on... use constant TYPE_BAR => 'bar'; use constant TYPE_BAZ => 'baz'; ## etc...
I'm expecting to have to add types to these classes on a relatively frequent basis, but the two have to stay in sync or chaos will ensue. How can I keep the data for both the files in the same place, so I don't run the risk of them going out of sync? I can think of a couple of ways to do it:// Note-- Java code. Heresy! Heresy! public interface FooConstants { public static final String TYPE_BAR = "bar"; public static final String TYPE_BAZ = "baz"; //... etc... }
What's the best way to handle this? I just know there's a trap in here someplace, and I'm doing my best to avoid it. Any advice would be greatly appreciated.
stephen
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Dual constant files
by Adam (Vicar) on Mar 13, 2001 at 06:54 UTC | |
Re: Dual constant files
by Tyke (Pilgrim) on Mar 13, 2001 at 14:02 UTC | |
Re: Dual constant files
by Desdinova (Friar) on Mar 13, 2001 at 09:19 UTC |