code_junkie

What is the prefered style for single decision and action statements?

Nov 10th, 2011
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. if (var == true)
  2. doSomething();
  3.  
  4. if (var == 1)
  5. doSomething(1);
  6. else if (var > 1 && var < 10)
  7. doSomething(2);
  8. else
  9. {
  10. validate(var);
  11. doSomething(var);
  12. }
  13.  
  14. if ( a == b) {
  15. doSomething();
  16. }
  17. else {
  18. doSomething();
  19. }
  20.  
  21. if(a==b)
  22. {
  23. doSomething();
  24. }
  25.  
  26. if(a==b)
  27. doSomething();
  28. doSomethingElse();
  29.  
  30. if(a==b)
  31. {
  32. doSomething();
  33. doSomethingElse();
  34. }
  35.  
  36. if(something)
  37. DoOneThing();
  38. else
  39. DoItDifferently();
  40.  
  41. if(something)
  42. DoOneThing();
  43. else
  44. DoItDifferently();
  45. AlwaysGetsCalled();
  46.  
  47. if (cond1)
  48. {
  49. SomeOperation();
  50. Another();
  51. }
  52. elseif (cond2)
  53. {
  54. DoSomething();
  55. }
  56. else
  57. {
  58. DoNothing();
  59. DoAnother();
  60. }
  61.  
  62. if (cond1)
  63. DoFirst();
  64. elseif (cond2)
  65. DoSecond();
  66. else
  67. DoElse();
  68.  
  69. foreach (var s as Something)
  70. if (s == someCondition)
  71. yield return SomeMethod(s);
  72.  
  73. if (var == 1)
  74. doSomething();
  75. doSomethingElse();
  76.  
  77. if (var == 1)
  78. doSomething();
  79. doSomethingExtra();
  80. doSomethingElse();
  81.  
  82. If A == true
  83. FunctA();
  84.  
  85. If B == "Test"
  86. {
  87. FunctB();
  88. }
  89.  
  90. If A == false {
  91. //calls and whatnot
  92. }
  93. //or
  94. If B == "BlaBla"
  95. {
  96. //calls and whatnot
  97. }
  98. //or
  99. If C == B
  100. {
  101. //calls and whatnot
  102. }
  103.  
  104. if (aString) free(aString);
  105.  
  106. do_something if (a == b)
  107.  
  108. if (a == b)
  109. do_something
  110. do_something_else
  111. end
  112.  
  113. if (a == b)
  114. DoSomething();
  115. DoSomethingElse(); <-- outside if statement
  116.  
  117. if (a == b) DoSomething();
  118.  
  119. var c = (a == b) ? DoSomething() : DoSomethingElse();
  120.  
  121. var c = (a == b)
  122. ? AReallyReallyLongFunctionName()
  123. : AnotherReallyReallyLongFunctionOrStatement();
  124.  
  125. if (condition) {
  126. statements;
  127. }
  128.  
  129. if (condition) {
  130. statements;
  131. } else {
  132. statements;
  133. }
  134.  
  135. if (condition) {
  136. statements;
  137. } else if (condition) {
  138. statements;
  139. } else {
  140. statements;
  141. }
  142.  
  143. if (var == true)
  144. { doSomething(); }
  145.  
  146. if (cond)
  147. {
  148. //statement
  149. }
  150.  
  151. if (i != 0)
  152. bar(i);
  153. foo(i);
  154.  
  155. if(!ok)return;
  156.  
  157. do();
  158.  
  159. that();
  160.  
  161. thing();
  162.  
  163. do_something if condition;
  164.  
  165. do_something unless condition;
  166.  
  167. sub test{
  168. my($self,@args) = @_;
  169.  
  170. return undef unless defined $self;
  171.  
  172. # rest of code goes here
  173.  
  174. }
Add Comment
Please, Sign In to add comment