Naming conventions for setting up projects

I'm a huge fan of BEM and my OCD is kicking in so I've been thinking a lot about file structures and naming for projects. I know that with some node packages and sass there can be certain folders and files that need specific names. So I'm wondering anyone could recommend some documentation or research on best practices for naming project files? Thanks
4 Replies
WebMechanic
WebMechanic•17mo ago
Naming things is the hardest part in programming. If you're working with a team: adjust to the team. If you're working alone: use what's meaningful for you. Best possible answer here: it depends. It's often a good idea to name files by what the do or what they represent and what data format they're in, which is why we see "favicon.ico", "index.html", "main.js", "base.css", "Button.vue", "Panel.tsx" etc... However, "main.js" and "base.css" already are opinionated choices, and "app.js" and "core.css" could be equally valid names. Don't be cryptic or too fancy if you then have to constantly search for files in each project. Like don't use "does-cool-stuff.js" when "animations.js" would be more descriptive. That being said: some languages and tools require a certain naming convention to function out of the box or be smart(er) about the behaviour and to enhance your DX, like - certain folder structures - specific file names (index.html) + extensions (.vue) - no special characters or Unicode symbols - casing based on scope (fubar, FuBar, fuBar, fu_bar, fu-bar, FUBAR ...) You'll develop a workable and accessible system over time that suits your workflow and thinking... and level of OCD 😉 But again: If you're working with a team, adjust to the team. Have fun. oh, forgot... Some software paradigms (and frameworks) also "dictate" how you name things. In Model View Controller (MVC) setups it's common to have separate directories and files for each w/ or w/o varying degrees of redundancy in the names: - ./Models/FubarModel.php - ./Views/FubarView.php - ./Controllers/FubarController.php or - ./Fubar/Model.php - ./Fubar/View.php - ./Fubar/Controller.php or ... ....it depends 😀
Zenon
Zenon•17mo ago
Are there any industry standard conventions or similar that we can use as a reference for at least some files?
Jochem
Jochem•17mo ago
some languages have suggested conventions, like PHP's PSR https://www.php-fig.org/psr/ or things like PEP-8 from Python https://peps.python.org/pep-0008/ Javascript effectively has a couple, one of the most popular being AirBNB's set of rule https://airbnb.io/javascript/ which have also been translated to ESLint and Prettier configs Other than that, I'd suggest just googling for "<language> coding standard", see what you find, and pick one you like. @__zenon ^
Zenon
Zenon•17mo ago
Thanks a lot Jochem.
Want results from more Discord servers?
Add your server