Some thoughts.
1. Do not use Hungarian notation.
2. Do not use ByRef params/dynamic objects/$lists/args... as an arguments. There are two exceptions: you don't know the number of arguments or there's more than 10 arguments.
3. Method should not parse arguments, only validate arguments. If caller passed invalid input it's caller problem. Fail fast.
4. Mandatory arguments go first.
5. If several methods have similar signatures, the order of arguments should be the same.
6. Same logical arguments in different methods should have the same names.
7. Arguments should be consistent. If you pass primitives, pass primitives everywhere. If you pass dynamic objects, pass them everywhere.
8. Return types should also be consistent.
9. If it's object methods and you pass the same optional arguments in several methods extract these arguments as a property.
- Log in to post comments