05 Challenge in The Menu App -- suggestions from a newbie

Thank you all for developing this course, it has been enjoyable and helpful!

I would like to make a suggestion that would make the 05 Challenge less confusing for complete newcomers like me. There are two places that I would suggest that you change your verbiage in the code:

(1)
var array = [“Apple”, “Orange”, “Banana”, “Pear”, “Dragon Fruit”]

It was confusing for you to call an array “array”. I would suggest not using the type of thing it is as the name, so that later learners won’t be confused about if it is referring to the var array or just an array itself. Maybe change to something like this:

var myWords = ["Apple", "Orange", "Banana", "Pear", "Dragon Fruit"]

(2)
List(items, id: .self) { item in

            Text(item)
        }

It is confusing to use the variable “items” when you must use the { item in} function. Those sound very similar and it tripped me up.

Maybe use something like this:

        List(fruits, id: \.self) { item in
            
            Text(item)
        }

I thought I’d pass on those suggestions since I’m seeing this stuff from the eyes of a near-idiot when it comes to coding. Experts like you might not notice these confusions!

Keep up the good work and I’ll keep doing my best to learn!

Blessings,
Greg

As a regular moderator on this site, to be honest this is the first time anyone (at least that I can recall) has commented regarding the naming conventions in the solution. That said, I can understand your point of view if coding is extremely new to you.

Rather than

List(fruits, id: \.self) { item in      
    Text(item)
}

You could say:

List(fruits, id: \.self) { fruit in      
    Text(fruit)
}

fruits is plural, ie many, and fruit is singular which is an element of the array fruits.

Given that you now understand what is going on I am sure that as the years pass you wont give this a second thought if you see it again.

Thanks for your quick reply, Chris. I thought there was something sacrosanct about the word item. I now understand that any word will do. Helpful!

Distinguishing two things by whether it is plural or not seems more difficult than using completely different words. Also, the distinction between capitalizing vs. lowercase also can make things more difficult (although Chris has mentioned this particular distinction in several of his videos).

However, if that’s how it’s done in the coding world, then I just need to conform and get used to it! Until a month ago, I’ve never coded anything in my life and so this is a completely new world for this accountant.

Thanks again,
Greg

This feels confusing at first, but thinking about an array, think of it like a file cabinet with folders in it.

You have multiple files, so you wouldn’t call all those files in that cabinet just “oh I have a file in the cabinet” you’d say “oh I have tons of files in that cabinet” it’s plural cause you’re talking about multiple.

But when you go through each one (iterating through them, aka going through them one by one) you can only ever open one at once, so that’s why it’s then singular

This is super important! Casing matters because Swift is case sensitive and statically typed. fruits and Fruits would refer to different things. This is 100% something you’ll get used to

This is a conference talk I gave that goes over stuff like this. It’ll include some things you haven’t learned yet, but all of it is important for writing good Swift code

Thank you! Your analogy about the file cabinet is very helpful. And I have definitely noticed that Swift is case sensitive— I can’t tell you how many times I have received an error message because I capitalized something, or not!

Steep learning curve to climb, but at least I’m no longer in the valley :slight_smile:

Blessings,
Greg

Remember you’ll never know everything!! (So don’t even try to make that a goal)

Coding is tough!! There’s a reason people can be paid 6 fixtures in their very first job whether they went to college or not.

We all learn at different speeds. What also helps is knowing the topic of a video (for example arrays) and then searching for that same topic and reading / watching how someone else explains it. Sometimes the way one person explains it, it’s confusing, but the way someone else does, it clicks!

I appreciate the encouragement! Good idea about getting the teaching from multiple sources. And by the way— I watched the conference talk you gave— very helpful presentation!

Onward and upward,
Greg

1 Like