I recently ported my old module Password Require, which allows password protecting any form in Drupal, to Drupal 7. This module was originally created for my presentation at the Florida Drupal Camp in 2010, as an introduction to module development.
It is an example of how little code you need to add useful functionality to Drupal. But of course after you add an administration UI and try to make it generally easier to use the code starts to add up, not tons but more than a good first module example.
So as a learning tool for those who want to start learning module development for Drupal I have trimmed this module down to 36 lines of code(not counting the comments).
The video above demonstrates the functionality of the module as it appears on Drupal.org and the video below gives an explanation of how the trimmed down code works. I have also attached the simplified version of the module to this post.
The module demonstrates the use of hook_form_alter and using a validation function to validate the input of an individual form element. It consists of only 2 php functions.
As an example of the difference between coding a contrib module for Drupal.org and a custom module for a client, the shortened version of the module is probably closer to what I would make for a client who needed the custom functionality for their site(if the module didn't already exist). Often a client is not going to want to pay for the time it takes a make more generalized module that will fit other needs beside their own.