Return-Path: X-Original-To: apmail-ignite-dev-archive@minotaur.apache.org Delivered-To: apmail-ignite-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2189318451 for ; Fri, 23 Oct 2015 20:22:10 +0000 (UTC) Received: (qmail 41283 invoked by uid 500); 23 Oct 2015 20:22:07 -0000 Delivered-To: apmail-ignite-dev-archive@ignite.apache.org Received: (qmail 41245 invoked by uid 500); 23 Oct 2015 20:22:07 -0000 Mailing-List: contact dev-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list dev@ignite.apache.org Received: (qmail 41234 invoked by uid 99); 23 Oct 2015 20:22:06 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Oct 2015 20:22:06 +0000 Received: from mail-lf0-f44.google.com (mail-lf0-f44.google.com [209.85.215.44]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 36E911A022C for ; Fri, 23 Oct 2015 20:22:06 +0000 (UTC) Received: by lffz202 with SMTP id z202so95960348lff.3 for ; Fri, 23 Oct 2015 13:22:04 -0700 (PDT) X-Gm-Message-State: ALoCoQl5IJHZkWCj9a1teF85oxBZofxJ+5R/QF/G0e+s6wQ7yBU6Um+gFY1kKKW2onq+Oa5YSeu2 MIME-Version: 1.0 X-Received: by 10.25.38.9 with SMTP id m9mr7746627lfm.112.1445631724430; Fri, 23 Oct 2015 13:22:04 -0700 (PDT) Received: by 10.112.29.50 with HTTP; Fri, 23 Oct 2015 13:22:04 -0700 (PDT) X-Originating-IP: [85.155.76.117] Received: by 10.112.29.50 with HTTP; Fri, 23 Oct 2015 13:22:04 -0700 (PDT) In-Reply-To: References: Date: Fri, 23 Oct 2015 21:22:04 +0100 Message-ID: Subject: Re: MQTT Streamer Code Style and Javadoc fixes (IGNITE-1747) From: Raul Kripalani To: dev@ignite.apache.org Content-Type: multipart/alternative; boundary=001a113f203069433a0522cb5d3e --001a113f203069433a0522cb5d3e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Dmitriy, The first step is to write a complete specification for a coding style. It's still incomplete from what I see. It's inadmissible that new rules pop up in an ad hoc manner during reviews, based on a single person's judgement. If it's not documented in the guidelines, it *cannot be enforced*, neither to contributors nor to committers. No one is a mind reader and no one is going to spend the time to go through all of Ignite's codebase to infer "unwritten rules" and apply them. That's what the guidelines are for. @Yakov =E2=80=94 could you please enhance the guidelines ASAP? @Dmitriy =E2=80=94 just to be clear again. I'm not complaining about follow= ing the guidelines. My intentions are (1) complete coverage in the guidelines and (2) to challenge some rules which just provide fluff with arguable value (IMHO). Never have I questioned the necessity of a clean and uniform codebase. This is primordial in successful OSS. Regards, Ra=C3=BAl. On 23 Oct 2015 21:01, "Dmitriy Setrakyan" wrote: > Gents, > > First of all, can I ask why this review is being done on the dev list > instead of in the Jira? All we are doing is splitting the communication > about the same feature into multiple places. I believe we have all agreed > in the past that Jira is the proper place for it. > > Now, I have not done the review, so I cannot comment on any type of > concurrency or bug fixing. As far as error messages starting with the wor= d > =E2=80=9CFailed to =E2=80=A6=E2=80=9D, I can see a potential reason for i= t. For example, I can do a > grep in the log for the word =E2=80=9CFailed to=E2=80=9D and find many er= ror messages > easily. To Raul=E2=80=99s point, it is not mentioned in the coding guidel= ines, so > it should be up to the project veterans to make sure that the coding > guidelines are properly updated (I am sure we are going to keep finding > such omissions here and there until we get it perfect). > > Generally speaking, the purpose of the coding guidelines is to make the > code more consistent. We have been getting a lot of praise for the qualit= y > of Ignite code, and I believe that it is mainly due to the strict coding > guidelines rules. > > I will start another discussion thread on the dev list asking everyone in > the community, contributors or committers, whether the current guidelines > should be relaxed. > > D. > > On Fri, Oct 23, 2015 at 9:56 AM, Raul Kripalani wrote: > > > Hey Yakov, > > > > About the exception messages, come on, you have to admit you are making > up > > rules as we go ;-) > > > > Nowhere in the coding guidelines does it say that all exception message= s > > have to start with "Failed to...". In fact, there are hundreds if not > > thousands of Exception messages in the existing Ignite codebase. > Examples: > > > > throw new IgniteException("Spring application context resource is n= ot > > injected."); > > throw new IgniteException("Cache store was not properly > initialized."); > > throw new IgniteClientDisconnectedException(reconnectFut, "Client > node > > disconnected: " + gridName); > > throw new GridClientClosedException("Client was closed (no public > > methods of client can be used anymore)."); > > > > About the full stop at the end, there is a reference, but the way it's > > written is incorrect (make each token start with upper case and end wit= h > a > > dot?!?!) > > > > Note that all prefix, postfix, name, value should follow English > > grammar, in particular, start with upper case and end with the dot '.'. > > > > Moreover, not even the examples on the Wiki are following that rule. > > Neither are lots of exceptions in the current code base... Please revie= w > > the whole situation as it seems that double standards are being applied > for > > old vs. newly contributed code. > > > > Also, I noticed that you changed all of my inline comments to upper cas= e > > and finished them with a dot. Could you please add this rule to the Wik= i? > > > > Finally, I have pushed a new version of the streamer that checks the > > connection state by calling MqttStreamer#isConnected. Changed the retri= er > > accordingly and added 2 unit tests. > > > > I don't consider syncConn is an appropriate nor user-friendly > denominator. > > > > Regards, > > > > *Ra=C3=BAl Kripalani* > > PMC & Committer @ Apache Ignite, Apache Camel | Integration, Big Data a= nd > > Messaging Engineer > > http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalan= i > > http://blog.raulkr.net | twitter: @raulvk > > > > On Fri, Oct 23, 2015 at 8:12 AM, Yakov Zhdanov > > wrote: > > > > > Raul, > > > > > > My comments are below. > > > > > > 2015-10-22 22:22 GMT+03:00 Raul Kripalani : > > > > > > > Hi Yakov, > > > > > > > > Thanks for the review. > > > > > > > > Comments inline. > > > > > > > > Aside from them: being honest, do you think Javadoc like the > following > > > > snippets are useful and provide any value? More so in a test case..= . > > > > > > > > Snippet #1: > > > > > > > > /** > > > > * @param topics Topics. > > > > * @param fromIdx From index. > > > > * @param cnt Count. > > > > * @param singleMsg Single message flag. > > > > * @throws MqttException If failed. > > > > */ > > > > > > > > > > This makes sense for me - this makes code looks consistent. > > > > > > > > > > > > > > Snippet #2: > > > > > > > > /** > > > > * @throws Exception If failed. > > > > */ > > > > > > > > To me, they are redundant. And I'm concerned about imposing > superfluous > > > > Javadoc "just because", or due to aesthetics, rather than value. > > > > > > > > > > This is not so redundant. If some special condition should be > mentioned - > > > go ahead and put it to javadoc. This javadoc shows at least that > > developer > > > has not just forget to put the description and there are no special > > > conditions to mention. > > > > > > Moreover, I thought I saw couple of places where javadoc stated > @throws, > > > but method did not throw any exception. It seems I fixed that. Can yo= u > > > please take a look at my changes? > > > > > > Another point - javadoc to streamer public method > > (isBlockUntilConnected()) > > > was completely omitted. I hope everyone agrees that configurational > > methods > > > should be documented. > > > > > > > > > > > > > > Regards, > > > > > > > > *Ra=C3=BAl Kripalani* > > > > PMC & Committer @ Apache Ignite, Apache Camel | Integration, Big Da= ta > > and > > > > Messaging Engineer > > > > http://about.me/raulkripalani | > > http://www.linkedin.com/in/raulkripalani > > > > http://blog.raulkr.net | twitter: @raulvk > > > > > > > > On Thu, Oct 22, 2015 at 11:52 AM, Yakov Zhdanov > > > > > wrote: > > > > > > > > > Hi Raul! > > > > > > > > > > Thank you very much for addressing my comments! > > > > > > > > > > I like the code however there are still a couple of points (I > > committed > > > > > everything to ignite-1747): > > > > > > > > > > 1. Please take a look at > > > > > > > > > > > > > > > > > > > > https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines#Codi= ngGuidelines-StringOutput > > > > > > > > > > > > Yeah, I'm familiar with this rule and I thought I was complying wit= h > > it. > > > > Could you give me an example where the code is not compliant? > > > > > > > > > > throw new IgniteException("Exception while initializing > > > MqttStreamer", t); - does not start with "Failed to.." and does not e= nd > > > with dot > > > throw new IgniteException("Attempted to stop an already > > stopped > > > MQTT Streamer"); > > > throw new IgniteException("Exception while stopping > > > MqttStreamer", t); > > > > > > + 'MqttStreamer' vs 'MQTT Streamer' inconsistency. I like 'MQTT > Streamer' > > > more. > > > > > > I thought I changed those lines. Can you please take a look at my > > changes? > > > > > > > > > > > > > > > > > > > 2. org.apache.ignite.stream.mqtt.MqttStreamer#connected - volatil= e > > > write > > > > > then read of most likely the same value - I changed it to return > true > > > > > literal. > > > > > connected =3D true; > > > > > return connected; > > > > > > > > > > > > > Agree. > > > > > > > > > > > > > 3. blockUntilConnected - I would name this property syncConn > > > > > > > > > > > > > Why? To me "blockUntilConnected" is clearer and more explicit than > > > > "syncConn", which sounds mystic to an ordinary user who's not > familiar > > > with > > > > the community's abbreviation table. It's ok for a private member, b= ut > > not > > > > for a property. In fact, syncConn requires the user to have the > Javadoc > > > > handy, blockUntilConnected doesn't. So I prefer the latter. > > > > > > > > > > This name does not state that connection is blocked on start. Moreove= r, > > > this adds no value as connection may disappear right after start and > > > streamer should recover connection in background. Maybe we can remove > it? > > > > > > > > > > > > > > > 4. Abbreviation rules violations - connected - conn, executor - > exec, > > > > > values - vals, count - cnt, message - msg > > > > > > > > > > > > > Ok, this is a rule... yeah. But you can imagine it's extremely hard > to > > > > memorise someone else's glossary. In my opinion, abbreviations shou= ld > > be > > > > used only when needed, not by default. An abbreviation subtracts > > > > readability for the general user =E2=80=93 long-term Ignite develop= ers are > > > probably > > > > used to these by now. > > > > > > > > > > > > > 5. What is the point of "connected" member? Client has > > "isConnected()"? > > > > Is > > > > > it similar to what you want to achieve? > > > > > > > > > > > > > I'll look at the implementation of MqttClient.isConnected(), but of= f > > the > > > > top of my head, it seems it could be replaced, yes. > > > > > > > > > > > > > 6. Race on stop - 1 thread calls stop and successfully exits the > > > method, > > > > > retrier is not stopped (awaitTermination has not been called - > should > > > it > > > > > be?) and can connect client back - is this the case? > > > > > > > > > > > > > I'll have a look. > > > > > > > > > > > > > 7. I think we use {@code } instead of ... > > > > > > > > > > > > > Correct. Thanks. > > > > > > > > On more point community should agree on - imports ordering and > > > grouping. I > > > > > will post another email. > > > > > > > > > > > > > This was already added a few weeks ago in the Coding rules. > > > > > > > > > That's fine then. > > > > > > > > > Yakov > > > > > > --001a113f203069433a0522cb5d3e--