Episode 3: UIKit Styling with Functions question about polluting namespace #126
Unanswered
acosmicflamingo
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I definitely learned a ton in that video and want to incorporate it for styling UIView subclasses like UIButtons, UILabels, etc. What I got out of the video was that you can do something like this:
However, couldn't the habit of using global functions like this potentially pollute the global namespace? Although you now lose the ability to chain functions by adding it to a UIView extension, it would certainly mean that typing 'ada' in Xcode would not automatically show the
adaptiveFont
function unless you were trying to call the function from within a UIView subclass instance.Is the video oriented more towards showing the power of chaining higher order functions, not so much for practical use because doing so runs the risk of namespace pollution?
Edit: perhaps a workaround to the polluting namespace issue could be to make these static functions that exist within a class named "StyleGuide", although it is certainly uglier to have "StyleGuide" appear over and over again if you are calling many of these functions back to back...
Beta Was this translation helpful? Give feedback.
All reactions