207
submitted 1 year ago* (last edited 1 year 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 74 points 1 year ago* (last edited 1 year 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 1 year 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.

load more comments (2 replies)
[-] that_leaflet@lemmy.world 49 points 1 year 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 34 points 1 year ago

Counterpoint: you have to use Shift a lot

load more comments (2 replies)
[-] delirious_owl@discuss.online 40 points 1 year 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

[-] gamma@programming.dev 8 points 1 year ago

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

[-] QuazarOmega@lemy.lol 6 points 1 year ago
[-] delirious_owl@discuss.online 5 points 1 year ago
[-] noisypine@infosec.pub 13 points 1 year ago

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.

load more comments (1 replies)
[-] Hupf@feddit.org 39 points 1 year ago
[-] TimeSquirrel@kbin.melroy.org 7 points 1 year ago

10 PRINT "FARTS" 20 GOTO 10

load more comments (2 replies)
load more comments (1 replies)
[-] thevoidzero@lemmy.world 27 points 1 year 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

[-] sntx@lemm.ee 7 points 1 year ago

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

[-] Telorand@reddthat.com 22 points 1 year 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 1 year 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...

[-] Meltrax@lemmy.world 21 points 1 year ago

SCREAMING_SNAKE_CASE just has the best name

[-] Tomkoid@lemmy.ml 9 points 1 year ago

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

[-] unknowing8343@discuss.tchncs.de 19 points 1 year 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)
[-] quantenzitrone@lemmings.world 15 points 1 year 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.

[-] boredsquirrel@slrpnk.net 8 points 1 year ago* (last edited 1 year ago)

True. Linux, Android, Windows all have no problems

Using dots in a file though...

[-] otp@sh.itjust.works 14 points 1 year 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 23 points 1 year ago

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

load more comments (1 replies)
[-] bhamlin@lemmy.world 13 points 1 year ago

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

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

IT'S

COOLFILE.NAM

THERE IS ONLY 8.3 AND THERE IS ONLY UPPERCASE

load more comments (1 replies)
[-] gerdesj@lemmy.ml 12 points 1 year 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!

[-] nyan@sh.itjust.works 10 points 1 year 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 1 year 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 1 year ago

Snake case. I find it the easiest to read.

[-] tetris11@lemmy.ml 8 points 1 year ago* (last edited 1 year 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 9 points 1 year ago

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

[-] pastermil@sh.itjust.works 6 points 1 year ago

You should, that's how you can make a name for yourself!

[-] TBi@lemmy.world 9 points 1 year ago

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

Kebab or snake for ease of parsing through them.

[-] BrianTheeBiscuiteer@lemmy.world 8 points 1 year 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).

[-] Professorozone@lemmy.world 8 points 1 year 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.

[-] orangeboats@lemmy.world 8 points 1 year 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"

[-] eruchitanda@lemmy.world 8 points 1 year ago

Unless I can't, Kebab.

No need to hold Shift.

[-] don@lemm.ee 8 points 1 year ago

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

L8R DOODZ

-SP4SEM4N B1FF

load more comments (3 replies)
[-] MonkderVierte@lemmy.ml 7 points 1 year ago* (last edited 1 year ago)

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

load more comments (1 replies)
[-] Landless2029@lemmy.world 7 points 1 year ago* (last edited 1 year ago)

Rfc3339 plus kebab case for many things

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

load more comments (2 replies)

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

[-] BCsven@lemmy.ca 6 points 1 year 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.

[-] lnxtx@feddit.nl 6 points 1 year ago

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

[-] ian@feddit.uk 6 points 1 year ago

This question just shows how messed up, and broken much of IT is.

[-] 7usr7local@lemmy.ml 6 points 1 year ago

It heavily depends on the context: Filenames? Variables? Functions? Interfaces/Classes? Java? C? Shell?

[-] navi@lemmy.tespia.org 5 points 1 year ago

I don't like it but I am used to reading old C codebase (windows: https://learn.microsoft.com/en-us/windows/win32/stg/coding-style-conventions) with Hungarian notation.

pszMyString 😥

load more comments (2 replies)
[-] ZombiFrancis@sh.itjust.works 5 points 1 year ago

Pascal_Snek_Case

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

Linux

60103 readers
631 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 6 years ago
MODERATORS