Not sure if this is an unpopular opinion. What do you think?
I am hoping when Paul updates 100 Days of SwiftUI videos he'll introduce the concept of renaming ContentView
into something more appropriate for the application you are building.
To me, ContentView
is the "FooBar" of examples. Many programming books would use the function name "FooBar" when trying to explain a concept. (This is back in the day when I actually bought hardcover programming books!) FooBar was always meant to mean, "This is a generic concept, replace FooBar with your actual intended function name. But for the purposes of this chapter, is just means generic function."
In most online SwiftUI videos, the presenters provide eloquent discussions how Swift functions names read like English sentences.
let singers = ["Taylor", "Paul", "George", "John"] // An array of people who sing!
singers.sort(by: > ) // See? sort by is meaningful. This is not FooBar.
singers.remove(at: 1) // this is clear.
Also there are many examples how struct and variable names should be descriptive of your intentions.
Yet, most online tutorials keep the default ContentView
simply because that's what XCode provides when creating a new view.
I think we do a disservice to new programmers. Perhaps we should challenge them to think about what it is they want to see on the screen! They are designing a tip calculator, the view could be called TipView
. If they are designing a screen to show a photo of a national park along with a description, perhaps the view should be called ParkView
?
I just think we can raise the bar a bit and teach new programmers to avoid the default, ContentView
.
Please share your thoughts below!