<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div>The lack of namespaces is making people create all kinds of "design patterns".<br /></div><div><br /></div><div>struct API {</div><div> static let endpoint = "<a href="http://example.com/api" target="_blank" rel="noopener noreferrer">http://example.com/api</a>"</div><div>}</div><div><br /></div><div>Here is an "improvement" to the above "design pattern" to prevent instantiating API:</div><div><br /></div><div>struct API {</div><div> private init() {}</div><div> static let endpoint = "<a href="http://example.com/api" target="_blank" rel="noopener noreferrer">http://example.com/api</a>"</div><div>}</div><div><br /></div><div>Finally, here is another "improvement" that uses enum instead of struct to avoid having to write the private initializer:</div><div><br /></div><div>enum API {</div><div> static let endpoint = "<a href="http://example.com/api" target="_blank" rel="noopener noreferrer">http://example.com/api</a>"</div><div>}</div><div><br /></div><div>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.</div><div><br /></div><div>What do you think?</div><div><br /></div> </body>
</html>