Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 13,353 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Formatting Syntax #115820
03/07/07 11:53
03/07/07 11:53
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline OP
User
sheefo  Offline OP
User

Joined: Jul 2006
Posts: 783
London, UK
I was wondering about how people format their code, like when you define a pointer, do you do "STRUCT* pointer;" or "STRUCT *pointer;"? Which one is the intended way, or the one which professionals use?

Do you use "pointer -> attribute" or "pointer->attribute" when accessing an attribute of the object your pointer is pointing to?

Are there any more? This is all I can think of right now.

Re: Formatting Syntax [Re: sheefo] #115821
03/07/07 12:39
03/07/07 12:39
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
I don't use Lite-C, but

1) STRUCT *Pointer; because then you protect yourselfe from the mistake: STRUCT* Pointer1, Pointer2; where 2 is no pointer because of the missing *

2) Pointer->x for sure, the spaces just take more time to write, while it's not better readable ( function foo(var Baa){} without whitespaces in the params, too )

3) Names: There is no best way; You can name members of strucs with m_ or write the names like I do ' function Net_ClVoiceGetVoiceDevice(ExempleVar); ' or write all names big or make struct names big, like the engine ones (VECTOR, STRING,...)

That's all up to you. But I think a notation like the type, ptr prefix (var *VPrtGameName;) or such things make programming crazy, it makes the code unreadable.

Every programmer has it's own preferences.

Re: Formatting Syntax [Re: TWO] #115822
03/07/07 13:43
03/07/07 13:43
Joined: Jul 2006
Posts: 783
London, UK
sheefo Offline OP
User
sheefo  Offline OP
User

Joined: Jul 2006
Posts: 783
London, UK
Thanks for sharing you coding style, even though you say you don't use lite-C... and C or C++ as well I guess...?

You reminded me of another thing, to do with structs. I would like to know how people define structs (or functions even)?

Style 1
Code:

struct myStruct {
int attr;
};



Style 2
Code:

struct myStruct
{
int attr;
};



I use Style 2

Re: Formatting Syntax [Re: sheefo] #115823
03/07/07 13:50
03/07/07 13:50
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
I work with C++ all day long

Most professional programmers prefer style 1, I prefer style 2.

Re: Formatting Syntax [Re: sheefo] #115824
03/08/07 00:22
03/08/07 00:22
Joined: Mar 2007
Posts: 4
New York, NY
DGuy Offline
Guest
DGuy  Offline
Guest

Joined: Mar 2007
Posts: 4
New York, NY
I actually use:

Code:
struct myStruct
{
int attr;
};


But, having said that, my only advice to someone concerned about layout style would be:

1) Keep your code readable (Don't be afraid of whitespace!)
2) Choose a style that you like, and use it consistantly.

HTH


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1