4 ms·
How do you know which 'Date' your are using. How do you know it's the one from 'date'? That's like using * imports in Python which is a huge pain once you done
by AnonymousPlanet 4y ago
How do you know which 'Date' your are using. How do you know it's the one from 'date'?
That's like using * imports in Python which is a huge pain once you done even minor refactoring.
- gedy 4y agoYeah in the Rails shops I've worked with, this "developer productivity" turns into a nightmare with large codebases.
- shaicoleman 4y ago> How do you know which 'Date' your are using. How do you know it's the one from 'date'? Ruby allows you to check where a method is defined, e.g.: puts Date.singleton_method(:today).source_location Although in this case it returns nil because it's implemented in C. But it would return the location if you overrode it. There are various tools to see what the code is doing: invoking a debugger and stepping into the code, tracing the code execution via TracePoint, etc. The Zeitwerk autoloader which comes with Rails enforces that the class name matches the filename. Naming conventions, specs, a quick grep and avoiding generic names make it almost a non-issue in my experience - only happens every few years or so, and usually quite easy to fix. Ruby gives you a lot of power, but it doesn't stop you from shooting yourself in the foot. https://m.signalvnoise.com/provide-sharp-knives/ https://m.signalvnoise.com/provide-sharp-knives/