Whats your go-to naming convention?
from Sunny@slrpnk.net to linux@lemmy.ml on 31 Aug 2024 18:08
https://slrpnk.net/post/12898579
from Sunny@slrpnk.net to linux@lemmy.ml on 31 Aug 2024 18:08
https://slrpnk.net/post/12898579
As far as I know there are these;
- Camel case = coolFileName
- Snake case = cool_file_name
- Kebab case = cool-file-name
- Pascal case = CoolFileName
- Dot notation = cool.file.name
- Flat case = coolfilename
- Screaming case = COOLFILENAME
Personally I prefer the kebab/dot conventions simply because they allow for easy “navigation” with (ctrl+arrow keys) between each part. What are your preferences when it comes to this? Did I miss any schemes?
threaded - newest
Related: a list and explanation of variable naming conventions pluralsight.com/…/programming-naming-conventions-…
Both snake and camel case. Sometimes I mix it in the same project and I hate myself for it
It depends a bit on the use case. I try to follow naming conventions within specific environments like Python. When just sorting some documents together, I usually do a mix of Kebab and snake case, where I split semantic parts with underscores and connect words with dashes like
2024-08-30_author_document-name_other-important-info.ext
Yeahh that’s the best IMO ! But I get most of the time stuck with some
testOFtest001
files/directory… cause I’m lazy…But I always ALWAYS regret it afterward… :/
This is exactly what I do. It lends itself to something like ‘prefix_specific-info_version’ which is both sortable and easy to read.
Is something like this defined in a standard somewhere?
I can tell that this guy fucks
I like Camel Case for code, but mostly because it’s ingrained in my brain, coming from Java as my first language.
For folders and files, I like Kebab Case.
Luckily, I was not ingrained by my first programming language like that, or my coworkers would strangle me.
I started with BASIC, which allowed only two letters for variable names…
I use flat case most of the time, but I also try to stick to single word files so there is no case to get in the way.
I think for documents I might share like a PDF I’d use Pascal case.
In a classroom or teaching setting I will sometimes use Kebab case as I find it is the least confusing and makes it extra clear where the word division is. Similarly I avoid Dot notation since it’s confusing for folks coming from a Windows world.
And I would avoid Screaming because that’s just too loud anywhere.
Isnt CAPSLOCK case for screaming? 😁
YEAH CRUISE CONTROL BABY
Depends. Java-like languages ofc camel/pascal case.
Bash, Python, etc., snake case, with constants as uppercase.
Filenames: I prefer snake case.
For files? I like title case (like in article headlines). For example, I have a “Shell Tricks.txt”. I’m not really consistent though, sometimes it’s all lowercase or whatever really.
spaces in filenames?
oh, my sweet summer child.
I don’t use a computer from the 90s. It can handle it.
I don’t like it but I am used to reading old C codebase (windows: learn.microsoft.com/…/coding-style-conventions) with Hungarian notation.
pszMyString 😥
That’s called camelCase, right? starting off small and then use Upper. Hungarian notation is a form of camelCase, just with the type added in front I think. But that’s for coding standards, not filenames. One can think of Hungarian notation as to what file extensions is to files, just added in front. Imagine files named as “txt.MyFile”, just for illustration.
Ah yes I dont know what I thought OP was asking about coding standards 😂
I try to make everything Pascal case. It’s easy to read in a terminal and pretty easy to type.
FileName_IMPORTANTCATEGORIZATION.yyyy.ext
With all bits being optional (not every file needs the date it refers to)
So eg (slight modifications for anonymity):
SunLifeInsureance_SIGNED.2024.Q1.pdf
SpotDoesTrickAndFalls_ORIG.mp4
JSmithPassport_CANADA.2015_2025.pdf (I am a dual citizen)
JSmithCOVIDPass_DOSE1.2021.pdf
WIAT, Y R U CALLIN IT SCREAMING CASE THAT SOUNDS FKN DUM TBH
L8R DOODZ
-SP4SEM4N B1FF
ive seen it be called both screaming and train case, not sure what the most used term is though.
.
It’s a reference to Tha Grate Biffinski:
en.m.wikipedia.org/wiki/BIFF_(Usenet)#
I like snake, but in some interfaces the underscores blend into the text line or are not rendered properly, so it becomes eaaier to discern if the filename has spaces or separators by using kebab.
For files? An unholy amalgam of snake, kebab and dot, depending on what exactly I’m trying to convey. (I still have much-ported files around with DOS 8.3 filenames, so they’re truncated scream case (SCREAMIN.NAM), but I don’t actively name files like that anymore.) The important thing is to separate the words/sections while using characters that are valid without escapes in both ext4 and vfat if at all possible.
For variable names, camel or Pascal case (depending on language convention) if I think anyone else is going to read it. Flat case for code I don’t think anyone else is ever going to see (don’t do this—it has left teethmarks in my ass from time to time and will do the same to you).
I don’t have a consistent style for everything and it depends on the circumstances. snake_case is often used, especially to avoid spaces. Sometimes I just do flatcase instead, and in rare cases also kebab-case or combined_snake-and-kebab-case. The combined_case is often useful to group parts of the name, like a dates and version numbers together and to indicate what part is constant; example-name_2024-08. Sometimes I also do the “Title Case”, which is basically PascalCase, but with spaces. Or even even more weird, “Python_Case”, which is PascalCase, but with snake_case, when I want to avoid spaces.
I often avoid dots in regular filenames, unless they indicate a file extension or format, such as “.svg” and “.inkscape.svg” to indicate its a specific version of the SVG format. Or “.xiso.iso”, as a specific compressed version of the regular ISO file (for use with Xemu emulator). Basically the same logic and tradition as “.tar.gz” (but in reverse order).
I don't like extra dots simply because pattern matching might get weird down the road. Keep dots for extension type and use Pascal to make it easier to read multiple words. Flatcase only if it's short or I'm lazy for a temp file.
Pascal_Snek_Case
Snake case for all kinds of file names and camel case for programming
For files, date+Snake: 20240831Letter_to_Rodney.odt For variables, Screaming
Camel case, but with a twist – if the next word is about to start after a capital letter, I’ll have it lower case.
topSecretFBIfile.txt for example
Interesting, I’d tend to demote the initialism, ie topSecretFbiFiles.tar.gz
That’s probably more commonly accepted. I defer to whatever my team is doing, but for my own files, I wouldn’t want things like UsStudentList or USStudentList which both look wrong to me.
USstudentList looks right to me, and if that’s wrong, I’m okay with being wrong! Haha
COOLFI~1.AME
10 PRINT "FARTS"
20 GOTO 10
Man I miss basic.
https://www.freebasic.net/
It's more like QBasic dialect, but it's still actively maintained. It can generate binaries and everything for modern machines.
Im dead! MS-DOS vibes
How about “cool file name”?
All my systems use modern file systems that are case sensitive and can contain any character except
/
and\0
.True. Linux, Android, Windows all have no problems
Using dots in a file though…
Using commands on that is still more annoying, so no way
not really
You can easily escape spaces with
\
and my modern shell (fish) suggests and completes filenames for me anyway, so i don’t have to type more than the first word in more than 90% of cases.Typing
\
in those cases instead of_
is super annoying.In my keyboard layout backspace is behind altgr.
the standard keyboard layouts (qwerty, qwertz, etc.) are mostly trash
are there any good alternative keyboard layouts for your native language (finnish if im not mistaken)?
In Germany there is the Neo Family: Neo{,2}, NeoQwert{y,z}, Bone, Mine, … as well as offsprings of that, but I guess you need your diacritics: å ä and ö. While Neo layouts have these diacritics available, they are made for german, so only ä ö and ü are easily accessible.
Finnish indeed. I’m not aware of any alternative layouts. å is completely unnecessary for finnish, so maybe the layouts you mentioned could work.
Now do it with a for loop on every file in a dir with thousands of files
where is the problem? fish shell doesn’t split arguments at spaces
$IFS splits files at spaces
IFS is a special shell variable in bash, ksh and POSIX shells that lets you configure how the shell splits words
by default it splits at spaces tabs and newlines
I use
fish
a shell that is intentionally not POSIX compatible. While it borrows some principles from Bash and POSIX, it simplifies a lot of things and removes most footguns. Words are split at new lines in fish, which admittedly can also cause troubles, but not nearly as often as in bash and other POSIXy shells.Wtf why would you intentionally not be POSIX compatible?
to make a good interactive shell
camelCase for non-source-code files. I find camelCase faster to “parse” for some reason (probably just because I’ve spent thousands of hours reading and writing camelCase code). For programming, I usually just use whatever each language’s standard library uses, for consistency. I prefer camelCase though.
I am a fan of Python’s or Rust’s official conventions.
For package names, tho, I don’t get why this-is-used over this_clearly_better_system, as I would expect a double click to select_the_whole_thing, whereas it does-not-happen-here.
While i do agree, snake looks a lot better too. I just wish it was possible to navigate through each parts of the word more easily with ctrl+arrow. That would make it the superiour choice imo.
Does alt+arrow work in your terminal?
yeah
Kebab for most things, camel for source code
I go with the “quotation case”, “Cool file name”.
Snake case.
Counterpoint: you have to use Shift a lot
He probably uses vi. A few hundred more shift-key presses won’t stand out.
kdd
For this reason, I use kebab case for directories. But because I agree underscores show spaces better, I use snake case for files.
Depends on your keyboard layout
For files, kebab case. For variables, snake case. For servers, megaman villains.
CaN’t BeLiVe No OnE eLsE uSeS mOrOn ScRiPt FoR eVeRyThInG!
I ScRoLlEd ThIs FaR fOr SpOnGeBoB cAsE
IWRITELOTSOFBASH
Snake Case and Pascal Case is what I tend to default to
Kebab. Not my favorite visually speaking but I had RSI issues for a while and I’m still very focused on limiting keystrokes (no shift key needed with kebab).
I like to use my enterprise number and a UUID (all in lower case, for legibility). Here’s an example:
Now you might say that the UUID is already globally unique or at least pretty unlikely to turn up anywhere else, so why bother prefixing it with more stuff? To that I say: “I need to be absolutely or at least reasonably sure … OK nearly sure”.
Anyway, you maintain a database of these things and then attach documentation and meaning to them. An editor could abstract and hide that away.
I started this post as a joke. Not sure anymore. Why get your knickers in a twist with naming conventions for variables and constants. Programming is already a whopping layer of abstraction from what the logic gates are up to, another one wont hurt!
Snake case, but I’m the World’s second worst programmer and just name files like this because I was alive when spaces were not allowed.
PascalCaseForTheWin
IT’S
COOLFILE.NAM
THERE IS ONLY 8.3 AND THERE IS ONLY UPPERCASE
FILEID.DIZ
Depending on the file it’s either dot notation or flat case.
I’ve got a personal convention that file names get snake case, directory names get Pascal case.
I do kebab with underscores.
Wouldn’t that be snake?
Snake if writing in python
Camel if writing in PowerShell
I tend to stick with what the language wants me to use.
Unless I can’t, Kebab.
No need to hold Shift.
Snake case, usually. Some perhaps unfounded fear that something will blow up on a dash in a file name kicking around. Or I’ll do a weird typo/premature enter and part of the file name will be treated like a -flag of some sort.
Rfc3339 plus kebab case for many things
2024-09-01_lname-fname-resume.pdf
RFC3389 ?
Systemwide RFC-3339 Dateformat
I meant RFC3339
My file
25% Camel case, 25% Pascal and 50% of the time flatcase. It drives me insane when I try and autocomplete a folder only to realise it was Downloads instead of downloads. I keep telling myself i will go through and make it all flatcase but I put it off because i tell myself i will rebuild my computer next week every week.
Never thought about making the home folders flatcase, thanks, takes all of 2 minutes btw.
If anybody else wants to do it, remember to edit
~/.config/user-dirs.dirs
with your new flatcase folders.I do the flatcase in my machines too, but it stopped being such big a nuisance to me when I moved to ZSH - it can autocomplete case-insensitively.
Is zsh a terminal or a language like bash? I don’t get what it is from reading descriptions
.
Thanks I’m gonna give it a go
Kebab case with Pascal case in the usual places. I’d change to all kebab case but the muscle memory of typing Documents would nearly kill me.
I use camel case for methods and functions and snake case for variables. And pascal case for constants. Why? I don’t really know, it makes for a nice distinction I guess.
I’ve got one more to add to your list, and I hate it, but it’s worth mentioning: en.m.wikipedia.org/wiki/Hungarian_notation
It’s when the data type is in the name of the variable.
Oh, that was always the standard for Game Maker to differentiate between sprites and objects, which typically had similar names. It’s a difficult thing to unlearn!
Snake case. I find it the easiest to read.
I’m starting to warm up to Pokemon case, which would simplify functions like
GottaCatchThemAll()
to🍚()
or
this
to⚡🐹IchooseU
which I think we can all agree is much easier to read
The only correct answer is to be consistent with the code base you’re working in or the language’s conventions. If neither of these conventions exist, then someone has already failed you.
Given OP mentions kebab-case, this is probably about file-systems. But you are absolutely correct about code.
It really depends.
If I know I will never open the file in the terminal or batch process it in someways, I will name it using Common Case: “Cool Filename.odt”.
Anything besides that, snake case. Preferably prefixed with current date: “20240901_cool_filename”
Underscore to delineate different parts, hypen to delineate words.
Like: my-resume_draft.pdf
And to make it consistent and easier to reuse parts for project names and such, I have a command line utility written for it. It caches the parts and uses a template system (support for generating current datetime in parts)
Available here (is in AUR too):
github.com/Atreyagaurav/nameit
Thats what I do as well. It makes it easy to seperate between logical units.
You can go-to_hell.
Depending on environment/language and policies. As long as its consistent throughout the project.
My old projects still have camelCase sprinkled around, you can tell which bits are new and old depending on whether it’s camel or kebab
Snake case or kebab case I guess. But why is it called kebab case?
Because it looks like the words are on a rod, like kebab meat
Huh thanks, I guess it’s based on a misunderstanding of the word kebab then. Correctly it would have to be called şiş/shish case then, but that certainly has less of a ring to it.
Skewer case, perhaps?
I like it
Gotta live the Ocaml_case
I took a CS class that was java based, and now my go-to is Pascal for file names. Sometimes I do flat or screaming just 'cause.
I put an unnecessary amount of spaces in all my file names to break anyone who wants to use CLI tools on them
i use windows btw
Using Windows is a true flex on Lemmy
What does this do?
Make a file named just a bunch of spaces with double quotes around them. It’s made confusing because of the 4 double quotes, two are escaped by the backslashes immediately before them.
Mental damage
I put newlines in my filenames to break both CLI tools and Windows filesystems
General purpose: Kebab case
But really, follow the conventions of what you’re working on. For example, I’d use pascal case when working on a Java/Kotlin project, and snake case when working on a Python project.
camel for java. flat for c
SCREAMING_SNAKE_CASE just has the best name
YES, I USE THIS TOO TO STAY CONSISTENT WITH SQL QUERIES
Pascal and Kebab case
Snake case and kebab case mixed arbitrarily.
Pascal for server code running C# and Camel for client running TypeScript.
I kebab case mine for personal files.
It’s mostly because I don’t have to use a modifier key and it’s doesn’t need url encoding and all in the same lowercase. Dot notation looks nice but I feel like dots are for extensions only. Flat case is horrible to read, screaming case even worse, camel/pascal case to many times ends up as coolFileNAme on first time typing.
I’ve done a couple of different styles because of programming in different languages but now if I have to do anything that’s not kebab case I make a small frown.
Kebab or snake for ease of parsing through them.
I’ve never been to a naming convention but I have been to some comic conventions!
You should, that’s how you can make a name for yourself!
If it’s something that will be mostly interacted with over CLI then kebab case. If GUI then spaces
If its my own personal code, snake case, if I am sharing with my frontend devs then camel case. If I am writing short scripts, then flat.
stOcHaStIC-l33t-CasE FTW yizzo.
Are you including the spaces in your filenames?
oFCoURsE! And the dot at the end with no file type extension? Also intentional.
generally i still to camelcase if i have no separators, if i do have separators i stick to - now. _ sucks. I use . notation when dealing with copies of files.bak or something like that.
If i feel really special i throw a space in the name just because
code: camel or snake, depending on language
files/dirs: snake + kebab + dot mixture (trying to avoid caps and special chars here)
This question just shows how messed up, and broken much of IT is.
Whatever case I get when my finger reaches the shift key.
The guy on shift before you got the Case of the Missing Variable. What will you get when your finger reaches that shift? Who knows… It will remain… A_Mystery!
Since Linux is caps sensitive, at least I always use lowercase.
I guess I use kebab case for any file used for IT projects
That’s why camelcase starts with a lower letter. If you’re using a good terminal+shell setup then it’ll be irrelevant most of the time.
I generally end up using snake case.
It heavily depends on the context: Filenames? Variables? Functions? Interfaces/Classes? Java? C? Shell?
I usually like to call my functions cool-Filename and my variables moronic_typeClass. Shell executable aliases look like ‘if\ then\ else’ and C constants are ‘IFTHANELSE’
.
Random mix and match. I’m all for diversity!
Me, a sick fuck, who likes a quick fuck:
Camel case for short names snake case if it starts getting hard to read
Have been defaulting to kebab case for variable and function names in all languages recently because of cargo yelling at me
Pascal case for class names cause c#, snake case for python files because it doesn’t like kebab
Screaming case for env files because that’s what everybody else does
my go_to NamingCovention: ANYTHING but camel-case 🤮
I use PascalCase for classes, camelCase for functions and variables, SCREAMINGCASE combined with snake_case for constants and for filenames/folders mostly snake_case with kebab-case if date or timestamp is involved.
1337 case = k3wlf1l3n4m3
Pascal or Camel are best cases
depends on the color of my mood ring
Pascal or camel case for code, snake case for files and screaming snake case for globals
Cool_file_name
cool-file-name