Conor MacNeill wrote:
Likewise, I do not see converting an if-else to a
ternary conditional makes the code clearer - on the contrary it makes it
more convoluted.
Ternary conditionals are one of my favorite things. I riddle the code with them in the interest of making it smaller... surely it doesn't raise the barrier of entry to understanding Ant's code _that_ much? :)
No, not *that* much but it's not really necessary. As an example, I personally find in the following, the original code is *much* clearer in intent and even in formatting.
- if (callee != null) { - return callee.handleInput(buffer, offset, length); - } else { - return super.handleInput(buffer, offset, length); - } + return (callee != null ? + callee.handleInput(buffer, offset, length) : + super.handleInput(buffer, offset, length) + );
Personally, I primarily use terneraries for situations such as parameter passing, where I need to pass one of two values. In general, I much prefer readable code with good variable names over smaller code with abbrv vrbl nms.
Conor
To the danger to be sounding mee tooish. The coding rules I made for the company I work for prohibit multiline ?: constructs AND prohibit multiple method calls to other objects in one statement. The reason is ?: tends to get less readable when used in multiline constructs (btw there is also a limit on line length). Multiple method calls / chaining / method calls as parameter make debugging and interpreting stack traces more difficult, also it tends to be less visible that such method is executed, which is certainly important when the method isn't a simple getter. Both rules would be violated in one single statment. IMHO Anything that does raises the barrier to understand code that can be avoided should be avoided.
Martijn
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]