Page 2 of 2

Posted: Sun Dec 04, 2005 7:22 pm
by Swizec
Ptirhiik - RPGnet-fr wrote: I still don't get the point "it is more readable" : really, I don't think so, at contrary : if you don't know if you have to consider a linefeed because it is before or after a block, you can be sure there will be mistakes, as at least there is non-obvious interpretation. The more I consider a template with exta linefeed, the less I figure how a user can do the right move at first shot.


I think those empty lines show what's the actual code and what the MOD template more destinctivly than just the # characters. Also looking at continous code is an eyesore, to me atleast, I mean, do you code without any linebreaks anywhere? I hope not.
Also, I don't know why, but I feel that copy pasting code that is enclosed in empty lines is easier than no empty lines. To be honest, I've installed your MODs by hand before and it has happened to me on several occasions that I pasted three actions with their respectful code where just one set of code should be.

Posted: Sun Dec 04, 2005 7:30 pm
by GPHemsley
For what it's worth, whenever I write a MOD, I usually like to use a line break to denote groups of instructions. That means there's never an unneeded line break after a FIND action, but always after the last modification action related to that FIND action.

For example, an excerpt from one of my MODs:

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
modcp.php

#
#-----[ FIND ]------------------------------------------
#
# Around line 1096
#
		obtain_word_list($orig_word, $replacement_word);
#
#-----[ AFTER, ADD ]------------------------------------------
#

// Begin Topic Type MOD
		$topic_types = get_type_info( FALSE, TRUE );

#
#-----[ FIND ]------------------------------------------
#
# Around line 1096
#
		$sql = "SELECT t.*, u.username, u.user_id, p.post_time
#
#-----[ IN-LINE FIND ]------------------------------------------
#
p.post_time
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
, tt.*

#
#-----[ FIND ]------------------------------------------
#
Essentially, there's an ├Žsthetic line break only right before the OPEN and FIND actions. Any other line break is or should be included in the actual code.

A good example of how I do things.

Posted: Sun Dec 04, 2005 8:23 pm
by Ptirhiik
Bad habbits come quick, and make longer to drop, but that has never been an argument :).

Posted: Tue Dec 06, 2005 1:28 am
by Blankety Blank Man
MOD Template Actions has 3 example codes with more than one action: the first code segment under "The INCREMENT Action", the second code segment under "The INCREMENT Action", and the first code segment under "The IN-LINE FIND Action". Only the first of the three does not skip lines as Ptirhiik suggests we all do.

The MOD Template which all newbie MODders (and probably even some veterans) are most likely using as a... MOD... Template... (hance the name!) shows the spaces before each action.

I think that having an empty line before each action makes it look nicer, but then that may just be me looking at the MOD Template... and most of the MODs in the database.

Posted: Tue Dec 06, 2005 2:08 am
by wGEric
I'm going to reply to this with my feelings now. There is no standard so this shouldn't be taken as one.

When I write a MOD, I usually skip a line between actions. This is so that the template is easier to read. I'm not caring about the spacing in the php file because most people that install the MOD won't be looking at the code.

I haven't created any MODs that are the size of Ptirhiik so I have never had to support one but I can guess that he has had to look at code quite often and it helps to have the spacing right.

Although if the person used EasyMOD to install the MOD (assuming that EasyMOD does the spacing right), then you can assume that the code is in the right place. Rarely does EasyMOD make a mistake with editing if the install file has been written correctly. Installing by hand is where those mistakes would be made and you can't assume that the person will follow the spacing exactly. When I am installing by hand, I ignore the white space before and after the code in the install intstructions and add my own spacing in the actual file.

IMO setting a standard would be creating more problems than it solves.