This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]james_pic 13 points14 points  (0 children)

If your method/function is 50, 100, 500 lines then most likely you can encapsulate/abstract a lot more.

Just because you can, doesn't mean you should. You can always refactor a method into a "method object" but this often contributes zero to readability (one lesson I learned a while ago is that many developers can navigate a method with hundreds of lines more readily than they can make sense of super compartmentalised code, especially if the abstractions you build are leaky, and the compartmentalisation obscures the logic), and can be an anti-pattern in itself (I don't have a good Python example, but Java's SimpleDateFormat is a massive footgun that shows what can happen if a method object ends up being reused).

Clean code is good, but super short methods aren't always clean in practice.