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

  • Home
  • SEARCH
  • 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 3751524
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:05:13+00:00 2026-05-19T09:05:13+00:00

I am tagging this as C, though it certainly applies to many languages. The

  • 0

I am tagging this as C, though it certainly applies to many languages. The reason for this is the part of the question dealing with optimization, which is compiler dependent.

Sometimes we encounter situations like this in programs:

if(bob == 42)
{
    /* ... */
    return;
}
else
{
    /* ... */    
}

The else block here is not strictly necessary, as you can probably see. The same thing also occurs with other program-flow-controlling structures; some “ordinary” constructs are made redundant because of special conditions. The question is: Is there a reason to write these redundant blocks of code? Clarity? Could it possibly help a compiler with optimizations, if the situation was complex enough?

  • 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-19T09:05:14+00:00Added an answer on May 19, 2026 at 9:05 am

    I refer to what you’ve written as “self-documenting code”. By using the else block, you make it easier for people to see that if bob does not equal 42 the 2nd block of code will fire.

    In my computer science classes, we would be given code samples like this to test our logical skills. But in the business world, you really don’t want to confuse people or do anything that could slow down progress. Therefore, you should opt for whatever is easiest to read assuming the performance hit is negligible.

    Self-documenting code means that the explanation of what is going on can be seen in the function names or by reading the actual code, reducing the need for code comments.

    As far as running the code goes, do some tests with some timing code to see what performs better.

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

Sidebar

Related Questions

I'm experimenting with a tagging system which is a many-to-one relationship. My schema is:
i am using the Toxi solution on this site for tagging bookmarks: http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html In
I am trying to design a tagging system with a model like this: Tag:
I have a Django app that use a django-tagging. I need to port this
EDIT : To people building tagging systems. Don't read this. It is not what
This is my first project in django and im using photologue for gallery, which
I am not sure whether this is an appropriate question to ask in this
Is tagging is the best user friendly way to categorize a subject? An example
I am designing a Tagging system for my site(a customized blog). These are my
I using Django tagging project. That is was very stable project. Working on django

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.