207
submitted 2 months ago* (last edited 2 months ago) by Sunny@slrpnk.net to c/linux@lemmy.ml

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?

top 50 comments
sorted by: hot top controversial new old
[-] gigachad@sh.itjust.works 76 points 2 months ago* (last edited 2 months ago)

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

[-] odin@lemmy.world 12 points 2 months ago

This is exactly what I do. It lends itself to something like 'prefix_specific-info_version' which is both sortable and easy to read.

[-] N0x0n@lemmy.ml 7 points 2 months ago* (last edited 2 months ago)

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... :/

load more comments (2 replies)
[-] that_leaflet@lemmy.world 51 points 2 months ago

Snake case.

  • Starts with a lowercase, good for shell autocompletion
  • No spaces, so no worrying about spaces in shell commands
  • '_' is better than '-' because it shows the spaces between words more clearly
[-] cygnus@lemmy.ca 35 points 2 months ago

Counterpoint: you have to use Shift a lot

[-] corsicanguppy@lemmy.ca 25 points 2 months ago

He probably uses vi. A few hundred more shift-key presses won't stand out.

load more comments (1 replies)
load more comments (2 replies)
[-] delirious_owl@discuss.online 43 points 2 months ago

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

[-] Allero@lemmy.today 18 points 2 months ago

Using Windows is a true flex on Lemmy

[-] gamma@programming.dev 8 points 2 months ago

I put newlines in my filenames to break both CLI tools and Windows filesystems

[-] Hupf@feddit.org 39 points 2 months ago
load more comments (4 replies)
[-] thevoidzero@lemmy.world 28 points 2 months ago

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):

https://github.com/Atreyagaurav/nameit

[-] luca@lemmy.today 13 points 2 months ago

You can go-to_hell.

[-] sntx@lemm.ee 9 points 2 months ago

Thats what I do as well. It makes it easy to seperate between logical units.

[-] Meltrax@lemmy.world 23 points 2 months ago

SCREAMING_SNAKE_CASE just has the best name

[-] Tomkoid@lemmy.ml 11 points 2 months ago

YES, I USE THIS TOO TO STAY CONSISTENT WITH SQL QUERIES

[-] Telorand@reddthat.com 22 points 2 months ago

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.

[-] Treczoks@lemmy.world 8 points 2 months ago

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...

[-] unknowing8343@discuss.tchncs.de 18 points 2 months ago

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.

load more comments (3 replies)
[-] bhamlin@lemmy.world 13 points 2 months ago

For files, kebab case. For variables, snake case. For servers, megaman villains.

[-] No1@aussie.zone 13 points 2 months ago* (last edited 2 months ago)

IT'S

COOLFILE.NAM

THERE IS ONLY 8.3 AND THERE IS ONLY UPPERCASE

load more comments (1 replies)
[-] otp@sh.itjust.works 13 points 2 months ago

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

[-] CodexArcanum@lemmy.world 22 points 2 months ago

Interesting, I'd tend to demote the initialism, ie topSecretFbiFiles.tar.gz

load more comments (1 replies)
[-] gerdesj@lemmy.ml 12 points 2 months ago

I like to use my enterprise number and a UUID (all in lower case, for legibility). Here's an example:

.1.3.6.1.4.1.33230.0d456e46-67e6-11ef-9c92-7b175b3ab1f1

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!

[-] quantenzitrone 11 points 2 months ago

How about "cool file name"?

All my systems use modern file systems that are case sensitive and can contain any character except / and \0.

[-] Monstera@lemmy.ml 11 points 2 months ago

Using commands on that is still more annoying, so no way

load more comments (10 replies)
[-] boredsquirrel@slrpnk.net 7 points 2 months ago* (last edited 2 months ago)

True. Linux, Android, Windows all have no problems

Using dots in a file though...

[-] Fizz@lemmy.nz 10 points 2 months ago

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.

[-] imecth@fedia.io 6 points 2 months ago

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.

load more comments (4 replies)
[-] nyan@sh.itjust.works 10 points 2 months ago

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).

[-] tatterdemalion@programming.dev 10 points 2 months ago

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.

load more comments (1 replies)
[-] communism@lemmy.ml 10 points 2 months ago

Snake case. I find it the easiest to read.

[-] tetris11@lemmy.ml 8 points 2 months ago* (last edited 2 months ago)

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

[-] Casuallynoted@pawb.social 10 points 2 months ago

I’ve never been to a naming convention but I have been to some comic conventions!

load more comments (1 replies)
[-] don@lemm.ee 10 points 2 months ago

WIAT, Y R U CALLIN IT SCREAMING CASE THAT SOUNDS FKN DUM TBH

L8R DOODZ

-SP4SEM4N B1FF

load more comments (3 replies)

Kebab or snake for ease of parsing through them.

[-] TBi@lemmy.world 9 points 2 months ago

Random mix and match. I’m all for diversity!

[-] eruchitanda@lemmy.world 8 points 2 months ago

Unless I can't, Kebab.

No need to hold Shift.

[-] MonkderVierte@lemmy.ml 8 points 2 months ago* (last edited 2 months ago)

Depending on environment/language and policies. As long as its consistent throughout the project.

load more comments (1 replies)
[-] orangeboats@lemmy.world 8 points 2 months ago

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"

[-] BrianTheeBiscuiteer@lemmy.world 8 points 2 months ago

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).

[-] Landless2029@lemmy.world 7 points 2 months ago* (last edited 2 months ago)

Rfc3339 plus kebab case for many things

2024-09-01_lname-fname-resume.pdf

load more comments (2 replies)
[-] Professorozone@lemmy.world 7 points 2 months ago

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.

[-] captain_aggravated@sh.itjust.works 7 points 2 months ago

I've got a personal convention that file names get snake case, directory names get Pascal case.

[-] lnxtx@feddit.nl 6 points 2 months ago

Depends. Java-like languages ofc camel/pascal case.
Bash, Python, etc., snake case, with constants as uppercase.
Filenames: I prefer snake case.

[-] wuphysics87@lemmy.ml 6 points 2 months ago

IWRITELOTSOFBASH

[-] Cris16228@lemmy.today 6 points 2 months ago* (last edited 2 months ago)

Both snake and camel case. Sometimes I mix it in the same project and I hate myself for it

[-] BCsven@lemmy.ca 6 points 2 months ago

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.

load more comments
view more: next ›
this post was submitted on 31 Aug 2024
207 points (97.3% liked)

Linux

48179 readers
1128 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS