
Originally Posted by
DimitriSavage
I know more then anyone about clean code
yeah, sure... best example (
Old Post from you):
1. Naming conventions, public members always start with uppercase char in C#
2. Members in a class with the same name as the class, should always be a constructor, no matter if the case does match or not
3. Nested code is bad, you end up with giant nested code, which makes it not really readable
4. "if" in "if" is bad, reduce them as much as possible to a single if
5. If you just have a method to check something, replace the if with return and everything will be fine
6. Use clear member/parameter names
(7. make a use of the "params" keyword, use it to create universal methods like the check method)
so dont tell me something about clear code now...
Result:
Code:
internal class Password
{
public static bool Check(string toCheck1, string password1, string toCheck2, string password2, string toCheck3, string password3)
{
return toCheck1 == password1 && toCheck2 == password2 && toCheck3 == password3;
}
}
Result with 7.:
Code:
internal class Password
{
public static bool Check(string toCheck, string password, params Tuple<string, string>[] rest)
{
return toCheck == password && rest.All(_ => _.Item1 == _.Item2);
}
}