• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Suggestion] Get away from those single file gamemodes
#6
(2019-06-05, 09:29 PM)Pinch Wrote:
(2019-06-01, 05:24 PM)Manyula Wrote: Even if you compel people to write modular scripts, everyone has an individual take on "modular" - at least when it comes to Pawn, imho. And, as far as I can see, this is due to a couple of reasons:



  1. People get confused because there is no uniform approach to modular programming in Pawn and they're afraid to make things wrong.

  2. People think that due to the increased length of the script when modularizing the gamemode, this somehow negatively affects performance, readability and their ability to find things in their gamemode.

  3. People get confused as to how to break things down and which order to include them in. They think that if two or more systems interact or rely on each other, they may as well merge them into one file.


Bottom line is, these people need to be taught, and that's a community effort. There's a need for a first and foremost SIMPLE approach to modular programming in Pawn. Here's how I do it:


  • Hooks of natives are included on the very top of the main script.

  • Systems are broken down into two files:

    1. Data Getters/Setters to access the data?(if necessary)

    2. Implementation (functions and callbacks)

  • In case some data is needed in a file that was included after the file that accesses it (and this forcing a reparse), I just forward the particular function in the file that tries to access it.




I'm always afraid that I won't call function correctly or just forget to call it cuz I have bad habbit of fast writing and I'm kinda dyslexic so I have problem there, that is the only reason why I prefer single file more, but I'm doing my best to get used to modularized way



Don't worry too much about that, it's all about learning from the right place. If you join our discord you will find many people there that will help guide you in writing much better code. We can help you in becoming a better programmer in general, it's what we do ;)



Also don't let your disability stop you, I suffer from Autism, Dyspraxia and HDHD, and I too once thought it was impossible to improve, but with the help of people from the discord, I have improved a lot and that has helped with me diving into other programming languages.



Keep pushing yourself to do better :)
Remember to always refer to J0sh as `J0sh...`



@ Networks/Servers

San Andreas Gaming Network (Owner/Founder)

San Andreas Gaming (Owner/Founder)

Grand Theft Cop's n Robber's (Owner)

Britannia Roleplay (Owner/Founder) [Retired]

Alpine RP (Owner/Founder)

Aluminium Network (Maintainer) [Disbanded]

AlphaDM (Tech Support) [Disbanded]



# Services

forum.open.mp (Forum Manager) (Formerly Burgershot.gg

open.mp (Member)



~ Languages/Frameworks

Pawn, C, C, C#, Javascript, Typescript, Lua, Python, Go, Rust, PHP, SQL,

Angular, React, Vue, Svelte, Laravel, Rocket
  Reply


Messages In This Thread
RE: Get away from those single file gamemodes - by JustMichael - 2019-06-05, 09:34 PM

Forum Jump: