Raised This Month: $51 Target: $400
 12% 

Good programming habits


Post New Thread Reply   
 
Thread Tools Display Modes
organizedKaoS
Senior Member
Join Date: Feb 2006
Old 10-29-2006 , 14:25   Re: Good programming habits
Reply With Quote #61

Quote:
Originally Posted by Xanimos View Post
TBH, I'm just messing with you. I don't doubt that I did it. I was just pointing out that you can't possible prove it in anyway.
LOL
organizedKaoS is offline
JFeldon
Member
Join Date: Feb 2007
Location: United Kingdom
Old 02-13-2007 , 03:32   Re: Good programming habits
Reply With Quote #62

Good work Ryan! Very helpful.
JFeldon is offline
Send a message via MSN to JFeldon
Old 04-10-2007, 13:24
totopito
This message has been deleted by sawce the snail. Reason: irrelevant
Old 04-10-2007, 13:25
totopito
This message has been deleted by sawce the snail. Reason: irrelevant
OneMoreLevel
Senior Member
Join Date: Aug 2009
Location: Look behind you... Very
Old 10-27-2009 , 21:12   Re: Good programming habits
Reply With Quote #63

This might fit, I usually use this habit.



-- Using the ! with statements.

Generally using code with ! like this:

PHP Code:
 /* Example plugin */
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Example plugin"
#define VERSION "1.1"
#define AUTHOR "OneMoreLevel"
public plugin_init() {
 
 
register_plugin(PLUGIN,VERSION,AUTHOR)
 
 
register_clcmd"say /alive","Example_code")
}
public 
Example_code (id) {
 
 
// Is the user alive if not, end the plugin.
 
if (!is_user_alive(id))
 return 
PLUGIN_HANDLED;
 
 
// We dont need to use an else if here because is_user_alive only has two options, 1 or 0. 
 
else
 {
  
// Send the message "You are currently alive!"
  
client_print(idprint_chat,"You are currently alive!")
 }
 return 
PLUGIN_CONTINUE;
 




Is better than using code like this:

PHP Code:
/* Example plugin */
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Example plugin"
#define VERSION "1.1"
#define AUTHOR "OneMoreLevel"
public plugin_init() {
 
 
register_plugin(PLUGIN,VERSION,AUTHOR)
 
 
register_clcmd"say /alive","Example_code")
}
public 
Example_code (id) {
 
 
// Is the user alive if not, end the plugin.
 
if (is_user_alive(id) == 0)
 return 
PLUGIN_HANDLED;
 
 
// We dont need to use an else if here because is_user_alive only has two options, 1 or 0. 
 
else
 {
  
// Send the message "You are currently alive!"
  
client_print(idprint_chat,"You are currently alive!")
 }
 return 
PLUGIN_CONTINUE;
 

This isn't required by the AMXModX include, nor the pawn language, its just a good habit to get into if you want to learn future languages, and it makes your code look cleaner.
__________________
60/100 60%
[||||||||||||||||||||]
Project: Warfighter mod
Blog:
http://sites.google.com/site/dailymultitasker/
PHP Code:
   if ( i_help_you "Yes" ) == )
    
set_user_karma(onemorelevel,add,+1

Last edited by OneMoreLevel; 10-27-2009 at 21:15.
OneMoreLevel is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-27-2009 , 23:58   Re: Good programming habits
Reply With Quote #64

Actually, I think it would be better to use:

PHP Code:
if( is_user_alive(id) )
{
    
// User is Alive
}
else
{
    
// User is Dead

This is much more readable if you need both cases. Otherwise you can do the following if you only need one or the other:

PHP Code:
if( is_user_alive(id) )
{
    
// User is Alive

OR

PHP Code:
if( !is_user_alive(id) )
{
    
// User id Dead

So, basically don't use the '!' (not) if you need both a dead and alive case.

Disclaimer: This is my opinion and I believe that it is much easier to read.
__________________
fysiks is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-28-2009 , 00:33   Re: Good programming habits
Reply With Quote #65

Boolean inversion is faster than direct comparison anyway. It's not a matter of style; you're just outright wrong otherwise.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-20-2010 , 23:27   Re: Good programming habits
Reply With Quote #66

Quote:
Originally Posted by GHW_Chronic View Post
NOTEPAD!!! W00T!

--Oldschool boi
Do you really code such great plugins in notepad,
I'm sorry but i can't believe that.
I tried it once and i though i was gonna throw my pc out the window because the nerves i got doing it.

No number of lines, ....
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 03-23-2010 , 20:35   Re: Good programming habits
Reply With Quote #67

Quote:
Originally Posted by drekes View Post
Do you really code such great plugins in notepad,
I'm sorry but i can't believe that.
I tried it once and i though i was gonna throw my pc out the window because the nerves i got doing it.

No number of lines, ....
...I coded all of my plugins in notepad....in fact I did a lot of things in notepad.
Also to get the line number use Ctrl+G. That's also a nifty way to skip around based on line numbers.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-24-2010 , 02:17   Re: Good programming habits
Reply With Quote #68

Notepad++ is also fine for coding.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
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 12:06.


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