From: Erik V. <eri...@hc...> - 2008-12-07 23:22:37
|
Hi Jean, The point is, that several class names are configurable. For instance, the default operating round class is OperatingRound, but several games use more specialized subclasses, with names like OperatingRound_18xx. Examples are 18AL and 18EU; see the <OperatingRound> tags in the Games.xml files of these games. These classes (and most other Round subclasses) are dynamically instantiated in method createRound() of class GameManager, by calling the newInstance() method of a Class object for the particular class to be created. The newInstance() method requires a parameterless constructor, like OperatingRound(). So we can only use such constructors; constructors that take parameters are useless for these classes. (I think there are ways to create newInstance methods that take parameters as well, but I didn't find it worth while to sort out how to jump through those hoops, as we already had a simple solution). Parameterless constructors can obviously only initialize fixed/default values, nothing that is variable (except through calling class methods, but we want to get away from class methods). That means that all further initialization must be done by calling a non-constructor method; in this case setGameManager(). I hope this helps. Erik. _____ From: Jean Michalski (Europe) [mailto:Jea...@eu...] Sent: Sunday 07 December 2008 09:46 To: Development list for Rails: an 18xx game Subject: Re: [Rails-devel] Another Bug I have found, and worked out a fix for Hi Mark, Erik, everyone, Just a small note to say I have followed the discussion, and without any pretention to say I understand the gritty details, Erik says that the classes in question are being instantiated "dynamically", e.g. in a way such that constructors would be inappropriate. So he says he would be happier to leave the empty constructors and use the setGameManager() or any other configuration method. Erik, would you be so kind as pointing out very pragmatically to one specific such case? I think it might enlighten at least myself on the way the architecture has been thought out and built. This would have all of us looking into the same direction (or question the direction, but this would certainly not come from me). Thank you, Jean (John in French) Michalski _____ From: Mark Smith [mailto:mar...@gm...] Sent: 05 December 2008 23:43 To: Development list for Rails: an 18xx game Subject: Re: [Rails-devel] Another Bug I have found, and worked out a fix for OK, if you feel that parametrized constructors is a step backwards, I will comply with your request. I don't agree, but I won't argue about it any more. Mark |