Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: Where to put the return Date: Mon, 21 Aug 2017 22:29:51 +0200 Lines: 32 Message-ID: References: <87zib6zeup.fsf@munus.decebal.nl> <87y3qlnyvj.fsf@munus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net H01nMtL1vsbIYdQB0EBcDQP2PHkbMx1f7FVTz6E3rk0skA2qw= Cancel-Lock: sha1:6P6AuEV9dp0UjEUZGa9KxdtCzIY= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.java.programmer:37331 On 19.08.2017 18:20, lewbloch@gmail.com wrote: > Constants make sense even if used only once. Seeing the constants at > the top of the class definition gives one a quick view of the > functionality below, I am not sure whether a bunch of String constants containing SQL statements really conveys the "functionality below". > and provides an easily-located maintenance point > if one decides later to change the constant value. That is correct in the general case. However, we are talking about SQL statements which have close ties to the method that uses it (the method needs to extract the correct columns into matching Java types etc.) so it is likely that the SQL and the method implementation need to be changed in lock step. I think maintenance in this case is simpler if the SQL lives inside the method. > I'm highly opposed to defining constants outside the class with which > they're semantically associated. +1 (Just in case it has not been clear: I am not advocating moving these constants out of the class that uses them but inside methods - at least for the cases where there is just one using method.) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/