C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 04-24-2002, 06:18 AM   #1
Unregistered
Guest
 
Posts: n/a
Question Which code is more effective?

Which cod is more effective?

int main()
{
int err = 0;
...
err = Function1();
if( err != 0 ){
...
return 1;
}
...
err = Function2();
if( err != 0 ){
...
return 2;
}
...
err = Function3();
if( err != 0 ){
...
return 3;
}
...
return 0;
}

OR:

int main()
{
int err = 0;
...
err = Function1();
if( err == 0 ){
...
err = Function2();
if( err == 0 ){
...
err = Function3();
if( err == 0 ){
...
}
}
}
return err;
}
  Reply With Quote
Old 04-24-2002, 06:27 AM   #2
the hat of redundancy hat
 
nvoigt's Avatar
 
Join Date: Aug 2001
Location: Hannover, Germany
Posts: 2,768
a) this is the C# board

b)

>Which code is more effective?

That depends on the situation. They both do the same, in the same amount of time. How you format it in the end is likely to be influenced by existing coding standards for your workplace or your own habits. Most effective is the version that is easier to read. But there is no perfect solution to this, as people are still arguing what is easier to read
__________________
hth
-nv

She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

When in doubt, read the FAQ.
Then ask a smart question.
nvoigt is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Extended ASCII Characters in an RTF Control JustMax C Programming 18 04-03-2009 08:20 PM
Enforcing Machine Code Restrictions? SMurf Tech Board 21 03-30-2009 07:34 AM
Values changing without reason? subtled C Programming 2 04-19-2007 10:20 AM
Updated sound engine code Bubba Game Programming 8 11-18-2004 12:38 PM
Interface Question smog890 C Programming 11 06-03-2002 05:06 PM


All times are GMT -6. The time now is 09:57 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22