Seperating functions? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Seperating functions? (
/showthread.php?tid=489899)
Seperating functions? -
seanny - 24.01.2014
I have a question, should I put my functions, enums and defines into their own .pwn/.inc files like below?:
pawn Код:
#include "../files/enums.pwn"
#include "../files/defines.pwn"
And what are the benefits and downsides?
Re: Seperating functions? -
Misiur - 24.01.2014
There is ongoing disccusion in Discussion subforum -
https://sampforum.blast.hk/showthread.php?tid=356764
Benefits are quite simple - better separation than single .pwn blob, more control when using VCS like git, easier search for specific things. Read ****** post there though - usually you shouldn't group by types, but by modular functionality - so car specific things in one file, player specific things in other one.
Re: Seperating functions? - Patrick - 24.01.2014
Benefits - Much neater code.
- Easier to track errors/warnings.
-
Downsides- Compilation time (loading and locating all .pwn and .inc files)
So far that is all I know, but I suggest you doing
separate .pwn files because its much more neater and easier to track errors and warnings.
More Information:
https://sampforum.blast.hk/showthread.php?tid=356764
Re: Seperating functions? -
MP2 - 24.01.2014
Quote:
Originally Posted by ******
- By code type: With this method you put variables in one file, defines in another, hooks in another, dialogs in another, etc... This is completely useless split as it means the code to do one thing is still split between multiple files. You also loose any benefits of separation you could get by using static functions and variables.
- By feature: With this method you have your streamer in one file (hooks, variables, API etc), your vehicles in another, your police job in another, your admin system in another, etc... This is called "separation of concerns" and is programming basics!
|
Re: Seperating functions? -
iZN - 24.01.2014
No downsides, and to be honest, good scripters would script like that.
Re: Seperating functions? -
seanny - 24.01.2014
Okay I made my decision, I'll convert my current scripts over to this method and any future projects will also use this method.
L&A