Coding Guidelines For HMG 4 Contributors [UPDATED]

Moderator: Rathinagiri

User avatar
Roberto Lopez
HMG Founder
Posts: 3902
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 13 times
Been thanked: 137 times

Coding Guidelines For HMG 4 Contributors [UPDATED]

Post by Roberto Lopez » Fri Aug 13, 2010 12:01 am

Hi All,

1. The goal for the 4.0 release is to mimic as good as possible the current HMG functionality only, so, submit code related to the achievement of this goal exclusively (the new features will be part of HMG 4.1).

2. The code submitted must have the same license as HMG (GPL+'Harbour Exception').

3. Use the same policy as existing project code for variables naming. This is: the initial letter indicates data type and the rest of the name is mixed case and as descriptive as possible ie:

- nNumeric
- cString
- lLogical
- dDate
- oObject
- bBlock

4. Indent the code to make clearly readable the control structures.

5. Comment the code you've added or modified as verbosely as possible (the rest of us must understand it too :) )

6. Please, add a commentary when commit changes (Tortoise commit window- 'message' frame).

7. Each control has three samples:

- Standard OOP
- xBase Syntax
- Alternate Syntax

Please, continue this way, so, we can show the three coding styles available for each control.

8. I've deliberately broke HMG compatibility in some special cases, using constants to signal property values to allow a OOP coding according standard way and a better (correct) alternate syntax.

ie: For label I've created the following constants:

#define LBL_LEFT 0
#define LBL_CENTER 1
#define LBL_RIGHT 2

So, when coding using OOP (ie):

:Alignment := LBL_RIGHT

When using alternate syntax:

Alignment LBL_RIGHT

This is more correct than current HMG's alternate syntax where RightAlign and LeftAlign are treated as properties:

RIGHTALIGN .T. | .F.
CENTERALIGN .T. | .F.

This is obviously wrong and we have the opportunity to correct now.

For full backwards compatibility we can create some preprocessor directives to make old syntax still working, but we must discourage its use. So, please consider this when required.

9. Remember that all controls inherits from Control class.

So, if you believe that the property, method or event you are coding can be reused 'as is' for other controls, it must be located at control class, if not you can put in the class of the control you are working on.

10. Other important thing is that you must 'double code' for prior/post control creation, since you can't access to a QT object before that this be created (done at Create() method executed by default at window activation).

So, your code must look at this:

Code: Select all


If ::lCreated

    * Access to QT object (ie)

    If pcount() == 0

        Return ::oQTObject:Something

    ElseIf pcount() == 1

        ::oOQTObject:Something(xValue)

    EndIf

Else

    * Access to instance variables only (ie)

    If pcount() == 0

        Return ::xVar

    ElseIf pcount() == 1

        ::xVar := xValue

    EndIf
   
EndIf




**** If the code submitted does not meet these guidelines, it could be removed by the project administrators ****


* To download the binary release (containing compiler, libraries and tools needed):

http://sourceforge.net/projects/hmg/files/

UNPACK IT IN ITS DEFAULT LOCATION (C:\HMG.4) OTHERWISE IT WILL NOT WORK.

* To become a contributor:

a. Download Tortoise SVN client (http://sourceforge.net/projects/tortoisesvn/).
b. Install according the setup wizard directions.
c. Open Windows explorer.
d. Right click in the C:\HMG.4\SVN folder.
e. Select 'SVN Checkout' (project url is: https://hmg.svn.sourceforge.net/svnroot/hmg).
f. If you change the code of your local copy and want to upload, Right click in the C:\HMG.4\SVN and select SVN Commit...
g. If you want download the changes from the server, Right click in the C:\HMG.4\SVN and select SVN Update.

* QT 4.5.3 Documentation: http://doc.trolltech.com/4.5/index.html

* HMG Documentation: hmgdoc/hmgdoc.htm

* Recommended Code Editor: I'm using Notepad++ (https://sourceforge.net/projects/notepad-plus/). It is open source and has a lot of nice features that makes it better that my previous choice (PsPad). ie: it shows lines to enclose control structures (It's very cool :))

Enjoy!
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
jerryfinuliar
Posts: 6
Joined: Tue Jan 19, 2010 6:03 am

Post by jerryfinuliar » Fri Aug 13, 2010 12:32 am

Good day Roberto,

Any thought of moving HMG 4 to any SVN?
It can receive more attention this way. Just my
0.2 cents.

Regards,
Jerry

User avatar
Roberto Lopez
HMG Founder
Posts: 3902
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 13 times
Been thanked: 137 times

Post by Roberto Lopez » Fri Aug 13, 2010 1:36 am

jerryfinuliar wrote:Good day Roberto,

Any thought of moving HMG 4 to any SVN?
It can receive more attention this way. Just my
0.2 cents.

Regards,
Jerry
It's already done: viewtopic.php?f=2&t=1634
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
sudip
Posts: 1444
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 4 times

Post by sudip » Fri Aug 13, 2010 6:06 pm

Hello Roberto,

I installed Notepad++ 5.7 but, don't know how to use with .prg files.
I shall try for some customization later.
With best regards,
Sudip

User avatar
apais
Posts: 260
Joined: Fri Aug 01, 2008 6:03 pm
Location: uruguay
Has thanked: 25 times
Been thanked: 15 times
Contact:

Post by apais » Fri Aug 13, 2010 7:01 pm

Why don't you use hbIde ? It's done with harbour and qt and is multiplatform also.

User avatar
Roberto Lopez
HMG Founder
Posts: 3902
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 13 times
Been thanked: 137 times

Post by Roberto Lopez » Fri Aug 13, 2010 7:13 pm

apais wrote:Why don't you use hbIde ? It's done with harbour and qt and is multiplatform also.
I've provided a batch file for build samples to keep the things simple, but, it could be included in future binary releases.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
Roberto Lopez
HMG Founder
Posts: 3902
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 13 times
Been thanked: 137 times

Post by Roberto Lopez » Fri Aug 13, 2010 7:35 pm

Roberto Lopez wrote:
apais wrote:Why don't you use hbIde ? It's done with harbour and qt and is multiplatform also.
I've provided a batch file for build samples to keep the things simple, but, it could be included in future binary releases.
Anyway, IMHO HMG4 should have its own IDE consistent with HMG philosophy: very simple and easy to use.

The works on it, could start when adequate functionality be in place.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

gvaronas
Posts: 108
Joined: Wed Aug 06, 2008 5:21 pm

Post by gvaronas » Fri Aug 13, 2010 8:32 pm

Roberto Lopez wrote:
apais wrote:Why don't you use hbIde ? It's done with harbour and qt and is multiplatform also.
I've provided a batch file for build samples to keep the things simple, but, it could be included in future binary releases.
de hecho, veo que HbIDE ya está incluido en el Binario de HMG.OBJECT que se distribuye (dentro del Harbour) y esta listo para usar

Salu2,
GVS

User avatar
Roberto Lopez
HMG Founder
Posts: 3902
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 13 times
Been thanked: 137 times

Post by Roberto Lopez » Fri Aug 13, 2010 8:48 pm

gvaronas wrote:
Roberto Lopez wrote:
apais wrote:Why don't you use hbIde ? It's done with harbour and qt and is multiplatform also.
I've provided a batch file for build samples to keep the things simple, but, it could be included in future binary releases.
de hecho, veo que HbIDE ya está incluido en el Binario de HMG.OBJECT que se distribuye (dentro del Harbour) y esta listo para usar

Salu2,
GVS
No está en HMG.4 (quité algunos archivos no escenciles para reducir el tamaño de la distribución).
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

gvaronas
Posts: 108
Joined: Wed Aug 06, 2008 5:21 pm

Post by gvaronas » Fri Aug 13, 2010 9:07 pm

de hecho, veo que HbIDE ya está incluido en el Binario de HMG.OBJECT que se distribuye (dentro del Harbour) y esta listo para usar

Salu2,
GVS[/quote]

No está en HMG.4 (quité algunos archivos no escenciles para reducir el tamaño de la distribución).[/quote]

Ok. Tenia una versión anterior de HMG.OBJECTS

Salu2,
GVS

Post Reply