DEV Community

Discussion on: What programming best practice do you disagree with?

Collapse
 
ben profile image
Ben Halpern

I question anything too religious around small files and tiny methods. Sometimes the better choice is to toss another method in the class so it’s easy to find rather than stash it away elsewhere in the codebase.

Collapse
 
nickhristov profile image
Nick Hristov

Use an ide, preferrably a jetbrains one.

Collapse
 
omrisama profile image
Omri Gabay

git grep

Collapse
 
georgecoldham profile image
George

My counter to this is that with any suitably large product, having a logical folder structure that you religiously stick to, regardless of file size/content† , you can reliably find the content that you are looking for. Okay you occasionally deal with a silly file, but its better than having someone recreate something and have inconsistency between what should be functionally identical.

For small/informal project then I understand the convenience, but otherwise i feel it can add to problems long-term, especially when working with big/multiple teams.

have a single exported const in a file for all I care

Collapse
 
woodencode00 profile image
WoodenCode00

I think modern IDEs are pretty smart to walk you to the file/class which encaosulates the method.
For me the method length limit is imposed by the response to simple question - "What the method accomplishes?". If you are not able to answer without using AND ..this.. AND ..that. AND ... multiple times, then it is time to better encapsulate the logic and maybe change the project's design.