Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: How to handle same sanity checks Date: Sat, 24 Jun 2017 16:46:09 +0200 Lines: 39 Message-ID: References: <87o9tgo0a9.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 rpIMwGIkYnbo+O5Yse6vvQWnU7l7Mx4X/tDBtB/QqZ3t2huT8= Cancel-Lock: sha1:A322fO9JggdsAc47/AdliNnHLMk= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.java.programmer:36713 On 24.06.2017 12:33, Martin Gregorie wrote: > On Sat, 24 Jun 2017 12:06:28 +0200, Robert Klemme wrote: > >> Premature modularization. That makes only sense if the variability is >> needed. Since this is a private method (which should be static btw.) I >> would only do the minimum what is needed. >> > Since almost every program I write has a need for both error reporting > and diagnostic tracing *and* past experience has shown that a well > thought out diagnostic tracing scheme remains valuable when code is in > production, you won't be surprised to hear that I have similar facilities > for use in both C and Java. In the Java case its a single class capable > of direct output via the error channel but that also has the ability to > accumulate the last 'n' tracing messages in a circular buffer and to > output them if an error is being reported (I swiped this idea from a > mainframe OS, where its ability to show what happened in the last second > or two before a crash was invaluable). > > So I agree that the stand-alone method is a kludge, while at the same > time its presence does declutter the code and also serves the useful > purpose of getting rid of repetitive code. However, something like my > rather more comprehensive diagnostic and reporting facility is more > generally useful and reusable. Maybe my phrasing was ambiguous. My point is, if it is not used then that level of flexibility is superfluous, or rather hurtful. If all ranges and error messages are identical than there is no point in making them arguments to a private method which by definition cannot be reused outside the class. If, at some point, more arguments are needed, then the usual Java tools will allow to do that change fairly quickly. Your scheme is a whole different story. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/