From: brett l. <wak...@gm...> - 2006-07-11 20:08:17
|
I've noticed that we've got a ton of constants that are duplicated across our source tree. Does anyone object to me creating a single Constants class-file that holds all of these items and relocating all of our constants into this central file? ---Brett. |
From: John A. T. <ja...@ja...> - 2006-07-11 20:12:55
|
brett lentz wrote: >I've noticed that we've got a ton of constants that are duplicated >across our source tree. > >Does anyone object to me creating a single Constants class-file that >holds all of these items and relocating all of our constants into this >central file? > > It would seem better to have them related to how they are used, rather than just grouping them because they are constants. For example, a constant describing the type of a junction on a tile has no business being lumped together with a constant definition of the number of pixels offset for some graphic object. This will add unnecesary coupling between classes. If the values are really duplicated, then a better solution would be to remove the duplication and use one canonical source. -- John A. Tamplin ja...@ja... 770/436-5387 HOME 4116 Manson Ave Smyrna, GA 30082-3723 |
From: brett l. <wak...@gm...> - 2006-07-11 20:19:31
|
On 7/11/06, John A. Tamplin <ja...@ja...> wrote: > brett lentz wrote: > > >I've noticed that we've got a ton of constants that are duplicated > >across our source tree. > > > >Does anyone object to me creating a single Constants class-file that > >holds all of these items and relocating all of our constants into this > >central file? > > > > > It would seem better to have them related to how they are used, rather > than just grouping them because they are constants. For example, a > constant describing the type of a junction on a tile has no business > being lumped together with a constant definition of the number of pixels > offset for some graphic object. > > This will add unnecesary coupling between classes. > > If the values are really duplicated, then a better solution would be to > remove the duplication and use one canonical source. > Of course. I was more meaning things like the many static strings that we use on buttons and labels (e.g. "ok" and "done") or static numbers like SQRT3 that are duplicated across the GUI files, etc. All of the more specific variables, I'm not interested in touching. ;-) ---Brett. |
From: Erik V. <eri...@hc...> - 2006-07-11 20:24:41
|
> I've noticed that we've got a ton of constants that are duplicated > across our source tree. > > Does anyone object to me creating a single Constants class-file that > holds all of these items and relocating all of our constants into this > central file? I presume you are only talking about public constants. Protected and private ones have only local significance and should stay where these are anyway. Displayed texts should not be constants but be made localisable by defining these in LocalisedText.properties, and retrieved via Game.getText(). For the rest I concur with John: it is generally better to keep constants related to classes where they logically belong to. Perhaps the keys of the localisable texts are an exception, I can imagine putting all these in one class LocalText or such (this is also the kind of constant that will suffer most from duplication). Game.getText() could then be moved to that class. Erik. |
From: brett l. <wak...@gm...> - 2006-07-11 20:30:02
|
On 7/11/06, Erik Vos <eri...@hc...> wrote: > > I've noticed that we've got a ton of constants that are duplicated > > across our source tree. > > > > Does anyone object to me creating a single Constants class-file that > > holds all of these items and relocating all of our constants into this > > central file? > > I presume you are only talking about public constants. > Protected and private ones have only local significance > and should stay where these are anyway. > Correct. > Displayed texts should not be constants but be made localisable > by defining these in LocalisedText.properties, and retrieved via > Game.getText(). > > For the rest I concur with John: it is generally better > to keep constants related to classes where they logically > belong to. > > Perhaps the keys of the localisable texts are an exception, > I can imagine putting all these in one class LocalText or such > (this is also the kind of constant that will suffer most from duplication). > Game.getText() could then be moved to that class. > Yeah, this was more along the lines I was thinking. I'll focus just on the localisable texts for now. ---Brett. |
From: John A. T. <ja...@ja...> - 2006-07-11 20:27:24
|
brett lentz wrote: >Of course. I was more meaning things like the many static strings >that we use on buttons and labels (e.g. "ok" and "done") or static >numbers like SQRT3 that are duplicated across the GUI files, etc. > > Speaking of strings, what is the plan for localization? I have always used GNU gettext myself, but I am not sure how that works with the Java approach (even though I see there is a port of gettext to Java). If we aren't using something like that, then perhaps isolating all the UI strings into a single class would make it easier to localize, perhaps even using ClassLoader to load the appropriate one from a preference setting. It's too bad Sun didn't include java.lang.Math.SQRT3 etc, and that you can't easily add constant definitions to a class. -- John A. Tamplin ja...@ja... 770/436-5387 HOME 4116 Manson Ave Smyrna, GA 30082-3723 |
From: brett l. <wak...@gm...> - 2006-07-11 20:46:47
|
On 7/11/06, John A. Tamplin <ja...@ja...> wrote: > brett lentz wrote: > > >Of course. I was more meaning things like the many static strings > >that we use on buttons and labels (e.g. "ok" and "done") or static > >numbers like SQRT3 that are duplicated across the GUI files, etc. > > > > > Speaking of strings, what is the plan for localization? I have always > used GNU gettext myself, but I am not sure how that works with the Java > approach (even though I see there is a port of gettext to Java). > > If we aren't using something like that, then perhaps isolating all the > UI strings into a single class would make it easier to localize, perhaps > even using ClassLoader to load the appropriate one from a preference > setting. > > It's too bad Sun didn't include java.lang.Math.SQRT3 etc, and that you > can't easily add constant definitions to a class. > Java has it's own localisation methods and classes under java.util.Locale and java.util.ResourceBundle. The current plan for localization in Rails is fairly loose. Erik has started a basic amount of using the Locale class and LocalisedText.properties. I was thinking that I might at least round up all the strings and make them available for translating. ---Brett. |
From: Erik V. <eri...@hc...> - 2006-07-11 20:54:20
|
> Java has it's own localisation methods and classes under > java.util.Locale and java.util.ResourceBundle. > > The current plan for localization in Rails is fairly loose. Erik has > started a basic amount of using the Locale class and > LocalisedText.properties. Localisation is (or should be) already handled in Game.getText(). Currently there is only a default (English) text file, but IIRC adding French texts in a file LocalisedText_fr.properties should handle that language (after calling Game.setLocale("fr")). Erik. |
From: brett l. <wak...@gm...> - 2006-07-11 20:58:45
|
On 7/11/06, Erik Vos <eri...@hc...> wrote: > > Java has it's own localisation methods and classes under > > java.util.Locale and java.util.ResourceBundle. > > > > The current plan for localization in Rails is fairly loose. Erik has > > started a basic amount of using the Locale class and > > LocalisedText.properties. > > Localisation is (or should be) already handled in Game.getText(). > Currently there is only a default (English) text file, > but IIRC adding French texts in a file LocalisedText_fr.properties > should handle that language (after calling Game.setLocale("fr")). > We should make this a configurable option on startup. We should also look at saving a file of "default" settings so that when the user sets a preference, we save it and re-use it the next time we start up. ---Brett. |
From: Erik V. <eri...@hc...> - 2006-07-11 21:25:47
|
> > Localisation is (or should be) already handled in Game.getText(). > > Currently there is only a default (English) text file, > > but IIRC adding French texts in a file LocalisedText_fr.properties > > should handle that language (after calling Game.setLocale("fr")). > > > > We should make this a configurable option on startup. We should also > look at saving a file of "default" settings so that when the user sets > a preference, we save it and re-use it the next time we start up. Yes, and yes. Erik. |
From: brett l. <wak...@gm...> - 2006-07-11 21:30:35
|
On 7/11/06, Erik Vos <eri...@hc...> wrote: > > > Localisation is (or should be) already handled in Game.getText(). > > > Currently there is only a default (English) text file, > > > but IIRC adding French texts in a file LocalisedText_fr.properties > > > should handle that language (after calling Game.setLocale("fr")). > > > > > > > We should make this a configurable option on startup. We should also > > look at saving a file of "default" settings so that when the user sets > > a preference, we save it and re-use it the next time we start up. > > Yes, and yes. > Ok... let's address this after we handle Undo/Redo and Load/Save of games. I'll stick it in the feature request tracker. Later today, I should have most of the strings pulled out into LocalisedText.properties. ---Brett. |