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 CC0347070 for ; Wed, 31 Aug 2011 08:52:53 +0000 (UTC) Received: (qmail 46393 invoked by uid 500); 31 Aug 2011 08:52:53 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 46190 invoked by uid 500); 31 Aug 2011 08:52:47 -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 46178 invoked by uid 99); 31 Aug 2011 08:52:45 -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 08:52:45 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [62.179.121.33] (HELO fep13.mx.upcmail.net) (62.179.121.33) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Aug 2011 08:52:37 +0000 Received: from edge02.upcmail.net ([192.168.13.237]) by viefep13-int.chello.at (InterMail vM.8.01.02.02 201-2260-120-106-20100312) with ESMTP id <20110831085216.QPWY1686.viefep13-int.chello.at@edge02.upcmail.net> for ; Wed, 31 Aug 2011 10:52:16 +0200 Received: from asgard.felixknecht.ch ([84.73.177.134]) by edge02.upcmail.net with edge id SwsE1h01Q2uMsfo02wsGLx; Wed, 31 Aug 2011 10:52:16 +0200 X-SourceIP: 84.73.177.134 X-Authenticated-Sender: felixknecht@hispeed.ch Message-ID: <4E5DF63E.8070705@apache.org> Date: Wed, 31 Aug 2011 10:52:14 +0200 From: Felix Knecht Reply-To: felixk@apache.org User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Apache Directory Developers List Subject: Re: Coding rules, some more things to discuss References: <4E5CE665.2030008@gmail.com> <07AF0E26-47A5-4801-9050-6AB00992954A@marcelot.net> <4E5DEBCA.1010505@apache.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Cloudmark-Analysis: v=1.1 cv=1spcbIYDqsXqpWho1FqXt/RH1HhH/N0x2ckrrSfPMwM= c=1 sm=0 a=CHB2QqGCMfkA:10 a=_ARDh0OnajgA:10 a=7qsJXG2k14gA:10 a=pXoq77xVGrQA:10 a=8nJEP1OIZ-IA:10 a=mV9VRH-2AAAA:8 a=sxNCP32KAAAA:8 a=6PRwQycpdP0CXGixS_0A:9 a=S0KRhn7rdfW3J2Sy7Z4A:7 a=wPNLvfGTeEIA:10 a=eX9hJc8_SS95zKXV:21 a=Dau4c_XKiM0JKJle:21 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 X-Virus-Checked: Checked by ClamAV on apache.org Hi Pierre-Arnaud, On 08/31/2011 10:33 AM, Pierre-Arnaud Marcelot wrote: > Hi Felix, > > On 31 ao�t 2011, at 10:07, Felix Knecht wrote: > >> On 08/31/2011 09:08 AM, Pierre-Arnaud Marcelot wrote: >>> On 30 ao�t 2011, at 15:32, Emmanuel Lecharny wrote: >>> >>>> Hi guys, >>> >>> Hi, >>> >>>> 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. >>> >>> 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). >>> >>>> I think we need to discuss a few things here. >>>> >>>> Currently, we have a small coding standard page : https://cwiki.apache.org/confluence/display/DIRxDEV/Coding+standards >>>> >>>> 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...) >>> >>> Same thing for Studio. >>> Some pretty old files may not be following *all* the rules. >>> >>>> 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. >>>> >>>> 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 '{' >>> >>> 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 = anotherVariable.getVariable(); >>>>> if ( variable.hasFlag() ) >>>>> { >>>>> [...] >>> >>> In that particular case, IMO, it helps grouping expressions for a better readability. >>> >>>> - get rid of trinary operator ( expr ? op1 : op2 ) >>> >>> I would prefer keeping it as it's very handy for variable nullity checks. >>> >>> Here's an example: >>>>> return ( ( variable == null ) ? "null" : variable ); >>> >>> >>> I prefer the compact format instead of this: >>>>> if ( variable == null ) >>>>> { >>>>> return "null"; >>>>> } >>>>> else >>>>> { >>>>> return variable; >>>>> } >>> >>> Now, if I'm the only one liking it, I will refrain myself from using it in the future... ;) >>> >>>> - add a blank line before each 'return' >>> >>> +1 >>> >>>> - in if ( expr ), we should use '(' and ')' for expressions containing an '==' or any other logical connector >>> >>> +1 >>> >>>> We also may want to add some rules for pom.xml. >>> >>> +1 >>> Even though I think we already share the same rules, having them written is always a plus. Especially for newcomers. >>> >>>> Typically, what I'd like to see is a blank line between each element like. Here is an example : >>>> >>>> >>>> >>>> >>>> org.apache.directory.shared >>>> shared-ldap-model >>>> provided >>>> >>>> >>>> >>>> org.apache.directory.shared >>>> shared-util >>>> provided >>>> >>>> >>>> This is to separate all the items which have the same dame, for clarity sake. >>> >>> 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. >>> >>> 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. >> >> I absolutely agree. On which tag (groupId | artifactId) would you order them? No matter wich one we take it should be the first tag after, so for artifactId it would be >> >> >> shared-ldap-model >> org.apache.directory.shared >> >> >> Ordering by groupId would make it possible to group then under a common "label". > > My personal preference would be to keep the structure of a dependency element the way it is used at the moment (groupId tag first then and artifactId in second), like this: > > ${groupId} > ${artifactId} > > > I would order dependencies by groupId first and then, in the case of an identical groupId, I would order them via their artifactId. > > That's why I think we should stick with the order groupId, artifactId. > But I might be wrong. ;) I don't think that you're wrong, I totally agree with this. > > Of course, ordering rules should not applied on "labels" themselves and "labels" could be ordered the way we want, according to the importance of each "label". > BUT, in each label, the dependencies should be ordered by alphabetical order. > > This scheme would allow to have different regroupments ("labels") ordered by importance and each of the regroupments dependencies would be classified by alphabetical order. > > Does it make sense? I'm not that positive of these regroupments ("labels"). - Having an alphabetic ordering I'd assume to find a dependency according the ordering - this might not be the case because of the regroupments. - Where do overridden transitive dependencies belong? Into the regroupment of it's parent? Into a regroupment labeled "miscellaneous"? - What are the criterias about the importance of a label? That's why I'd have them ordered as you proposed (groupId/artifactId) but not regrouped by importance. Regards Felix > >>> >>>> For Studio, I let Stefan and Pierre-Arnaud define the rules they prefer to use, as i'm not working often on its code. >>> >>> 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... ;) ). >>> >>> Regards, >>> Pierre-Arnaud >>> >>> >>>> Any comments ? >>>> >>>> -- >>>> Regards, >>>> Cordialement, >>>> Emmanuel L�charny >>>> www.iktek.com >>>> >>> >> >