What is better
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
In that specific example, both versions are equally horrible. Functions can have parameters. Use them.
Global variables are evil. Avoid whenever possible.
ok, than how about this:

Код:
///////1st example
new Msg[128];
public OnPlayerConnect(playerid)
{
     format(Msg, 128, "Some Text");
     SendClientMessageToAll(0x00FF00FF, Msg);
     return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
     format(Msg, 128, "Some Text");
     SendClientMessageToAll(0x00FF00FF, Msg);
     return 1;
}
and some other callbacks
or this:


Код:
///////2nd example
public OnPlayerConnect(playerid)
{
     new Msg[128];
     format(Msg, 128, "Some Text");
     SendClientMessageToAll(0x00FF00FF, Msg);
     return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
     new Msg[128];
     format(Msg, 128, "Some Text");
     SendClientMessageToAll(0x00FF00FF, Msg);
     return 1;
}
and some other callbacks with same variables inside: new Msg[128]...
Reply


Messages In This Thread
What is better - by AntonioCroatia - 17.05.2015, 17:11
Re: What is better - by Vince - 17.05.2015, 17:37
Re: What is better - by icra - 18.05.2015, 04:02
Re: What is better - by EBook - 18.05.2015, 05:09
Re: What is better - by AntonioCroatia - 22.05.2015, 12:53
Re: What is better - by AntonioCroatia - 23.05.2015, 14:57
Re: What is better - by Ghazal - 23.05.2015, 14:59
Re: What is better - by SickAttack - 23.05.2015, 15:04
Re: What is better - by AntonioCroatia - 23.05.2015, 15:04
Re: What is better - by SickAttack - 23.05.2015, 15:14

Forum Jump:


Users browsing this thread: 2 Guest(s)