Is it a bad practice to give two very different files with the same general purpose the same name, separating them into different directories?<script src=client_scripts/app/player_stats/generator.js></script><script src=client_scripts/app/coach_settings/generator.js></script>I'd like to keep my file names short, and both of the files have the same general purpose without being identical. I'm not sure whether or not this would be considered a bad practice in a professional programming environment. I'd like to know what the best practice is in this situation.Alternatively, at the expense of the name's short length, I could use:<script src=client_scripts/app/player_stats/player_stats_generator.js></script><script src=client_scripts/app/coach_settings/coach_settings_generator.js></script>
Is it a bad practice to give two very different files with the same general purpose the same name?
naming;file structure
Consider the cost/benefit ratio of your two options:Would reusing the same name cause confusion or naming conflicts? Probably not, since they're in different folders. The name player_stats/generator.js is equivalent to player_stats_generator.js. However, if you see, in the future, a reason to merge your js files into a single directory (deployment? I dunno), then this should be a good indicator to give unique names.Would using the longer names involve a lot of extraneous typing? Probably not. Not only do many JS IDEs autocomplete filenames in the project for you, it's also a piece of code that's probably only written - at most - once per file. The code that gets typed a lot is the classes and functions inside the js files, and those (hopefully) don't conflict.When debugging, what sort of information do you get about an error? If the most common bug report is Error in line 34 of <filename.js>, then consider giving them unique names, since receiving errors in just generator.js and then trying to divine, through context, which generator it was can be a hassle.