[swift-evolution] The lack of namespaces is leading people astray
tuuranton at tutanota.de
tuuranton at tutanota.de
Mon Jan 30 07:55:31 CST 2017
The lack of namespaces is making people create all kinds of "design patterns".
struct API { static let endpoint = "http://example.com/api"}
Here is an "improvement" to the above "design pattern" to prevent instantiating API:
struct API { private init() {} static let endpoint = "http://example.com/api"}
Finally, here is another "improvement" that uses enum instead of struct to avoid having to write the private initializer:
enum API { static let endpoint = "http://example.com/api"}
I doubt any of you find this beautiful. Yet these "design patterns" (just hacks IMO) are spreading like the plague because of the lack of namespaces.
What do you think?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170130/31ef2222/attachment.html>
More information about the swift-evolution
mailing list