Path: csiph.com!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: BGB Newsgroups: comp.lang.java.programmer Subject: Re: multi-line Strings Date: Tue, 11 Dec 2012 19:41:48 -0600 Organization: albasani.net Lines: 35 Message-ID: References: <7f36342c-2331-4484-874b-4a0f8953f160@googlegroups.com> <1pvw1ur9xgeke$.wdqso0m84fyy$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net w5tB4iyiAGT7nn5suALe4Y80biWNG8zT6SsxVS/ewB95u5dH5ln2OtK2P7A0hUASGYYbvSWg4NDaNXSvh96CeQ== NNTP-Posting-Date: Wed, 12 Dec 2012 01:44:49 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="oSeZxmtfTe84A5PMStyChBPK6Z64sZhB6XTBf6O1YZ6n13xwKXEGX2L8G8kSgFGAVZ/Sb6kopEmyxb7RcqutcHowRgw0BZNLuzpCfHyryNx6Wz5V2PHXGJVpWNKBROhw"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 In-Reply-To: <1pvw1ur9xgeke$.wdqso0m84fyy$.dlg@40tude.net> Cancel-Lock: sha1:AhNbhgfR3VBmRoShG27pix7VSAE= Xref: csiph.com comp.lang.java.programmer:20266 On 12/11/2012 5:31 PM, Peter Duniho wrote: > On Tue, 11 Dec 2012 17:07:05 -0600, BGB wrote: > >> [...] >> but, yeah, banning string literals would be stupid... > > That said, I think there's a good argument for insisting that most if not > all string literals be declared as constants (e.g. final fields in the > class or a separate static class), rather than being found inline with the > code. > > You don't get out of having string literals, but at least they are in a > centralized place or places, and when the same value is required in > multiple places, changes to the value or refactorings of the code are > simplified in this way. > yep, this makes sense... it is along similar lines though to the avoidance of "magic values" being declared inline in code. sometimes, a value makes more sense as a constant variable, and people will declare it as such. other times, it does not, and will typically be left inline. IMO, all this isn't really an area tools should get involved with enforcing though, since tools can't really know whether or not something "makes sense", they will just uniformly enforce various rules whether or not they make sense in a given situation. sort of like life in general I guess...