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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:50:25+00:00 2026-06-11T19:50:25+00:00

I sometimes have colleagues frowning about using the return statement to leave a routine

  • 0

I sometimes have colleagues frowning about using the return statement to leave a routine (before the end) because it looks like a kind of hidden goto and all gotos are evil. I neither share the thought about a goto being bad no matter how used nor can I really see why using return like this is so bad.

The question is relatively language independent. I currently program in PL/SQL and Objective-C so I give examples in this languages.

Objective-C

-(void)finishedLoading:(NSString*)result success:(BOOL)success 
{
    NSLog(@"delegate method finished loading invoked");   
    if (!success) {
        self.status.text = @"Failed to load file.";
        return; // IS THIS BAD??
    }

    self.status.text = @"File loaded.";

    // do more stuff here with result string
}

PL/SQL

PROCEDURE example(i_parameter pls_integer)
AS
BEGIN
   IF i_parameter IS NULL THEN
      RETURN; -- is this bad??
   END IF;

   -- do more stuff here

END example;

The examples are really only examples and maybe they can be criticized as they are, but I rather would like to know why the return should not be done. The only alternative that I see is to have a routine wide embracing if statement with potentially nested ifs making it hard to read but some people prefer that and I never figured out why.

  • 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-06-11T19:50:26+00:00Added an answer on June 11, 2026 at 7:50 pm

    I think it’s fine. In fact, I try to do all my validation at the top, either throwing or returning as necessary before the ‘meat’ of the method. Keeps things simpler with fewer nested-if/else’s, etc. Also easier to unit-test with fewer code-paths to cover.

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

Sidebar

Related Questions

I have three checkboxes like ch[0], ch[1] and ch[3] (sometimes i have more, or
I have tables like Customer , Purchase etc which sometimes have associated documents with
I have variable 'cno' and it's values sometimes have 123# - ( end with
In php, why do people sometimes have things like param mixed $value as comment
I see on sites that they sometimes have a statistic showing how many views
Our build workflows are a bit involved in the sense they sometimes have to
I'm testing out the OpenERP 6.1 web client, and I sometimes have a sales
I'm part of a team building an ADO.NET based web-site. We sometimes have several
Sometimes I have to check for some condition that doesn't change inside a loop,
Sometimes I have to write code that alternates between doing things and checking for

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.