Thursday, May 23, 2019
Variable naming rules in Visual Basic, Python, and Java
This paper will draw and quarter the variable naming rules of three different programming languages. These three languages are ocular staple fibre, Python, and Java. Each of these languages has different rules that apply to them and some similarities. I will describe the rules and the similarities and differences in the next few paragraphs.The first language and its rules I will describe is Visual prefatorial. Visual Basic has a few different rules and they are draw on Microsofts website in a document. This document is called (Visual Basic Naming Rules) and they immortalize as such You must use a letter as the first character.You cant use a space, period (.), exclamation beat (), or the characters , &, $, in the realise. Name cant exceed 255 characters in length. Generally, you shouldnt use any label that are the same as the functions, statements, and methods in Visual Basic. Visual Basic isnt case-sensitive, but it preserves the capitalization in the statement where the na me is declared. These are the variable naming rules are specific to Visual Basic and are all important(p) to know if you program using Visual Basic.The second language I will describe is Python. This language has a few rules of its own and they are described on a site called programmr.com in an article called (Python Variable Naming Rules) and they read as such Must put down with a letter (a z, A B) or emphasise (_).Other characters can be letters, numbers or _ only.Variable names are Case Sensitive.There are some reserved lyric which we cannot use as a variable name because Python uses them for other things. These are and, del, from, not, art object, as, elif, global, or, with, assert, else, if, pass, yield, break, except, import, print, break, except, import, print, class, exec, in, raise, class, exec, in, raise, continue, finally, is, return, continue, finally, is, return, def, for, lambda and try. These are the naming rules for Python and are necessary to programming in t his specific language.The three and final language I will talk about is Java. This program is no different than the other two languages and its rules are described in an oracle document called (Lesson Language Basics) in a sub article called Variables and they read as such Variable names are case-sensitive. A variables name can be any legal identifier an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign $, or the underscore character _. The convention, however, is to always begin your variable names with a letter, not $ or _. Additionally, the dollar sign character, by convention, is never used at all.You may find some situations where auto-generated names will contain the dollar sign, but your variable names should always avoid using it. A similar convention exists for the underscore character while its technically legal to begin your variables name with _, this practice is discouraged. White space is not permitted. Subsequent char acters may be letters, digits, dollar signs, or underscore characters. Conventions (and frequent sense) apply to this rule as well.When choosing a name for your variables, use full words instead of cryptic abbreviations. Doing so will make your code easier to read and understand. In many cases it will also make your code self-documenting fields named cadence, speed, and gear, for example, are much more intuitive than abbreviated versions, such as s, c, and g. in like manner keep in mind that the name you choose must not be a keyword or reserved word. If the name you choose consists of only virtuoso word, spell that word in all lowercase letters. If it consists of more than one word, capitalize the first letter of each subsequent word. The names gearRatio and currentGear are old examples of this convention.If your variable stores a constant value, such as static final int NUM_GEARS = 6, the convention changes slightly, capitalizing every letter and separating subsequent words with the underscore character. By convention, the underscore character is never used elsewhere. The Java programming language is statically-typed, which means that all variables must first be declared before they can be used.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.