Newbies question: Advisability of using reserved words and terms for variables? - page 2

 
ckingher:

Thanks for the flattery. However, people can do things differently from us.


I don't like assuming that all people are using MetaEditor as their sole editor.

It's weird and for whatever reasons, all kinds of IDE do exist out there.

And some editors don't have function and reserved word highlights.


They may compile their programs with MetaEditor.

It's a compliment.. your welcome.

 
cloudbreaker:

Good practice in order to make maintenance of your code easier is to include the variable type in the name.


eg.

bValidParameters is a bool

sParameterName is a string

iParamaterNumber is an int

dParameterValue is a double


CB


Thanks CB.

Good suggestion, though I have also adopted the practice of ptutting what the term is first. I don't remember the terms from my English lessons very well, but I think the is the noun at the start of the term and then the adjective.

Thus I would use: SpreadMax & SpreadMin

rather than : MaxSpread or MinSpread.

I utilize this same convention in naming MQL programs and folders on my computer so that when I sort them alphabetically, they are all grouped together.

Likewise if I am quickly scanning my MQL code, I can spot them easier this way.

But I can't think of any reason why adding your convention to it as well wouldn't be a good idea as it is along the same lines as my usage already and its ready advantage is obvious.

But this still doesn't help me deciding if I should just use: 'spread' rather than 'SpreadMax', or 'Bid' rather than 'BidMax' etc

 

I have no idea why you would want to use reserved variable names for your own variables.


CB

 
cloudbreaker wrote >>

I have no idea why you would want to use reserved variable names for your own variables.

CB

It just seems natural and makes it less complex and redundant to just use the designated terms that already exsist. But I don't have enough expereince to know if this will cause practical difficulties, problems and contentions.

 
cloudbreaker wrote >>

I have no idea why you would want to use reserved variable names for your own variables.

CB

Why use a different term if their is already one designated for the purpose and reason that I want and need it for?

This is a question, not a statment.

 

Let's take Bid as an example.


Option 1 (recommended). You use Bid for its stated purpose. The platform provides the current bid price for the current symbol as a normalized double. You reference it as Bid in your code. You do not attempt to declare the variable (eg. by stating "double Bid") anywhere in your code.


Option 2 (why would you want to do this??). You attempt to declare Bid as a variable of your own with a statement such as "double Bid". This would NOT be using it for its designated purpose which is for the PLATFORM - not you - to maintain the current normalized value of the bid price for the current symbol.


Hope this makes sense to you.


CB

 
cloudbreaker wrote >>

Let's take Bid as an example.

Option 1 (recommended). You use Bid for its stated purpose. The platform provides the current bid price for the current symbol as a normalized double. You reference it as Bid in your code. You do not attempt to declare the variable (eg. by stating "double Bid") anywhere in your code.

Option 2 (why would you want to do this??). You attempt to declare Bid as a variable of your own with a statement such as "double Bid". This would NOT be using it for its designated purpose which is for the PLATFORM - not you - to maintain the current normalized value of the bid price for the current symbol.

Hope this makes sense to you.

CB

Yep it does,

Like I said, at first it made sence. But I had this 'itch' in my frontal lobes......

Thanks CB

 
cloudbreaker wrote >>

Let's take Bid as an example.

Option 2 (why would you want to do this??). You attempt to declare Bid as a variable of your own with a statement such as "double Bid". This would NOT be using it for its designated purpose which is for the PLATFORM - not you - to maintain the current normalized value of the bid price for the current symbol.

Hope this makes sense to you.

CB

Still thinking about this:

If I'm using a 'standardized term' that is already recognized by MQL, then I don't have to 'declare/define' it, it already is.

Thus I have been using existing predefined designated terms when I need them, and only adding ones that I declare and define when needed that aren't already in existence.

Not doing this for the sake of argument, just trying to fully understand and comprehend it and utilize the 'KISS' (Keep it Simple STUPID!) formula.

 
FourX:

Still thinking about this:

If I'm using a 'standardized term' that is already recognized by MQL, then I don't have to 'declare/define' it, it already is.

Thus I have been using existing predefined designated terms when I need them, and only adding ones that I declare and define when needed that aren't already in existence.

Not doing this for the sake of argument, just trying to fully understand and comprehend it and utilize the 'KISS' (Keep it Simple STUPID!) formula.

Now you've got it.


CB

 

I have?

But this means that I am utilizing pre-existing and defined terms in the EA regardless if they are designed for the terminals usage or an external EA. I don't mean to be rude of insulting as I appreaciate your help, but this is what I was doing to start with that you said to avoid? I just want to be sure and get this sucker nailed down correctly at the start so I don't get into bad habits. I already have enough against me in this endevour: ME!

I have adopted your reccomendation of prefixing it with the type of variable when I create new ones, though obviously had to avoid 'iMA'. I could use i_MA in this instance though. Thanks for the tip.

Having one heck of a time with syntax so far.

Reason: