Closed (fixed)
Project:
Mailman Groups
Version:
6.x-1.1
Component:
Code
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
19 Dec 2008 at 22:32 UTC
Updated:
8 Oct 2009 at 17:59 UTC
Jump to comment: Most recent file
Attached patch cleans up the code of this module. It doesn't seem to follow any coding standard - this patch applies Drupal core's coding standard to it.
While being there, debugging code has been removed and some logic improved.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | mailman_groups.patch | 26.97 KB | sun |
| mailman_groups.clean-up.patch | 25.4 KB | sun |
Comments
Comment #1
andy inman commentedThanks for that, though I would suggest that "messy" code is a matter of opinion :)
For example I think:
.. is a lot *less* messy than...
... *standards* of course are another matter, but I do have some :)
Comment #2
avpadernosun's patch is good as (indeed) rewrites the code following the Drupal coding standards, which have been thought to make reading the code easier, but also to make possible to maintain the code with less effort. Just to make an example, the last array index of an array is suggested to be followed by a comma to avoid problems when extending the array content.
In Drupal, following the coding standards is seen positively, and it shows that the maintainer of a project cares of doing a module in the Drupal way.
Similar coding standards are suggested in other projects, and they are normally required to be followed from who creates code for the specific project (which could be jQuery, in example). In some cases, the code is not even accepted, if the coding standards are not used.
Comment #3
andy inman commented@Kiam I do understand and accept the value of coding standards in general, and Drupal's coding standards in particular. The problem comes when Drupal's coding standards are in conflict with my coding standards (which incidentally, have been established longer than Drupal's, though of course that doesn't make them any more valid.)
Here are a few examples:
/* style comments are reserved for "commenting-out" blocks of code, or for blocks of pure text (no code). // comments should be used in all other cases.
// Comment at end of line of code (on same line) short comment should almost always be used (so one per line) and suitably indented. This allows reader to read easily down the right-hand part of the page (comments only) and so follow the program logic and flow without needing to read the code.
Comments which describe a block of code should be punctuated by three periods, e.g: Loop through array... Comments which describe a single line or operation should have only one or no period, or where more applicable ! or ? The comment after an if() would normally be punctuated with ?
Single line if and loop structure ... should be used for trivial structures, especially with if() when dealing with exception conditions. In those cases, tab or minimum of two spaces should be after the if () etc.
Example:
for ($i = 0; $i < 1000; $i++) { // Loop through the data...
if ($numbers[$i] == 0) return ERROR_INVALID_DATA; // Exception, zero is invalid!
do_something_with($numbers[$i]); // Do something with each value.
// Trivial loop:
for ($n = 0; $n < 10; $n++) $output .= '.'; // Output some dots.
if ($time() >= LUNCHTIME) { // Is it lunch-time?
/***
confirm_hunger(); // Make sure we are hungry!
show_debug_message('working very hard.'); // Show debug message.
***/
buy_sandwiches(); // Procure sustenance .
break; // That's all for now!
}
}
The // comments above would normally be tabbed to the same column, allowing the reader to read easily through the comments. This tends to conflict with Drupal standard of a maximum line length.
In summary, I do not ignore Drupal's coding standards (any more than they ignore mine). It's not about not caring to do things "the Drupal way", simply a need to trade-off with my own efficiency (I don't code as a hobby, so my efficiency is important to me). Maybe what I need is an easy way to convert code to "Drupal standard". Does anyone know of a "beautifier" type of script that would do the trick?
Comment #4
andy inman commentedComment #5
sunActually, I'm sick of such debates. In the meantime, I could as well use a template for my response.
Comment #6
avpadernoIn other words, you use the drupal standards when they don't conflict with your personal standards, which means that you don't follow the Drupal standards because the standards must always be followed, not just when you (impersonal you) want to follow them.
Comment #7
andy inman commentedThanks to sun for valuable input. I will check out the coder module.
There is a well-known quote, I'm not sure who it's attributed to: "The great thing about standards is that there are so many to choose from."
Anyway, I suggest that this thread is well and truly off-topic and should end. I would appreciate confirmation that the supplied patch works without side effects, and I will happily implement it before uploading the module source here, which I've been meaning to get round to for ages.
Comment #8
avpadernoThe patch works, and it doesn't not introduce any bugs.
Comment #9
sunIofC already uses this improved code. Note that #349285: Call-time pass by reference error needs to be applied first.
I'm not sure whether anyone should use this module though. The code is distributed separately, and bugs are not fixed. (This and the other issue were opened 7 months ago.)
Comment #10
avpadernoThe code does not seem written for Drupal; I saw a call like
sprintf(t())that no Drupal programmer would write as the second function already support the placeholders.EDIT: I meant the module code, not the code provided in the patch; I am sorry I have not been clearer.
Comment #11
sunNote that I'd be open to take over this project. Although I have a lot of other obligations (that are more important to me), I can see that people who implemented this module on their sites are now stuck in nirvana - which is the worst that can happen. The way it is currently, the d.o project shouldn't have been created in the first place.
Just let me know. I have sufficient privileges to alter the project.
Comment #12
andy inman commented@sun
Thanks for the offer. I have been very busy with www.ksfiomdepositors.org, but that's now winding down and I will have a little more time. The reason why I didn't originally upload here via CVS was some weird problem I had with CVS on my machine at that time, now fixed. So, I'm doing it now, with patches applied.
Comment #13
andy inman commentedsun's patches committed.