Clean Code Tips #4-6: Method Arguments

#4:  Methods should have as few arguments as possible.  Ideally, they should never have more than three.  If there’s more than three, then it’s likely the arguments should be wrapped into a class of their own.

#5:  Boolean arguments should be avoided because it complicates the method name and the purpose of the method.  Passing a boolean will likely cause your method to do two different things based on the bool.  This is in contradiction to rule #2.

#6:  Methods that change input arguments should be defined so the argument is the return value.  This also prevents the usage of output arguments which can be confusing.


About Brian McKay
Software Architect

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: