-->
BEM is not just useful for CSS, but also to manage use cases for your commands.
Have you considered BEM naming for scripts? Consider a git feature branch.
git checkout -b feature/something
# ... some commits
git checkout develop
git merge --no-edit --no-ff feature/something
git branch -d feature/something
git push
This is clearly scripting material. A git alias was not ideal because of the multiple steps and since I am always reviewing branching strategies I rather have space for comments and annotate ideas. How should I name this script?
git-feature-end
Sounds OK, but if you tab complete git-
you will notice that git actually has some commands with that pattern like git-receive-pack
or git-shell
.
A double --
makes clear which is the command and which is the job to do.
git--end-feature
Later I started to use another branching style where I just squash the whole branch into a single commit. Is that a variant? Let’s rename things.
git--feature-start
git--feature-end__ff
git--feature-end__squash
Notice I renamed end-feature
to feature-end
after creating a script to start features too. Names going from generic to specific help exploring which scripts I have with tab complete. First I try git--
and then I can keep narrowing down with git--feature
. Basically the pattern is:
# The original for CSS
[Block]--[Element]__[Modifier]
# For scripts
[Command]--[Job To Be Done]__[Variant]
It is a mouthful to type but that is what alias are for. The verbose naming is still useful when building a personal collection of self describing command use cases.
Since the one I use the most often is git--feature-end__ff
I set everything to just type g end
. Once you start creating BEM commands you will notice so many variants that it is easier to remember just the aliases of the most frequent ones and rely on the BEM naming to find the rare but still valuable ones.