should people skip lines between commands in a mod template?

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Swizec
Former Team Member
Posts: 1701
Joined: Mon Mar 10, 2003 9:42 pm
Location: Slovenia
Contact:

Post by Swizec » Sun Dec 04, 2005 7:22 pm

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.

User avatar
GPHemsley
Registered User
Posts: 1475
Joined: Fri Apr 18, 2003 3:12 am
Location: Long Beach, NY
Name: Gordon Hemsley
Contact:

Post by GPHemsley » Sun Dec 04, 2005 7:30 pm

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.

User avatar
Ptirhiik
Registered User
Posts: 7411
Joined: Mon Jan 06, 2003 10:36 pm
Contact:

Post by Ptirhiik » Sun Dec 04, 2005 8:23 pm

Bad habbits come quick, and make longer to drop, but that has never been an argument :).

Blankety Blank Man
Registered User
Posts: 881
Joined: Wed Mar 30, 2005 3:54 am

Post by Blankety Blank Man » Tue Dec 06, 2005 1:28 am

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.

wGEric
Former Team Member
Posts: 8805
Joined: Sun Oct 13, 2002 3:01 am
Location: Friday
Name: Eric Faerber
Contact:

Post by wGEric » Tue Dec 06, 2005 2:08 am

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.
Eric

Post Reply

Return to “[2.0.x] MOD Writers Discussion”