Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 670945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:19:10+00:00 2026-05-14T00:19:10+00:00

I always thought that parentheses improved readability, but in my textbook there is a

  • 0

I always thought that parentheses improved readability, but in my textbook there is a statement that the use of parentheses dramatically reduces the readability of a program. Does anyone have any examples?

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:19:10+00:00Added an answer on May 14, 2026 at 12:19 am

    I can find plenty of counterexamples where the lack of parentheses lowered the readability, but the only example I can think of for what the author may have meant is something like this:

    if(((a == null) || (!(a.isSomething()))) && ((b == null) || (!(b.isSomething()))))
    {
       // do some stuff
    }
    

    In the above case, the ( ) around the method calls is unnecessary, and this kind of code may benefit from factoring out of terms into variables. With all of those close parens in the middle of the condition, it’s hard to see exactly what is grouped with what.

    boolean aIsNotSomething = (a == null) || !a.isSomething();  // parens for readability
    boolean bIsNotSomething = (b == null) || !b.isSomething();  // ditto
    if(aIsNotSomething && bIsNotSomething)
    {
       // do some stuff
    }
    

    I think the above is more readable, but that’s a personal opinion. That may be what the author was talking about.

    Some good uses of parens:

    • to distinguish between order of operation when behavior changes without the parens
    • to distinguish between order of operation when behavior is unaffected, but someone who doesn’t know the binding rules well enough is going to read your code. The good citizen rule.
    • to indicate that an expression within the parens should be evaluated before used in a larger expression: System.out.println("The answer is " + (a + b));

    Possibly confusing use of parens:

    • in places where it can’t possibly have another meaning, like in front of a.isSomething() above. In Java, if a is an Object, !a by itself is an error, so clearly !a.isSomething() must negate the return value of the method call.
    • to link together a large number of conditions or expressions that would be clearer if broken up. As in the code example up above, breaking up the large paranthetical statement into smaller chunks can allow for the code to be stepped through in a debugger more straightforwardly, and if the conditions/values are needed later in the code, you don’t end up repeating expressions and doing the work twice. This is subjective, though, and obviously meaningless if you only use the expressions in 1 place and your debugger shows you intermediate evaluated expressions anyway.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I always thought that you could use OR in a LIKE statment to query
I always thought that if you didn't implement a heartbeat, there was no way
I always thought that an if statement essentially compared it's argument similar to ==
I always thought that form borders that use programs like iTunes or Visual Studio
I've always thought that Python's advantages are code readibility and development speed, but time
I've always thought that server-side code is unaffected by the browser requesting it, but
I always thought that the nullable types of the .NET framework where nothing but
I always thought that an statement like const int *a means a is an
I always thought that jinja was better because of template extending.. but them I've
I always thought that Predef.println was merely a shortcut for System.out.println , but apparently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.