-
Notifications
You must be signed in to change notification settings - Fork 31
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
Comments
cc @mormaer and @JakeShirley since they have been working on this |
Filenames should have no spaces and should match the name of the struct/class inside of the file where possible imo. |
I know that the current file names are weird like who tf puts spaces in file names |
Don't succumb to the dark side @tht7 - stay strong I'd vote for any new files we create being in 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 |
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 |
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. |
I was definitely thrown off by the spaces in some filenames. For example, when I was looking for
![]()
![]()
![]() 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 😆😆 |
How should we format our code?
Discuss.
The text was updated successfully, but these errors were encountered: