creating module ids

Mark Reinhold mr at sun.com
Tue Nov 10 11:02:16 PST 2009


> Date: Tue, 10 Nov 2009 10:46:20 -0800
> From: jonathan.gibbons at sun.com

> Is there any reason not to make the constructors accessible --
> e.g. ModuleId(String name, Version version) ?
> Having to go through parse methods all the time to create objects is, well,
> tedious.

Versions are module-system-specific, so you have to consult a
ModuleSystem object to parse a version anyway.  Given that,

    ModuleSystem.base().parseModuleId(n, v)

seems to me to be less tedious than

    new ModuleId(name, ModuleSystem.base().parseVersion(v))

(or s/ModuleSystem.base()/JigsawModuleSystem.instance()/ if
you like).

> Date: Tue, 10 Nov 2009 10:55:33 -0800
> From: jonathan.gibbons at sun.com

> Brian Pontarelli wrote:
>> Constructors bad. Factories better.
> 
> Factories ok; parsing from strings every time: bad.

Ah, I didn't realize that was your use case -- you already
have a Version object.  So how about

    ModuleId.create(String name, Version version) ?

- Mark



More information about the jigsaw-dev mailing list