Path: csiph.com!aioe.org!.POSTED.xV/6gj+grSZn0+TB/DGTcw.user.gioia.aioe.org!not-for-mail From: Graeme Geldenhuys Newsgroups: comp.lang.java.programmer Subject: Re: Interview question - better solution for MergePurgeAndReverseOrder() Date: Fri, 29 Mar 2019 16:53:10 +0000 Organization: Aioe.org NNTP Server Lines: 34 Message-ID: References: NNTP-Posting-Host: xV/6gj+grSZn0+TB/DGTcw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 Content-Language: en-GB X-Notice: Filtered by postfilter v. 0.9.2 Xref: csiph.com comp.lang.java.programmer:38828 On 29/03/2019 15:30, Stefan Ram wrote: > First observation: "And" in a method name is a indication that > the method does too many things or has no clear responsibility. > > So one should check whether it is possible to refactor, i.e., > to split the method or improve the name. I fully agree, and that is how I would implement code "in the real world". But as this was an interview technical test, I was given two classes and the second one had an empty implementation for MergePurgeAndReverseSort(). I was not allowed to change anything, other than implement the method. > Next observation: "implement it". Implement what? > Where's the specification? They should have given > you a specification of what the method is supposed > to do. May be this is what follows in the comment? > >> /* >> * [x] Merge the two arrays >> * [x] remove duplicates >> * [x] remove NULL's >> * [x] sort in reverse order >> * [x] return as an int[] array >> */ It was a while back. I can't remember if they supplied that comment, or if I did it to make sure I implemented everything that was asked. Either way, that checklist is what the method had to do in the end. Regards, Graeme