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 226009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:28:10+00:00 2026-05-11T19:28:10+00:00

My OCD makes me add break when writing case statements, even if they will

  • 0

My OCD makes me add “break” when writing case statements, even if they will not be executed. Consider the following code example:

switch(option) {
    case 1:
        a = 1;
        b = 7;
        break;
    case 2:
        a = 2;
        b = 4;
        return (-1);
        break;
    default:
        a = -1;
        break;
}

My two questions are:
For “case 2:”, I don’t really need the break, but is it a good idea to have it there anyway?
For “default:”. Is it purely OCD, or is there any real reason to have the break here?

  • 1 1 Answer
  • 0 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-11T19:28:11+00:00Added an answer on May 11, 2026 at 7:28 pm

    You don’t need either break, but there’s no harm in having them. In my opinion, keeping your code structured is worth having a couple of extraneous statements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code, where Config.PREFERENCES_ENABLE is a static final boolean , produces a compiler
I think I have something like programmer's OCD. I like my code to be
I'm working on an LGPL game engine library and I prefer to code without
I know it's 'technically' not the best practice to be hard coding strings; but
I have just discovered the command :sort n in vim (how did I not
I'm attempting to add data to a table and linq to entities throws an
For reasons it's not worth getting into, the object Model of the django application
Depending on your interpretation this may or may not be a rhetorical question, but
I am using MVC 3 with Razor. I can't figure out how to code
current_working_directory = os.getcwd() relative_directory_of_interest = os.path.join(current_working_directory,../code/framework/zwave/metadata/) files = [f for f in os.listdir(relative_directory_of_interest) if

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.