Coding efficiency
One of the things I am very interested in as of late, is coding efficiency. What do you do to increase your coding efficiency? Do you use specific tools or tricks?
I am going to go ahead and give away some of my secrets in hopes of helping others (and maybe to pick up some additional tricks).
My Development Environment
I currently do all my development on my laptop. It is nothing special, a fairly old Toshiba Satellite laptop (I plan on upgrading soon). I run Ubuntu as my operating system of choice. I have a local LAMP setup for coding in the rare circumstances that I do not have the Internet available or I do not want to VPN into my development network.
For my editor I use the free Komodo Edit. It has all the tools I like to use such as code snippets, shortcut keys, syntax highlighting, etc. I even have it reading a local copy of Drupal to help increase my efficiency by providing information on Drupal specific functions. This helps save me from having to go to Drupal.org too often. Nothing against Drupal.org of course, it just saves me time not having to look up functions I do not use often enough to commit to memory.
I use BZR for version control and keep all my projects hosted in a private launchpad branch. I have been looking to switch over to GIT recently, not because I am unsatisfied with BZR, but only because I have been hearing good things that I would like to try out myself.
I use MySQL Query Browser for working with Mysql. I prefer this over using PHPmyadmin but it still leaves a lot to be desired. I am always on the lookout for a better Mysql querying tool for Linux based systems, but MySQL Query Browser does what I need it too.
I always keep a command line open for running Drush commands on my Drupal sites that I am developing on, as well as to add/commit things to version control.
I generally have two browsers open at all times, usually Firefox and Chrome. I keep myself logged in as an Admin account on my Drupal sites in one of the browsers and use the other for testing. I use firefox extensions such as Firebug and the Web Developer Toolbar, and also know my way around Chrome's Developer Tools.
I have Meld diff viewer installed on my system for the rare occasions I need to view complicated changes. I like it because it lets me compare differences in entire directories. I use it occasionally to view entire module changes since it is able to recursively scan the entire module directory and report any differences.
Code snippets
When I am coding I re-use code snippets heavily. I have some of these set as hot keys and others in my toolbox in Komodo edit (only a click away). My most used snippet is probably for debugging.
print('<pre>'.print_r($node,1).'</pre>');
I then change the $node variable to whatever I need to see additional debug output for. Here are some more of my Drupal 6 specific code snippets. I haven't had the time to convert these over to Drupal 7, but I am sure I will as I have more time to focus on Drupal 7 module development.
Database result set loop
while ($result = db_fetch_object($results)) { }
Common Drupal hooks
/** * Implements hook_install(). */ function hook_install() { //if using any db tables drupal_install_schema('module_name'); //if setting any variables variable_set('var_name', 'variable'); } /** * Implements hook_uninstall(). */ function hook_uninstall() { //if you need to delete variables variable_del('var_name'); //if using db tables drupal_uninstall_schema('module_name'); } /** * Implements hook_schema(). */ function hook_schema() { $schema['db_table'] = array( 'description' => 'Description', 'fields' => array( 'serial' => array( 'type' => 'serial', 'not null' => TRUE, 'description' => 'description', ), 'datetime' => array( 'type' => 'datetime', 'not null' => TRUE, 'description' => 'description', ), 'varchar' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'description', ), 'int' => array( 'type' => 'int', 'not null' => TRUE, 'description' => 'description', ), ), 'primary key' => array('serial'), 'indexes' => array( 'another_field' => array('another_field'), ), ); return $schema; } /** * Implements hook_theme(). */ function hook_theme($existing, $type, $theme, $path) { return array( 'theme_callback' => array( 'template' => 'template', 'arguments' => array( 'arg1' => NULL, ), ), ); } } /** * Implements hook_init(). */ function hook_init() { drupal_add_css(drupal_get_path('module', '[mod-name]') .'/[css-path].css'); } /** * Implements hook_menu(). */ function hook_menu() { $items = array(); $items['path'] = array( 'title' => t('title'), 'description' => t('description'), 'page callback' => 'callback', 'page arguments' => array('args'), 'access arguments' => array('args'), 'file' => 'file', ); return $items; } /** * Implements hook_nodeapi(). */ function hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { //print('<pre>'.print_r($node,1).'</pre>'); } /** * Implements hook_cron(). */ function hook_cron() { }
I have many more that I occasionally use, however these almost always make it into my day to day coding in some way.
What do you use to help with your software development efficiency? Let me know in the comments.



Discussions
As an alternative to having
As an alternative to having two browsers open one could use incognito mode, private browsing or whatever it's called.
Komodo Edit Setup
How can I setup Komodo Edit so it can "read a local copy of Drupal to help increase my efficiency by providing information on Drupal specific functions".
Follow these steps
I think you should be able to get it setup by following these steps:
That should get you the core Drupal code to display in an autocomplete format. For example, when you start typing "drupal_goto" in a PHP file, it should pop up the information on the drupal_goto() function.
Let me know if that works for you.
Thanks for the comment.
mysql client
you may want to try navicat for your work with the database;
it is not free, but it really speed up your work and it runs under ubuntu;
Post new comment