This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[TUT] Code Styling & Good Programming Habits


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 01-16-2010 , 01:48   Re: [TUT] Code Styling
Reply With Quote #1

Quote:
Originally Posted by hleV View Post
Nice.

I myself prefer HN.

Didn't knew that this was possible:
Code:
MyFunction( id ) if( is_user_alive( id ) ) { client_print( 0, print_chat, "We are now killing %d", id ) user_kill( id ) }

o_O

About function names... I'm still not decided, but currently I write only the first letter (or letters, if function's type title is made from 2 words, like forward - fw). Like eDeathMsg() for event and cSay for command. Also sPrint() for stock.

BTW is the g_Test pointer (although danielkza said there are no pointers in Pawn) or a normal integer?
Code:
g_Test = register_cvar("amx_test", "1");

I was used to treat it as pointers (so g_Test was g_pTest) but then I realized I have no idea what pointer really is so now I treat is as normal integer (g_Test is now g_iTest). Which one is more correct?
There is some confusion in this old post but for those who read it and don't understand why is pointer mentioned on it and what does pointers have to do with pawn:

In pawn there isn't the concept "pointer" (a variable which value is an address and that, with features of the language, can be used to perform operations on/with the data that is located at that address).

What is happening here is that register_cvar returns an address that in a language like C++ can be used as a pointer but in Pawn it can only be provided to a native in C++ so that it can be used as a pointer. So g_Test holds an address but that isn't enough to make it a pointer because pawn doesn't has pointers.
joaquimandrade is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 02-08-2009 , 12:54   Re: [TUT] Code Styling
Reply With Quote #2

I strongly agree with the "Tabbing and Spacing" part
Its soo annoying when u get a wall of text in the source

Good tut
+k
__________________
minimiller is offline
Send a message via MSN to minimiller
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 02-11-2009 , 15:34   Re: [TUT] Code Styling
Reply With Quote #3

nice thread hawk + i agree cuz its very similar to my style
good codes are one thing, finding solutions for huge problems is another thing BUT having a readable code has a very high priority as soon as you are planning to release a plugin or share the source in any way. just look at numbs plugins, then you know what i mean (at least most of his plugins show how a code shouldnt... ).
numb <3
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 02-22-2009 , 11:13   Re: [TUT] Code Styling
Reply With Quote #4

hey Hawk, nice tut but I allways use in my plugins semicolons at the end of line.....
My question is, i must put this #pragma semicolon 1 in every plugin?
__________________
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 02-22-2009 , 11:37   Re: [TUT] Code Styling
Reply With Quote #5

No.
__________________
hleV is offline
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 02-22-2009 , 11:45   Re: [TUT] Code Styling
Reply With Quote #6

ok thank you
__________________
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 02-22-2009 , 12:29   Re: [TUT] Code Styling
Reply With Quote #7

you can put it to be sure what you placed ; at end of all lines :]
__________________
xPaw is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 02-22-2009 , 15:20   Re: [TUT] Code Styling
Reply With Quote #8

IMO it's useless because there's nothing bad if you forgot to put ; somewhere.
__________________
hleV is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-22-2009 , 16:08   Re: [TUT] Code Styling
Reply With Quote #9

It's a nice habit to use ; so that you won't need to have to remember to use it in one language and not another.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-23-2009 , 01:27   Re: [TUT] Code Styling
Reply With Quote #10

Quote:
Originally Posted by Exolent[jNr] View Post
It's a nice habit to use ; so that you won't need to have to remember to use it in one language and not another.
I program in C++ at work and I have no problem switching between the two at any time.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode