课程: Java Essential Training: Syntax and Structure

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Naming variables

Naming variables

- [Instructor] In our GrossPayCalculator program, notice, we name these variables hours and payRate to represent the information that they're holding. If we need to use these variables later on or revisit this program a year from now, it will be clear what these variables represent. Sometimes, programmers are in a hurry and will use abbreviated words or even a single letter, such as h for hours or r for rate. This is discouraged because it makes your code less understandable to others, and even to your future self. Please be descriptive when you're naming your variables, methods, class, and packages. Anything that you name in programming, be descriptive of what it represents, because whenever you look at this again, you don't want to have to guess or dig around to figure out what it represents. Also, when you're collaborating with other programmers, they may have to update your program later. So it's very helpful when…

内容