About conventions in OOP MQL5 programs

 

Hi there,

Nice to greet you again! These months I have shared nothing with you cause I have been very busy but I'm here again xxxxxx (edited by moderator) which is going to be built on a solid mathematical (but very simple) conceptual base :-)

I have been able to advance my knowledge in MQL5 thanks to Code Base. Thank you very much! However I am a bit concerned about programming conventions. As a software engineer I am used to follow some strict conventions when programming, for instance, I try to be semantic when speaking through code, I camel case sentences, the names of my private and protected PHP variables begin with an underscore., etc.

Maybe there's a bit chaos in this sense in Code Base, that's my humble opinion, IMHO. The rest is perfect for me. 

Could you please tell me about some link, resource or whatever that explains some conventions, if any? If you want we can discuss them in this thread.

For instance,

1. I've seen that private properties always starts with an underscore, altough other times those properties start with _m.

2. Should start the method names in capital letters?

... 

Thank you very much in advance, 

 
laplacianlab:

Hi there,

Nice to greet you again! These months I have shared nothing with you cause I have been very busy but I'm here again xxxxxx (edited by moderator) which is going to be built on a solid mathematical (but very simple) conceptual base :-)

I have been able to advance my knowledge in MQL5 thanks to Code Base. Thank you very much! However I am a bit concerned about programming conventions. As a software engineer I am used to follow some strict conventions when programming, for instance, I try to be semantic when speaking through code, I camel case sentences, the names of my private and protected PHP variables begin with an underscore., etc.

Maybe there's a bit chaos in this sense in Code Base, that's my humble opinion, IMHO. The rest is perfect for me. 

Could you please tell me about some link, resource or whatever that explains some conventions, if any? If you want we can discuss them in this thread.

For instance,

1. I've seen that private properties always starts with an underscore, altough other times those properties start with _m.

2. Should start the method names in capital letters?

... 

Thank you very much in advance, 

If conventions isn't imposed by the language you always have this problem of chaos in a codebase. The better we have to do is to use a convention and be coherent (I am not always ). It's probably a little unrealistic to impose a convention to all programmers.
 
angevoyageur:
If conventions isn't imposed by the language you always have this problem of chaos in a codebase. The better we have to do is to use a convention and be coherent (I am not always ). It's probably a little unrealistic to impose a convention to all programmers.

Hi again!

I agree with you, don't want to force anybody to follow programming conventions. I see them as a set of good practices, just this, good practices defined by developers. In fact, conventions are not exceptional but rather normal in Open Source projects!

The lack of conventions may be a problem. Imagine a team of four people building a library of code, each of them on their own... One is writing the names of things in Spanish, the other writes in English... One person uses the hyphen character (name‐of-my-file.mq5) for separating words in file names. Other uses the underscore (nombre_de_mi_archivo.mq5), but one third member of the team camelcases (nameOfMyFile.mq5) the name of his files.

What would you do in a team such as this?

 
laplacianlab:

Hi again!

I agree with you, don't want to force anybody to follow programming conventions. I see them as a set of good practices, just this, good practices defined by developers. In fact, conventions are not exceptional but rather normal in Open Source projects!

The lack of conventions may be a problem. Imagine a team of four people building a library of code, each of them on their own... One is writing the names of things in Spanish, the other writes in English... One person uses the hyphen character (name‐of-my-file.mq5) for separating words in file names. Other uses the underscore (nombre_de_mi_archivo.mq5), but one third member of the team camelcases (nameOfMyFile.mq5) the name of his files.

What would you do in a team such as this?

We agreed about that. But the mql5 code in general are rarely the work of a team, and I doubt that majority of programmers who published code in Codebase see their work as integrated to a team.

Anyway, if you have some proposal for a "set of good practices", it will be good.

 
angevoyageur:

We agreed about that. But the mql5 code in general are rarely the work of a team, and I doubt that majority of programmers who published code in Codebase see their work as integrated to a team.

Anyway, if you have some proposal for a "set of good practices", it will be good.

I understand you. Code Base is a very good place for learning MQL5.

When I have time I'll try to detect some existing conventions to take advantage of them. I take note about what you say. Thank you!

 
angevoyageur:

We agreed about that. But the mql5 code in general are rarely the work of a team, and I doubt that majority of programmers who published code in Codebase see their work as integrated to a team.

Anyway, if you have some proposal for a "set of good practices", it will be good.

I have finally realized the best way to write MQL5 code is observing how the framework is written!

I am inspired by any file written by MetaQuotes Software Corp., for instance:

Include\Arrays\Array.mqh

Include\Arrays\ArrayChar.mqh

...

The files located in the MetaTrader 5 folder do follow some programming conventions, so maybe there's no need to propose any good practices for writing code, just observe how MT5 is written.

Thank you!

 
laplacianlab:

I have finally realized the best way to write MQL5 code is observing how the framework is written!

I am inspired by any file written by MetaQuotes Software Corp., for instance:

Include\Arrays\Array.mqh

Include\Arrays\ArrayChar.mqh

...

The files located in the MetaTrader 5 folder do follow some programming conventions, so maybe there's no need to propose any good practices for writing code, just observe how MT5 is written.

Thank you!

Good decision
Reason: