Comments (9)
Definitely do away with prefixes. Apple seems to be encouraging this as well.
However, probably let's not name any classes UIButton. ;)
--------- Original Message --------- Subject: [swift-style-guide] Class prefixes (#13)
From: "Matthijs Hollemans" [email protected]
Date: 6/10/14 1:31 pm
To: "raywenderlich/swift-style-guide" [email protected]
Because you get an automatic namespace that is named after your project, I vote that we drop the requirement of having an RWT / SKT / whatever prefix for class names and global constants.
If there is a naming conflict with a built-in symbol, you can always prefix with the name of the framework (or your project) to disambiguate.
Silly example:
class UIButton { ... } // this is now allowed (but not a good idea) let myButton1 = UIButton(...) let myButton2 = UIKit.UIButton(...) // get the one from UIKit let whatever = Swift.Array() -
Reply to this email directly or view it on GitHub.
from swift-style-guide.
👍 👍 Kill the prefix!
I think a prefix would confuse me and make me think I am working with an ObjC class.
from swift-style-guide.
👍 Plus prefixes are dumb when I want to reuse classes between multiple projects and I have to change the file names :)
from swift-style-guide.
Also, when you need Obj-C interoperability, you can do:
@objc (RWTMonster) class Monster { ... }
In Obj-C the class will have the name RWTMonster.
EDIT: To clarify, in your source code it will still be called Monster but during runtime it's called RWTMonster. Freaky! (And even if you don't specify a name, the class will automatically get a mangled runtime name to avoid namespace collisions.)
from swift-style-guide.
Since we will be writing both Swift and ObjC we should definitely use the @objc
tag for all classes so no one gets lost between Swift & ObjC.
from swift-style-guide.
Prefixes seem to have been abandoned in Swift, and I agree that our classes should not be prefixed. However, not for some of the reasons people are saying.
Namespaces is why we should not have prefixes, I agree. I just do not like the argument, "it seems like Apple wants it this way." If out style guide is exactly how Apple is pushing Swift, then there is no point in having a style guide. We can deviate from Apple's suggested formatting for our own reasons and purposes.
from swift-style-guide.
Our style guide is meant for one thing: making sure we all agree on the way we write code so that the books (primarily) and tutorials (secondarily) look consistent. Whenever in doubt, do what Apple does, because that makes our code consistent with their code, which is the other place most people will encounter Swift.
We can definitely do things other than what Apple does, but we should have a really good reason for doing it.
--------- Original Message --------- Subject: Re: [swift-style-guide] Class prefixes (#13)
From: "Evan Dekhayser" [email protected]
Date: 6/10/14 7:15 pm
To: "raywenderlich/swift-style-guide" [email protected]
Cc: "elephantronic" [email protected]
Prefixes seem to have been abandoned in Swift, and I agree that our classes should not be prefixed. However, not for some of the reasons people are saying.
Namespaces is why we should not have prefixes, I agree. I just do not like the argument, "it seems like Apple wants it this way." If out style guide is exactly how Apple is pushing Swift, then there is no point in having a style guide. We can deviate from Apple's suggested formatting for our own reasons and purposes.
Reply to this email directly or view it on GitHub.
from swift-style-guide.
+1 for no class prefix in Swift-only code - i.e. class Monster { ... }
but +1 to maintain the convention for those classes that are going to be exposed to ObjC - i.e. @objc (RWTMonster) class Monster { ... }
.
from swift-style-guide.
I agree that when exposing our classes to Obj-C, we should use a prefix.
However, will we be exposing any classes to Obj-C? Other than maybe in a chapter or tutorial that is specifically design to show how to use Swift code from Obj-C code, will any projects we deliver mix the two?
--------- Original Message --------- Subject: Re: [swift-style-guide] Class prefixes (#13)
From: "Soheil Moayedi Azarpour" [email protected]
Date: 6/10/14 10:05 pm
To: "raywenderlich/swift-style-guide" [email protected]
Cc: "elephantronic" [email protected]
+1 for no class prefix in Swift-only code - i.e. class Monster { ... } but +1 to maintain the convention for those classes that are going to be exposed to ObjC - i.e. @objc (RWTMonster) class Monster { ... }.
Reply to this email directly or view it on GitHub.
from swift-style-guide.
Related Issues (20)
- Make the linter a dotfile HOT 2
- [email protected] HOT 1
- New line in functions. Not good. HOT 2
- Please add `no_extension_access_modifier` as a default SwiftLint rule HOT 1
- Please Add SwiftUI style guide
- https://ideas.accredible.com/changelog/functionality-for-a-messagenotification-to-be-added-over-an-issued-credential
- edge://credits/ HOT 1
- Clean code
- Function Declarations HOT 1
- 4-space indentation. HOT 2
- False positive from array_constructor custom rule
- how to write switch statement HOT 1
- Preferred type inference of static vars inside extensions HOT 4
- Pls update Readme file to reflect the newest changes in `if let` syntax introduced in Swift 5.7 HOT 1
- unused_import does not seem to be working HOT 1
- Function Calls vs Function Declarations HOT 2
- `unused_import` should be listed in the `analyzer_rules`
- SwiftLint 'attributes' rule flags property wrappers HOT 2
- Function calls format
- Revisit ternary operator section
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-style-guide.