May 24, 2011

Modules should be simple. The D7KISS

It's been 6 months since I joined Seed Software as a Development Manager, and since day one I've been getting more and more involved with the Drupal community, and since day one I've been trying to push as many new development towards using D7 (I just love it), but off course, module availability is a problem, and even when the most popular modules already have a D7 release and most of them are stable, there is always that forgotten module that is stuck in D6 and its last release was back in 2009 (or so). Flying solo it would have been an impossible task to take those modules and upgrade them, but working in a development company gives me the time and the resources to do so (most of the times).

So what with that? Well, you see, I'm pretty sure I'm going to start a pledge similar to the D7UX, but this is one is to keep modules simple, a temporary name would be D7KISS.

This year I've released two new modules, Maxlength JS and Entity Reference Field, both of them I tried to keep simple. Just enough code to work, but I didn't try to make them do everything. Instead sub-modules can be created that leverage their potential. This makes it stupid simple to upgrade them to D8, and so on.

As an example, we needed a location field module. Simple: You create a node (or entity, whatever) and you have a field where you set a location (or multiple ones) for that node (or entity, whatever). Two modules exist in D6 that could accomplish that, the Mapedelic Group (GMap Module + Location) and Google Maps Tools. The first one I just don't like, one simple reason for it: it doesn't use CCK in D6, and the D7 branch still doesn't use the field API. And the latter one, well, D7KISS is the exact opposite to what modules like Google Maps Tools do. I mean, it is not a bad module, I've used it in some D6 projects and it works pretty well for when you are setting a site using only the admin interface, as its admin interface and Views integrations is impressive, but it is unmaintainable:

  • 4143 lines of code just in the main .module
  • +54.000 lines of code (not including .module, .install and .info files)
  • 12 .module files.
  • 49 includes (.inc)
  • 35 javascript files (.js)

See my point? Who can work with that!

I am now a co-maintainer Geolocation Field module, it is a simple module, it gives you a field to store a latitude and a longitude, and by default 3 widgets, a "you type it if you know it", which is the least useful one (no one knows their latitude or longitude), a gmap widget where you click and that's it, location set; and one that uses the new Geolocatoin API (html5) like the one in D.O.; and for future plans we are going to store an address (with city, state, and so on).

So, yeah, modules should be simple unless, off course, it is views ;)

Comments