Seperating functions?
#1

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?
Reply
#2

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.
Reply
#3

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
Reply
#4

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!
Reply
#5

No downsides, and to be honest, good scripters would script like that.
Reply
#6

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)