When is it time to write a module?

MamaGubs's picture

I have a "system" that I have built in Drupal 6 for tracking employee time off. I used actions, triggers and php snippets to get this all working. I have a form for creating a time off request, which launches an approval workflow and email notifications, and that ends with (if the time actually taken) a record that records that time, and reports that HR uses for determining vacation and sick balances.

However, as I add more and more features and logic, I begin to wonder if this wouldn't be better as a module, simply because of the sheer number of triggers and actions, and the growing complexity of those php "snippets".

So the question here is, what are appropriate guidelines for determining when a "system" should be a module? I know this is somewhat of a nebulous question, but I feel like I could pretty much go on forever with what I'm doing, but also realize that at some point nobody following me will ever be able to figure out how it all hangs together.

It'd be great to hear what prompted some of the experts here to write modules, particlularly in the light of the power of actions and triggers, as well as modules like rules and workflow.

Joyce

Groups:
Login or register to post comments

Maybe not "when..."

davidwatson - Tue, 2010-03-30 19:16

I think it's more a matter how to achieve encapsulation than when to write code, IMO. For instance, I package each of my discrete features in a module so I can set up all of the snippets/config programmatically (the Features module helps with this). Only if there's something that truly hasn't been done yet will I write any new code, and even then I'd decouple that from any implementation-specific details. Does this mean more modules? Yes, but they're also more portable, too - and using exports it often means less actual custom code. That way, when the problem comes up again, you don't have to hack at anything you've already written.


More thoughts...

MamaGubs's picture
MamaGubs - Tue, 2010-04-27 17:20

Thanks for the reply, c.ex.

Now that I'm a few more weeks into writing my module (an application module for corporate vacation, sick and other time off), I have more concrete thoughts on the subject, for what it's worth.

  1. There seem to me to be two types of modules - those that extend the ability to build applications (e.g. date, views) and those that are applications in themselves (e.g. ubercart). When I scan through available contributed modules, it seems that the vast majority are of the first type. This leads me to tentatively conclude that application type modules are not necessarily making their way to contributed modules (though I hope to add my time off tracker at some point). Site builders are most likely not making "encapsulated" modules - they're building their functionality within Drupal, maybe creating a module to hold some complex actions or menus, but not making the module "whole" so that it can be added to any site. This makes sense, as most site builders are very busy just getting the sites built and working correctly, then need to get on to the next piece of work. Also, obviously, a lot of site building is pretty specific to its application and not of general interest.

  2. Since this is my first major piece of functionality since I've launched our departments intranet in Drupal, I realized that I have to develop this functionality on a test site. So that, of course, brings up the question of how to port my new functionality (consisting of a tabbed menu, a few new content types, several actions, etc.) to the production web site. Well, I could bring everything over piecemeal, or I could write all the pieces into a .module and .install, which is what I've decided to do.

Conclusion: Write a module for an application if there's a lot going on in it and/or you want to share it with others. Write a module when you're extending the functionality of drupal core or contributed modules.


Enterprise group might be interested in your project

mlangfeld's picture
mlangfeld - Sun, 2010-09-12 13:43

I wonder if you might find support or even collaborators in the Enterprise group. Your evolving module sounds like it might be of interest there, or in the Open Atrium world, if it could be made into a feature. Congratulations on going ahead with it.

Best, Marilyn

Best, Marilyn