5 ms·
If someone is new to the codebase, would you rather they need to open a dozen files to see all of the different virtual functions that could occur at one call s
by anonymoushn 4y ago
If someone is new to the codebase, would you rather they need to open a dozen files to see all of the different virtual functions that could occur at one call site, or open one file?
- xnickb 4y agoI see your point, but no one uses Windows notepad for coding anymore. There are far worse crimes than having code structure that spans several files.
- Tomis02 4y ago> There are far worse crimes than having code structure that spans several files. Sure, but what's the advantage of having your code split over several files? Yes, you can jump between them with an IDE, but that's still a disruption, and it makes it harder to see common patterns that can help you simplify the code. As demonstrated in the video, splitting up the switch into multiple classes only hurts readability.
- kaba0 4y agoYou are only seeing a screenful of code at any time, no matter if they are in one file or multiple ones. I much prefer each “section” of code if you will having a specific name/location I can associate it with, than scrolling as a mad-man. Yeah, I know about markers/closable functions/opening multiple sections of the same file/etc, but at that point whose workflow is more complex?
- TeMPOraL 4y ago> I see your point, but no one uses Windows notepad for coding anymore. Did I miss an IDE that inlines all those things for you automatically? Because ones that only give you a "jump to definition", or maybe a one-at-a-time preview in a context popup, are not much better than Notepad++. You still don't get to see all the relevant things at the same time.
- kaba0 4y agoMost real world applications won’t have `print “red”` or the like under a specific implementation. Good luck inlining 6 1000 lines-implementations into a single switch statement.
- TeMPOraL 4y agoThe "project" vs. "external" vs. "system" library conceptual distinction exists for a reason. But of course you want presentation-level inlining to be semi-automated, much like autocomplete and jump to definition.
- hennell 4y agoAs tradeoffs go, I don't see opening a dozen files as a big hurdle. I'd take smaller single purpose files over one big file anyday. Plus how often do you need to see all functions? If there's a problem in RectangleArea function, you go to that file, no need to look in CircleArea. If you're adding 'StarShapeArea' you only care that it matches the callers expectations, not worrying about the other function logic.
- KyeRussell 4y agoHonestly this itself is a massive oversimplification, and a bit of a strawman, and kinda indicates that you still aren’t seeing the nuance. Yes, if something is understandable in a single file, that’s fine. But also appreciate that too many pieces in the same file can also be confusing and disorienting for people. You also have to consider all the cases in which someone would be opening that file. You’re basically posing a situation which by its very description is an exception. If anyone is slavishly following these rules, they’re undoubtedly doing it wrong. Knowing when to apply the patterns is the hard bit. And, in my experience working on codebases worthy of considering these things in the first place, there’s much more to consider than what you’re posing.