1. 首页
  2. 易语言 - EasyLanguage
  3. 命名习惯 D. Naming Conventions

命名习惯 D. Naming Conventions

What is a Naming Convention?

It is a style or method of applying words, symbols to Filenames and Variables etc. so that code is more readable to the User and become familiar as to their hidden meaning. This type of structure enables the coder to become more efficient in finding like items on a global scale as well as quickly understanding like concepts over a large volume of coding.

Easy Language provided Document files like Strategies, Indicators, and Functions Have a (generic) Naming Convention.
If you were to Edit an Easy Language Document a way of adding a naming convention to the filename would be to use SAVE AS and rename the document  for example:

Bollinger Bands could become _myBollingerBands   
_BollingerBands could become too _myBollingerBands_Revision2    To represent a second revision etc.

With an Underscore as the first character, if you sorted the directory you will find that it will now be close to the top of the file list. 
Many other characters as well as numbers will sort first ahead of Alpha Text.

DataType (Variable Types) Naming Conventions

In Easy Language there the following Data or Variable types:

There are three reserved words used to identify the three numeric subtypes:
INT for integers, FLOAT for single floats, and  DOUBLE for double floats.
String or Text variables
Boolean or TrueFalse

Many coders use special characters before or after variables of certain DataTypes.

They is no specific Rule as to which character to use different coding languages would accept symbols too.

An example for a Integer could be iNumber, i_Number  or Number_i whereas  any variable with that prefix or suffix could
An output Variable from a function could begin with a small o etc.

Many coders do not use Variable prefixes or suffixes (in Easy language). The need to identify a Variables DataType makes sense when coding unique instances of variables that are outside of your standard naming conventions.

Making the Code yours

One of the most important key to learning how to code is to attempt to breakdown code samples so that you understand how they were built and the meaning of each sentence in a paragraph of code.

Add comments … Change Variable names if needed and use a naming convention that is relevent and personal to you.

Note: that nothing has to make sense as long as you understand the meaning. There is no right or wrong!
If you develop a study or a concept, give it a name or title that is different that relates in some way to something you are trying to code.

Making the code yours … and personal

Input:	BarTender(34);    		{Am I King of how many}
Input: 	GhostLineOn(false);   		{Ghost 5}
Input: 	HyperGhostLineOn(false);	{Fibonacci Ghost} 
var: 	Apples_n_Cherries(true);	{See the dots on the mid-line}
var: 	Buttons(true);    		{button to view hips and lops}
var: 	ExtremeBands(true);   	{Bands to border extremes}  {IndyRacer}
var: 	Dash (false);  		{Show Indy Racer Logic}
Var:  	IndyRacer(0);   		{Keeps direction of trade opportunity}
Var: 	Fingers(0);
Var: 	Donut(0), Nut(0);
if Dots_Donuts=1 then begin Donut =1;  Nut =0;end;
if Dots_Donuts=2 then begin Donut =2;  Nut =1;end;

if IndyRacer_On then begin
 IndyRacer = IndyRacer[1];etc....
更新于 2020年6月2日

这篇文章对您有帮助吗?

相关的话题

留言评论