2

Our company uses checkstyle to ensure the java source code having no nested if..else. i am trying to get used to it. but i have this doubt, is this a efficient way to improve code quality?

we have many rules,

  1. no nested if else
  2. Method should be no longer than 50 lines.
  3. anonymous inner class no longer than 15 lines.
  4. there must be a white space before {, which means we have to use Ctrl+Shift+F to format code.
6
  • What's an embedded if...else? Things like if(...) { if(...) {...} }? Commented Feb 25, 2012 at 2:26
  • @Chi What do you mean by an embedded if else? Commented Feb 25, 2012 at 2:28
  • i'm pretty sure he means nested if blocks. Commented Feb 25, 2012 at 2:31
  • 1
    Indentation going over to the right hand side of the screen typically indicates a problem. This particular coding style seems a bit, er, eccentric. But if you've got this rule, there are probably far more serious things you might want to clear up first. Commented Feb 25, 2012 at 2:46
  • Yes, it is nested if else, we can't use if(...) { if(...) {...} } Commented Feb 25, 2012 at 2:52

2 Answers 2

2

There are arguments for favoring polymorphism over use of switch or if else blocks. Here is a link to a google tech talk discussing the issue

Sign up to request clarification or add additional context in comments.

Comments

1

Switch / select case statements are generally more efficient, but that seems like a lot of effort over a fairly small issue.

1 Comment

Not to mention that switch only works on values that evaluate to compile time constants.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.