SwissCovid / swisscovid-app-ios

SwissCovid is the official contact tracing app of Switzerland.
Mozilla Public License 2.0
146 stars 44 forks source link

The NS prefix should only be used by Apple #57

Open seanlilmateus opened 4 years ago

seanlilmateus commented 4 years ago

according to the Apple's docs the NS and UI prefixes are exclusively for Apple classes, otherwise your own classes could collide with future apple's classes

In order to keep class names unique, the convention is to use prefixes on all classes. You’ll have noticed that Cocoa and Cocoa Touch class names typically start either with NS or UI. Two-letter prefixes like these are reserved by Apple for use in framework classes. As you learn more about Cocoa and Cocoa Touch, you’ll encounter a variety of other prefixes that relate to specific frameworks: [..] Your own classes should use three letter prefixes.

e.g.: NSTracingErrorView NSSimpleModuleBaseView UIStateManager

You Actually don't need class prefixes in Swift

Create a Swift class for your corresponding Objective-C .m and .h files by choosing File > New > File > (iOS, watchOS, tvOS, or macOS) > Source > Swift File. You can use the same or a different name than your Objective-C class. Class prefixes are optional in Swift.

Solution:

You could either create your own Prefix (following the Objective-C Prefix convention) or remove it completely

Why This should be fixed At the moment users might imply that those classes are coming from Apple, and look for its documentation on Apple's doc page

maerki commented 4 years ago

It true, that was a bit of an unfortunate decision that happened that happened in one of the late nights eary in the project.

We might fix this somewhen, but security, stability and UX are more important right now. Would you be interested to start a PR?

seanlilmateus commented 4 years ago

Alright, I will remove the prefixes and create a PR

maerki commented 4 years ago

Great. A few remarks:

UBaggeler commented 4 years ago

As the code base is not changing much anymore, are you still interested in updating the pull-request?