Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: Type of a generic class? Date: Thu, 02 Aug 2012 20:08:29 -0700 Organization: A noiseless patient Spider Lines: 51 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 3 Aug 2012 03:08:32 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="61282af8d6595e8d991edb5ac03d6e00"; logging-data="23541"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zF03FYdF6rgZhrx5jfgLOHlXKNvVGfZM=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 In-Reply-To: Cancel-Lock: sha1:VEm/z/XyCu7Hq/DtVG9vKBaRYMw= Xref: csiph.com comp.lang.java.programmer:17023 On 8/2/2012 4:27 PM, Donkey Hottie wrote: > It is indeed kind of spooky and strange idea, after all what is so wrong > about simple > > String value = SystemProperties.getString("ParamName") ; > > It is OK, but I'm kind of toying with idea of strong typing of System > Parameters: A Date can not be stored as Long or Double etc.. To do something like this, I'd arrange some implementation for the parameter: class Parameter { public void processParam( String param ) { double d = Double.parse( param ); // or whatever... ... } } And then use a Map as Lew suggests or some other method of binding the Parameter class to the string "ParamName". (You could, for example use Class.forName(): Parameter proc = Class.forName( "my.project.parameter."+"ParamName").newInstance(); or you could use annotations: @Parameter("ParamName") class Parameter {... or any other crazy thing you like. It would probably be better than what you have now.) > The back end of the system parameters is simply > > CREATE TABLE SystemParameters > ( > name varchar(64) not null primary_key, > value varchar(512) > ) ; I've written this table definition. In fact it was 23 odd years ago, as in intern while still in college. I don't know if it's good or bad practice, but it seems a common idea.