News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Making a Mod Questions

Started by The Wizard, August 18, 2013, 08:07:05 AM

Previous topic - Next topic

The Wizard

Hello:

I have a few questions that are not covered under making a mod and I would like to know the official position on these questions before I possibility go an do a lot of unnecessary work.

Questions:

1. - If you have say 20 or more template files should they be keep separate, or should they be combined into one big template file?
      Note: If they were combined were talking about 3,000 lines of code.

2. - If you have say 20 or more source files should they be keep separate, or should they be combined into one big source file?
      Note: If they were combined were talking about 3,000 lines of code.

3. - If you had say 250 $txt definitions should they be put in the "Modifications.english.php" file, or should a seprate php file be created, and
      if so where would you put it?

Thanks

Wiz




emanuele

Quote from: The Wizard on August 18, 2013, 08:07:05 AM
1. - If you have say 20 or more template files should they be keep separate, or should they be combined into one big template file?
      Note: If they were combined were talking about 3,000 lines of code.
SMF has 51 templates ranging from 42 up to 3000 lines of code.

20 templates are quite a bit, so the first question you should ask yourself is: am I sure I need so many?
Remember you can re-use code, so if two templates are the same except for a couple of strings of text, you can use the same and make it so the text changes depending on what you are doing (obviously that's an example based on something I know nothing about).

Then, the second question could be: do they have a reason to stay each in their own file?
Take in consideration that what could be considered "good practice" is to group things that belong to the same "action" (please note action may refer to a sub-action in case of the admin panel), or at least to meaningfully connected actions.

Quote from: The Wizard on August 18, 2013, 08:07:05 AM
2. - If you have say 20 or more source files should they be keep separate, or should they be combined into one big source file?
      Note: If they were combined were talking about 3,000 lines of code.
Same as above.

Quote from: The Wizard on August 18, 2013, 08:07:05 AM
3. - If you had say 250 $txt definitions should they be put in the "Modifications.english.php" file, or should a seprate php file be created, and
250 is quite a bit again, I would create a new file. Easier to maintain and less troubles installing/uninstalling things.

Quote from: The Wizard on August 18, 2013, 08:07:05 AM
      if so where would you put it?
Not sure what you are asking here.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.


The Wizard


Matthew K.

Kind of building on top of what ema already said.

Thousands of lines of code in one file is not a bad thing - I do it quite frequently. It's better to have all similar functions and such in one file, at least from my experiences.

As for the language strings...most definitely put them in your own file, I typically do that with all of my modifications no matter the size to keep things organized, you'll always know where my resources are (at least for the most part). I put mine in a subdirectory of languages such as: ./Themes/default/languages/my-modification/main.english.php or something along those lines.

Advertisement: