Return-Path: X-Original-To: apmail-directory-dev-archive@www.apache.org Delivered-To: apmail-directory-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B706370D1 for ; Wed, 31 Aug 2011 09:48:57 +0000 (UTC) Received: (qmail 1916 invoked by uid 500); 31 Aug 2011 09:48:57 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 1704 invoked by uid 500); 31 Aug 2011 09:48:50 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 1696 invoked by uid 99); 31 Aug 2011 09:48:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Aug 2011 09:48:47 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of pajbam@gmail.com designates 209.85.215.170 as permitted sender) Received: from [209.85.215.170] (HELO mail-ey0-f170.google.com) (209.85.215.170) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Aug 2011 09:48:40 +0000 Received: by eyd10 with SMTP id 10so435365eyd.1 for ; Wed, 31 Aug 2011 02:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; bh=1F0yEV3sSDEEO4UEyq/m2/buaN1H9B1+MUBVm/aymrY=; b=fN4xoZlmKG9jlnW6VKJ6ZZxpt6TO9DmwFCEz0HMNxZnH+hYigLH+0+xyrtcTRiJ59y 0WqI7WMiOW6wmzmM7xI1t7BBEGRIBhInzk+2R2634RWkYoW8M4THYCNrTmAQbcAAGvvj XlpMebdoMB3fDw+vqzM9xfmfMilklhg0d66ME= Received: by 10.213.112.136 with SMTP id w8mr157053ebp.104.1314784099744; Wed, 31 Aug 2011 02:48:19 -0700 (PDT) Received: from [10.0.1.2] (def92-4-82-225-58-213.fbx.proxad.net [82.225.58.213]) by mx.google.com with ESMTPS id q10sm1396333eef.33.2011.08.31.02.48.17 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 31 Aug 2011 02:48:18 -0700 (PDT) Sender: Pierre-Arnaud Marcelot Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Apple Message framework v1084) Subject: Re: Coding rules, some more things to discuss From: Pierre-Arnaud Marcelot In-Reply-To: Date: Wed, 31 Aug 2011 11:48:15 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <6BC81C55-7B42-4BBB-B65A-BB6D9CCF5A67@marcelot.net> References: <4E5CE665.2030008@gmail.com> <07AF0E26-47A5-4801-9050-6AB00992954A@marcelot.net> To: "Apache Directory Developers List" X-Mailer: Apple Mail (2.1084) X-Virus-Checked: Checked by ClamAV on apache.org On 31 ao=FBt 2011, at 11:06, Kiran Ayyagari wrote: > On Wed, Aug 31, 2011 at 12:38 PM, Pierre-Arnaud Marcelot > wrote: >> On 30 ao=FBt 2011, at 15:32, Emmanuel Lecharny wrote: >>=20 >>> Hi guys, >>=20 >> Hi, >>=20 >>> we just had a private convo with Pierre-Arnaud about coding rules. = We are not following exactly the same type of rules in Studio and in = ADS, which is quite normal. There are some reason why there is a = divergence. >>=20 >> As we've seen in our private convo with Emmanuel, the divergence is = very very subtle and it's mostly a divergence on "unwritten" rules that = we can't find in our coding standards documentation... >> The rest of rules are clearly well followed (except some very very = old parts of code that haven't been touch for years now). >>=20 >>> I think we need to discuss a few things here. >>>=20 >>> Currently, we have a small coding standard page : = https://cwiki.apache.org/confluence/display/DIRxDEV/Coding+standards >>>=20 >>> It's pretty simple, with not a lot of rules. Both ADS and Studio are = more or less following those rules which were established a long time = ago (there are still some very old files in ADS which are not following = those rules, but with more than 3000 files on the project, we won't = spend one month reviewing all of those files one by one...) >>=20 >> Same thing for Studio. >> Some pretty old files may not be following *all* the rules. >>=20 >>> I'd like to add a few more rules, at least for ADS, and suggest that = Studio keep a slightly different sets of rules, but in any case, I'd = like to see all the rules added to the wiki. >>>=20 >>> Here is what I think would be good for ADS : >>> - add a blank line before each 'if', 'for', 'do', 'switch', 'case' = unless the previous line is a '{' >>=20 >> In most cases I agree, but I find some cases where I prefer leaving = the if close to the previous expression. >> Especially in cases where I get a variable and I want to test = something on it just after. >> Here's an example: >>>> // Testing variable >>>> SomeType variable =3D anotherVariable.getVariable(); >>>> if ( variable.hasFlag() ) >>>> { >>>> [...] >>=20 >> In that particular case, IMO, it helps grouping expressions for a = better readability. >>=20 >>> - get rid of trinary operator ( expr ? op1 : op2 ) >>=20 >> I would prefer keeping it as it's very handy for variable nullity = checks. >>=20 >> Here's an example: >>>> return ( ( variable =3D=3D null ) ? "null" : variable ); >>=20 >>=20 >> I prefer the compact format instead of this: >>>> if ( variable =3D=3D null ) >>>> { >>>> return "null"; >>>> } >>>> else >>>> { >>>> return variable; >>>> } >>=20 >> Now, if I'm the only one liking it, I will refrain myself from using = it in the future... ;) >>=20 >>> - add a blank line before each 'return' >>=20 >> +1 >>=20 >>> - in if ( expr ), we should use '(' and ')' for expressions = containing an '=3D=3D' or any other logical connector >>=20 >> +1 >>=20 >>> We also may want to add some rules for pom.xml. >>=20 >> +1 >> Even though I think we already share the same rules, having them = written is always a plus. Especially for newcomers. >>=20 >>> Typically, what I'd like to see is a blank line between each element = like . Here is an example : >>>=20 >>> >>> >>> >>> org.apache.directory.shared >>> shared-ldap-model >>> provided >>> >>>=20 >>> >>> org.apache.directory.shared >>> shared-util >>> provided >>> >>>=20 >>> This is to separate all the items which have the same dame, for = clarity sake. >>=20 >> Why not. >> I liked the idea of grouping a set of dependencies under a common = "label" like this "Apache Directory Studio library plugins dependencies" = in your example. >> But adding a blank line doesn't really break either... >> So, +1. >>=20 >> One more thing I'd like to add to pom.xml guidelines, I really like = when dependencies are ordered in alphabetical order. >> In Studio, we deal with a lot of dependencies for each project = (mostly Eclipse dependencies + a few others) and having them ordered = REALLY helps when looking for something, IMO. >>=20 > won't this be a bit laborious to order the dependencies by name Hopefully, most of the pom.xml files are already almost following this = path. I think this is somehow a natural thinking. At least for me. Even though, I admit it, I think I'm a little too = maniac about ordering things in code (at home and in life too...) Maybe, I should consult someone... ;) > ( we have Ctrl + F anyway :) Haha, yeah, that's true. One big advantage I also see by the alphabetical ordering of = dependencies is that it allows you to catch duplicated dependencies = easily, which could then be a problem if you think you removed a = dependency and it's still there because it was duplicated. I had this problem personally a few times already. >>> For Studio, I let Stefan and Pierre-Arnaud define the rules they = prefer to use, as i'm not working often on its code. >>=20 >> For the sake of a better interaction and simplicity, I think we = should share the same rules across the whole Directory project. >> As I'm mostly the only dissident on some of the facts above, I can = and will adapt myself. >> Not a big deal (except for the trinary operator... ;) ). >>=20 >> Regards, >> Pierre-Arnaud >>=20 >>=20 >>> Any comments ? >>>=20 >>> -- >>> Regards, >>> Cordialement, >>> Emmanuel L=E9charny >>> www.iktek.com >>>=20 >>=20 >>=20 >=20 >=20 >=20 > --=20 > Kiran Ayyagari