Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conventions Convention #55

Closed
EricBAndrews opened this issue Jun 28, 2023 · 7 comments
Closed

Conventions Convention #55

EricBAndrews opened this issue Jun 28, 2023 · 7 comments
Milestone

Comments

@EricBAndrews
Copy link
Member

How should we format our code?

Discuss.

@ShadowJonathan ShadowJonathan transferred this issue from mlemgroup/mormaer-mlem Jul 3, 2023
@ShadowJonathan ShadowJonathan moved this from To Triage to Todo in Development Tracker Jul 3, 2023
@ShadowJonathan
Copy link
Contributor

cc @mormaer and @JakeShirley since they have been working on this

@ShadowJonathan ShadowJonathan moved this from Todo to In Discussion in Development Tracker Jul 3, 2023
@Sjmarf
Copy link
Member

Sjmarf commented Jul 7, 2023

Filenames should have no spaces and should match the name of the struct/class inside of the file where possible imo.

@tht7
Copy link
Contributor

tht7 commented Jul 7, 2023

I know that the current file names are weird like who tf puts spaces in file names
Buttt it’s kinda growing on me, feels oddly friendly

@mormaer
Copy link
Contributor

mormaer commented Jul 7, 2023

Don't succumb to the dark side @tht7 - stay strong

I'd vote for any new files we create being in UpperCamelCase and matching the struct/class they contain as @Sjmarf said... it's the sane choice 🙃

It'd be worth fixing the others but given the potential nightmarish rebases against large changes to the project file I'd perhaps suggest if/when a particular file is refactored, we fix the file name at the time rather than an all at once approach

@EricBAndrews
Copy link
Member Author

Personally I prefer the spaces--there isn't any downside to it (it's not like we're navigating through this on a terminal--Xcode handles spaces very nicely), and it makes the file name easier to read. The only reason to use CamelCase is when it's actually impractical to use spaces.

It's a very minor concern either way, though, so if people like the CamelCase I don't mind using it

@Sjmarf
Copy link
Member

Sjmarf commented Jul 8, 2023

Every other Swift project I've worked on uses CamelCase for filenames, and so do all of the most popular Swift repos I've seen (CodeEdit, Whisky, Firefox, etc). I'm yet to see a project that doesn't do this, and thought it was some kind of standard. Google and Microsoft seem to think so, but I can't find any comments on file naming from Apple themselves.

As you say, one of the reasons why we typically avoid spaces in filenames is because of the terminal - and sure, we may not be using it now, but we may need to in future.

I'd prefer to use CamelCase for consistency with the wider Swift community, but don't really mind that much.

@boscojwho
Copy link
Contributor

I was definitely thrown off by the spaces in some filenames. For example, when I was looking for AppState using Open Quickly:

  • Typing appstat shows two seemingly unique results.
Screenshot 2023-07-24 at 2 43 34 PM
  • Typing app stat only returns one result.
Screenshot 2023-07-24 at 2 44 14 PM
  • Which means, we'd have to type appstate to get AppState the class itself.
Screenshot 2023-07-24 at 2 45 08 PM

Obviously, this is only relevant if the file only contains one type with the same name, but it gets a little tedious having to possibly think about this when you're just trying to open something quickly.

PascalCase has definitely been the convention not just in Swift, but also Objective-C, Cocoa (Touch), and first/third party Apple ecosystem frameworks. Much of this is cultural (especially within the "indie" Apple dev community), but Apple also loves to be opinionated on this subject. For example: See here for an old Apple article on naming header files in Objective-C. I couldn't find Apple's newer documentation that directly discusses filenames, but Apple's own repos also use Pascal Case, for example apple/swift-syntax

I guess it's not a big deal, as long as we don't do snake case 😆😆

@EricBAndrews EricBAndrews modified the milestones: v1.1, v1.2 Sep 18, 2023
@EricBAndrews EricBAndrews closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2024
@github-project-automation github-project-automation bot moved this from In Discussion to Finished in Development Tracker Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

No branches or pull requests

6 participants