Code Smell of the year

Long method


Long methods mean large pieces that are reused. It is an indicator that the Single-responsibility principle is being violated.

A method should generally work on a Single Level of Abstraction. It would be a mess to invoke a low level (e.g.: the operating file system) and a high level function (a collection in your main memory) in the same piece of code. Inspect the code inside the method. What is it really doing?

Your indicator could be a method name with AND in there, like e.g.: `getDataFromFilesystemAndValidateIt().


Break the code into smaller pieces. Extract everything out of it to use it afterwards.


Hint: Keep in mind that there is no technical modification of the code during the refactoring step.


This is step three of the first part of the Refactoring kickstart beginner series. Here is step 4.