Search
Saturday, June 15, 2019 ..:: Home ::.. Register  Login
   Calendar  
     
  
   Search  
     
  
   Blogroll  
     
  
   Disclosure  
All blog entries are the opinions of the author and do not necessarily reflect the opinions of their employer. All the code presented is for explanation and demonstration purposes only. Any damages incurred to your site and/or data are not the responsibility of the author. Every effort is taken to ensure the code properly compiles, however sometimes there are some hiccups and you might be required to do your own debugging.
     
  
   TechTidBits (Blog)  

Series: Coding Contentions: How do you return?

Aug 27

Written by:
Wednesday, August 27, 2008 1:32 PM  RssIcon

As you're processing a method, how do you return back to the calling method?  Do you have multiple returns in your logic or just have one at the end of the method?

After high-school, I got used to writting one and only one return statement at the end of a method.  I was told it was bad practise to have multiple returns "littered throughout your method."   And you/we were graded that way, multiple returns meant less marks, you quickly learned to bend to "da man."

However, after a few years (ok, stop laughing, it's been a bit more than a few :>) and a few languages (VB, Java, C#), I've seen many high profile programmers using both multiple returns and single returns.  I've even seen it debated online but those URLs escapse me at the moment.

What is part of your coding standards?  Do you have any standards for this type of thing?  Take a look at your existing code and tell me what you're using now.  I would love to read what other people are using/doing!

If you don't know what I'm talking about, here's a sample doing both.

Single and Multiple Returns in methods

Tags:
Categories:
Location: Blogs Parent Separator TechTidBits

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 
     
  
Copyright 1999-2012 by PCHenry.com   Terms Of Use  Privacy Statement