Not complaining here but..... Level level?

First of all, congratulations on creating a great course. I’ve been fully enjoying it although I’m a bit frustrated right now.

I find it confusing to have a namespace and a variable be the same name.

For example: Level level; // confuses the heck out of me.

And then: level = FindObjectOfType<Level(); // makes my eyes go crossed.

But! I have had several Ah Ha! moments while watching and following along with these lessons so I’m open to the possibility of this becoming clear in a future Ah Ha! moment.

But for now is there any way I can get a bit more info on what Level level; actually does and what is the difference between the two.

Thanks!

1 Like

Hi Brian,

That’s actually a class not a namespace but you raise an interesting point.

Some would suggest that it is better to not name your variables the same as the class which they represent, equally, others may argue that using something like;

Level myLevel;

Equally,

Level currentLevel;

You could argue that current as a prefix is somewhat surpurflous as you know its the current level.

The lesson to take away from this is that you are able to identify which is the class and which is the variable. There are many articles online regarding naming conventions, many best practices are broken frequently, both in the course, across the Internet and in development generally. If I could offer one piece of advice to you it would be that whichever convention you decide to go with, be consistent. Whether it’s consistently good or consistently bad, another developer looking at your code will be very grateful if you are consistent regardless of the naming conventions you use.

Hi Rob, thank you for your reply.

I’ve moved on the next lecture/video and this concept is reinforced there so I think I’m starting to grasp it. You make a good point and a good suggestion about consistency in naming conventions.

Thanks again for the quick reply.

Onward to the rest of the course!

I’m looking forward to learning more.

Brian

1 Like

Privacy & Terms