Long Parameter List: Too Much Information
Long Parameter List
Methods that take too many parameters produce client code that is awkward and difficult to work with.
It's common to see parameter lists grow and grow when a method requires too much data.Callers of the method often have an awkward time assembling all of the data and the resulting code is usually not too pretty.In the example below, 11 parameters are passed into UserManager
's create(...)
method.
(Ugly wrapping or a horizontal scrollbar are other signs of the awkwardness of this smell.)
class OwnershipTest…
private:
void CreateUserInGroup()
{
GroupManager groupManager;
Group* group = groupManager.Create(TEST_GROUP, false, GroupProfile::UNLIMITED_LICENSES, "", GroupProfile::ONE_YEAR, NULL); user = userManager.Create(USER_NAME, group, USER_NAME, "joshua", USER_NAME, LANGUAGE, false, false, new Date, "blah", new Date);
}
(Reading...)
Formatting Hints:
To format... | use this markup: |
---|---|
source code | {source:lang=java|lineNumbers=false}...{source} (Supported languages: java, cpp, csharp, c, python.) |
bold text | __some text__ |
italicized text | ~~some text~~ |
underlined text | @@some text@@ |
a method or class name | ``myMethod(...)`` |