8th Light: Day 94

12 May 2016 . 8thlight . Comments #apprenticeship #8thlight #software #code-smells

Code smells: Long method

A method contains too many lines of code. Generally, any method longer than ten lines should make you start asking questions. - sourcemaking.com

Long methods are difficult to follow, difficult to reuse, and difficult to change. Additionally, longer methods can be breeding grounds for duplicate code and difficult-to-spot bugs.

Generally, it is good practice to keep methods under 10 lines, and ideally around 5 (see Sandi Metz’s rule no. 2).