From: Erik V. <eri...@hc...> - 2008-11-05 20:59:24
|
Mark, I'm not sure if I understand your point. In GameManager, getInstance() is a static method, but getCurrentPhase() is not. Your shortened call wouldn't compile. Generally spoken, there might indeed be a lot of unwieldy code around. The code base has grown in ways that may have caused inconsistencies and redundant code (we have just seen an example - I'm going to fix it soon), unused or almost duplicate methods etc. When I find such a case, I often try to fix it, but not always is the solution immediately clear and other priorities may cause it being forgotten. So it goes. Over time all will be done (I hope). Erik. > -----Original Message----- > From: Mark Smith [mailto:mar...@gm...] > Sent: Wednesday 05 November 2008 01:43 > To: Development list for Rails: an 18xx game > Subject: Re: [Rails-devel] Starting on a client/server > > I would like to pose a question using your example routine in > the Tile Class: > > 325 /** > 326 * Is the tile layable now (in the current phase)? > 327 * > 328 * @return > 329 */ > 330 public boolean isLayableNow() { > 331 return > GameManager.getInstance().getCurrentPhase().isTileColourAllowe > d(colourName); > 332 } > > This calls in the Game Manager the 'getInstance ()' routine: > > 336 /** > 337 * @return instance of GameManager > 338 */ > 339 public static GameManager getInstance() { > 340 return instance; > 341 } > > What I am very puzzled by is why bother to call to get the > instance at all? > If you have the GameManager, you already have a copy of the instance. > You can reduce the original call to: > > 325 /** > 326 * Is the tile layable now (in the current phase)? > 327 * > 328 * @return > 329 */ > 330 public boolean isLayableNow() { > 331 return > GameManager.getCurrentPhase().isTileColourAllowed(colourName); > 332 } > > And even saving the a pointer to the object within the object is a > circular reference that accomplishes nothing useful that I can see. > > Maybe I am failing to realize why you bother with this > self-referencing object. > > Mark > > -------------------------------------------------------------- > ----------- > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge > Build the coolest Linux based applications with Moblin SDK & > win great prizes > Grand prize is a trip for two to an Open Source event > anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Rails-devel mailing list > Rai...@li... > https://lists.sourceforge.net/lists/listinfo/rails-devel > |