4 ms·
> When you reorganize files, now references need to be updated in many places. This is exactly why directory based namespaces are a good idea. Otherwise: 1.
by jeswin 1y ago
> When you reorganize files, now references need to be updated in many places.
This is exactly why directory based namespaces are a good idea.
Otherwise:
1. You refactor. But namespaces which were formerly in sync with dir structure, but now aren't because you decided to move directories around to manage code better.
2. You don't refactor because it's a lot of work.
> I hate it in TS/JS
It's not only JS/TS. Python, Go, Rust ....
C#'s approach here is redundant, and due to copying whatever Java was doing.
- metaltyphoon 1y ago> It's not only JS/TS. Python, Go, Rust Rust allows you to move modules around without you changing using.
- jeswin 1y agoWhen you write 'mod foo;' in a Rust file (say, main.rs), Rust will look for the source code for the module named foo in one of two places: a file named foo.rs in the same directory as the file declaring the module, or a folder named foo/ with a file named mod.rs inside it. That's great. Something like this is what C# can also aim for, while retaining full backward compatibility.
- metaltyphoon 1y agoThis would break every codebase in C# where a file lives in a folder where it is NOT in sync with the file system.
- jeswin 1y agoThis can be opt in, and not break any existing code.
- viraptor 1y ago> 2. You don't refactor because it's a lot of work. Why? It's free is you use an IDE and otherwise mostly doable with search and replace + a few manual fixes where the compilation fails.
- CharlieDigital 1y agoOr be like me and not care about the Duke structure at all. I don't sync my namespaces to file paths and instead only use namespaces to logically group imports. That let's me organize the visual structure of the tree independently of the logical structure. Every IDE now has great navigation utilities that doesn't require click based navigation so I don't see the infatuation some folks have with syncing these. In JS, end up creating stupid barrel files all over the place.