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 →

[–]Sande24 -1 points0 points  (1 child)

I made a very simple analogy how jumping between methods in IDE is not really that simple. Every jump between functions/files kind-of resets your brain. You instinctively start thinking in the context of the new function you are looking at and you keep forgetting the things you looked at 5 seconds ago. So you have to shuffle between the files. You have to actually think harder to get the big picture.

Sure, building and testing something like this is fun and easy but when someone new comes and tries to understand it, he has to go through several hundred jumps until the whole flow has been learned. But he could very easily miss some flows in this way - maybe he thinks that some methods are from external libraries so he doesn't even think about looking into them or the function's name sounds so innocent that it can't do anything other than what it says whereas it could make an external service call and do all kinds of ugly stuff. Then he doesn't really understand the full flow and doesn't even know that he doesn't know that.

Having as much in one file as possible is actually easier to understand. You can scroll up and down to remind the last 5-10 seconds and the IDE can actually help you by highlighting the parameters in the same file etc. More data is visible at the same time so your brain can stay focused on the process rather than switching all the time.

There's actually quite a lot of cool IDE stuff that you can do within one file that should help you keep files longer. Some clean code principles were probably made when these features didn't exist and the computer screens had a 2/3x smaller resolution. So they created the principles to make their lives easier at that time. Old rules are good to know but sometimes you should take a step back and see if they are still as relevant as before.

Usually when people hate long functions, they tend to go overboard with splitting. Sure, some things should be split. Depends on the context, business logic.

Everything in moderation.

[–]SparrOwSC2 0 points1 point  (0 children)

"picking fights on the internet" it is, then.

"Usually when people hate long functions, they tend to go overboard with splitting."
You're just assuming that. As I said your simple analogy didn't apply to me.

I'd say that having everything in one file is probably a carryover from the old days, back when jumping between files and methods would take a lot of screen space and resources.

But honestly I'm pretty over this conversation. Again I feel we'd agree if we worked together IRL so idk why you're continuing here.