-
-
Save AramRafeq/4bb1d6bf9b04392c39493fae66c73e2e to your computer and use it in GitHub Desktop.
arrow head https://devstree.io/arrow-head-antipattern/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if | |
if | |
if | |
if | |
if | |
end if | |
end if | |
end if | |
end if | |
end if |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void DoSomething(string param1, string param2) | |
{ | |
if (param1 != null) | |
{ | |
if (param2 != null) | |
{ | |
if (param1 == "Foo") | |
{ | |
if (param2 == "Bar") | |
{ | |
Console.WriteLine("Foo Bar!"); | |
} | |
else | |
{ | |
Console.WriteLine("Not Foo Bar !"); | |
} | |
} | |
else | |
{ | |
Console.WriteLine("Not Foo Bar !"); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void DoSomethingBetter(string param1, string param2) | |
{ | |
if (param1 == null) | |
return; // datwani return y bkay, yanish... | |
if (param2 == null) | |
throw new ArgumentNullException("param2"); // exception y throw bkay | |
if (param1 == "Foo" && param2 == "Bar") | |
Console.WriteLine("Foo Bar!"); | |
else | |
Console.WriteLine("Not Foo Bar!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void DoSomethingVeryShort(string param1, string param2) | |
{ | |
if (param1 == null || param2 == null) | |
return; | |
if (param1 == "Foo" && param2 == "Bar") | |
Console.WriteLine("Foo Bar!"); | |
else | |
Console.WriteLine("Not Foo Bar!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void DoSomethingNoReturn(string param1, string param2) | |
{ | |
bool everythingIsOkay = param1 != null && param2 != null; | |
if (everythingIsOkay) | |
{ | |
if (param1 == "Foo" && param2 == "Bar") | |
Console.WriteLine("Foo Bar!"); | |
else | |
Console.WriteLine("Not Foo Bar!"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void DoSomethingNoReturn2(string param1, string param2) | |
{ | |
bool notNull = param1 != null && param2 != null; | |
bool notShort = param1.Length >= 3 && param2.Length >= 3; | |
bool everythingIsOkay = notNull && notShort; | |
if (everythingIsOkay) | |
{ | |
if (param1 == "Foo" && param2 == "Bar") | |
Console.WriteLine("Foo Bar!"); | |
else | |
Console.WriteLine("Not Foo Bar!"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void DoSomethingThirdWay(string param1, string param2) | |
{ | |
if (param1 != null && param2 != null && param1.Length >= 3 && param2.Length >= 3) | |
{ | |
if (param1 == "Foo" && param2 == "Bar") | |
Console.WriteLine("Foo Bar!"); | |
else | |
Console.WriteLine("Not Foo Bar!"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void DoLoop() | |
{ | |
for (int i = 0; i < 100; i++) | |
{ | |
for (int j = 0; j < 100; j++) | |
{ | |
for (int k = 0; k < 100; k++) | |
{ | |
// do something | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void DoLoop() | |
{ | |
for (int i = 0; i < 100; i++) | |
{ | |
FunctionA(); | |
} | |
} | |
void FunctionA() | |
{ | |
for (int j = 0; j < 100; j++) | |
{ | |
FunctionB(); | |
} | |
} | |
void FunctionB() | |
{ | |
for (int k = 0; k < 100; k++) | |
{ | |
// do something | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment