From the course: Agile Software Development: Clean Coding Practices

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Parameter lists

Parameter lists

From the course: Agile Software Development: Clean Coding Practices

Start my 1-month free trial

Parameter lists

- [Instructor] A method's definition includes the method's name and an optional list of parameters. When those parameters are specified, the values they store are available to the code inside the method. The best methods only take a few parameters. The fewer parameters a method takes, the easier it is to tell what each parameter is used for when the method is called. Here's a method that only takes one parameter. It's pretty clear both when reading the method definition and reading where the method is called what the parameter is used for. With a method that takes more than one parameter, take care to list the parameters in an order that makes sense. Here's a method that takes two parameters but it's not super clear which parameter's the book title, and which parameter's the author's name, unless you're familiar with the books, that is. A technique that can help is to make the final word in a method's name describe…

Contents