37 lines
1.1 KiB
Plaintext
37 lines
1.1 KiB
Plaintext
You're allowed to make function calls with positionally-identified parameters or with named parameters. In long parameter lists, explicitly naming your parameters both eliminates the risk of swapping parameter values and makes the call clearer to maintainers.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
With the default threshold of 3:
|
|
|
|
----
|
|
def coordinateSurpriseParty(self, hostName, guestOfHonor, caterer, invitees, peopleNotToInvite):
|
|
# ...
|
|
|
|
host="John"
|
|
guestOfHonor="Fred"
|
|
caterer="Barry"
|
|
invitees="Thea, Will, Mark, Mary"
|
|
peopleToExclude="Susan, Alberta, Frank, Larry"
|
|
|
|
coordinateSurpriseParty(caterer, host, guestOfHonor, peopleToExclude, invitees) # Noncompliant; this party will be a train wreck!
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
def coordinateSurpriseParty(self, hostName, guestOfHonor, caterer, invitees, peopleNotToInvite):
|
|
# ...
|
|
|
|
host="John"
|
|
guestOfHonor="Fred"
|
|
caterer="Barry"
|
|
invitees="Thea, Will, Mark, Mary"
|
|
peopleToExclude="Susan, Alberta, Frank, Larry"
|
|
|
|
coordinateSurpriseParty(caterer=caterer, hostName=host, geustOfHonor=guestOfHonor, peopleNotToInvite=peopleToExclude, invitees=invitees)
|
|
----
|
|
|