>> In any case, even if we keep the Java standard code format, there are things >> that must change for rational reasons ... I agree with the points made below the point. Maybe we only require the main coding style to be consistent, I doubt if we're able to enforce the rules in details strictly unless we have such tool.
-----Original Message----- From: Emmanuel Lécharny [mailto:[email protected]] Sent: Tuesday, January 13, 2015 5:17 PM To: Apache Directory Developers List Subject: Re: [kerby/haox] Dependencies updates needed Le 13/01/15 09:30, Kiran Ayyagari a écrit : > On Tue, Jan 13, 2015 at 4:01 PM, Zheng, Kai <[email protected]> wrote: > >>>> I don't like 4 spaces for XML files, it's quickly too wide, I use 2 >> spaces. >> Agree, let's follow this. >> >>>> Regarding teh Java code, I suggest we keep what you have (likely >>>> Java >> code convention), we can vote later on keep it or moving globally to >> another convention. >> I do like the current one that can be most easily setup in IDEA or >> Eclipse in my view and is also very concise/compact in lines, but >> sure I would follow the best practice if we vote one. The major >> concern would be we have to find/write a tool to convert the existing >> codes to use the new style if we have to change. >> >> Current codes follow in the following style I copied from IDEA template. >> === >> public class Foo { >> public int[] X = new int[]{1, 3, 5 7, 9, 11}; >> >> public void foo(boolean a, int x, int y, int z) { >> label1: >> do { >> try { >> if (x > 0) { >> int someVariable = a ? x : y; >> int anotherVariable = a ? x : y; >> } else if (x < 0) { >> int someVariable = (y + z); >> someVariable = x = x + y; >> } else { >> label2: >> for (int i = 0; i < 5; i++) doSomething(i); >> > the above block certainly hurts my eyes ;) I can understand. But let's not be religious about that... In any case, even if we keep the Java standard code format, there are things that must change for rational reasons : 1) int someVariable = a ? x : y; Barely readable. And it's just about using simple variables here, but when it comes to complex expressions, the ? and : will be totally invisible. Better write : if ( a ) { int someVariable = x; } else { int someVariable = y; } Way more readable. 2) someVariable = x = x + y; Yuk. Everytime I see such construct, I vomit. Again, this is an almost guarantee to fuck up big time. Every expression when a normal human being have to *think* to understand what the code is doing is a nail in the coffin of what computer science is made for : spare a human being the pain to think. 3) for (int i = 0; i < 5; i++) doSomething(i); Any construction where a loop is done without { and } to enclose the expression to execute is dangerous. At first, you do something like : for (int i = 0; i < 5; i++); then you decide to do something and change the code to be : for (int i = 0; i < 5; i++); doSomething(i); Now, you are totally fuxked, and it may takes hour to understand why. *Every* single expression must be enclosed into { and }. Otherwise, I don't mind if we decide to use Java coding convention. I prefer the Directory coding convention, because I'm under no obligation to work on a VT-100 since 1985, so with my 1680x1050 display, with 50 lines/200 char per line screen (and it's a laptop, I'm not mentionning those who use a 30" screen here...), and even when using Monaco 11 fonts - and being 50 years old, with difficulties to read small font, it tells something ;-), I have no problem with spaced code.
