Namespacing

For what it's worth, recent frameworks (e.g. Combine) have been using enums as namespaces (e.g. Publishers). You can indeed extend enums in different files.

I used to be in the #2 camp (prefer structs) and would just make a private init() {} to prevent creating an instance of the namespace. I've since been converted to camp #1 (prefer enums.)

Apple frameworks have been updated over time to reduce the amount of flat names in the global namespace. It has somewhat reduced discoverability but in the same stroke has decluttered the global namespace. I think, for the most part, this has been a great thing.

6 Likes