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?

  • @gigachad@sh.itjust.works
    link
    fedilink
    51
    edit-2
    9 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
      link
      fedilink
      109 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
      link
      fedilink
      6
      edit-2
      9 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… :/

  • Leaflet
    link
    fedilink
    English
    399 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
  • @thevoidzero@lemmy.world
    link
    fedilink
    209 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

    • @sntx@lemm.ee
      link
      fedilink
      79 months ago

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

    • Tomkoid
      link
      fedilink
      99 months ago

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

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

    • Sips'OP
      link
      fedilink
      49 months ago

      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.

  • @nyan@sh.itjust.works
    link
    fedilink
    109 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).

  • Billegh
    link
    fedilink
    99 months ago

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

  • @gerdesj@lemmy.ml
    link
    fedilink
    English
    99 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!

    • @flashgnash@lemm.ee
      link
      fedilink
      19 months ago

      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

  • @otp@sh.itjust.works
    link
    fedilink
    79 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

    • Codex
      link
      fedilink
      169 months ago

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

      • @otp@sh.itjust.works
        link
        fedilink
        29 months ago

        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

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

    • @tetris11@lemmy.ml
      link
      fedilink
      4
      edit-2
      9 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

  • @orangeboats@lemmy.world
    link
    fedilink
    79 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”