Databug

Friday, May 19, 2006

Latest Demo

Added a random color function:

Array
(
[first_name] => Sly
[last_name] => Eller
[user_name] => seller
[full_name] => Sly Eller
[gender] => m
[email] => seller73003@hotmail.com
[zip] => 19026
[city] => Pilgrim Gardens
[state] => PA
[phone] => (484) 555-0109
[fav_color] => #9d61af
)


Script:

$User = new Databug();
$User->fav_color= $User->get_random_color();
$DATA = $User->get_data();
$DATA['fav_color'] = $User->fav_color;
print_r($DATA);

 

phpDocumentor Commenting Style

I'm a vigil (somewhat anal) commentor. A good part of the art in coding for me rests with neat, well formatted, and consistent comments. Over the last couple years I've developed my own style, idiosyncratic perhaps, but neatly formatted and easy to pick up at a glance. (You can see examples of it on my design blog.)

For the sake of this project, however, I am making a concerted effort to use the phpDocumentor style. I'm slowly getting the hang of it. There is extensive online documentation, but I'd trade it all for one complete demo file. (I must have someone on my drive somewhere.)

phpDocumentor organizes comments around DocBlocks. For a class, I count four key DocBlocks.

1. The Page Block
/**
* Package PackageName
* desciption of package here --
*
* @package PackageName
* @author Name
*/


2. The Class Block
/**
* Class ClassName
*
* NOTES
* notes here
*
* @package PackageName
* @author Name
* @version
*/


3. The Variable Block
/**
* @access public
* @var string
*/


4. The Method Block
/**
* Short description of method
* Usage: $result = $_O['data_obj']->Method($string, $integer, $float, $ARRAY);
*
* @access public/private
* @param string $string
* @param integer $integer
* @param float $float
* @param array $ARRAY
* @return string $return
*/

 

Thursday, May 18, 2006

Zip Code and Phone Methods

I've added methods to generate a random city, state, and zip pulled from a flat file I adapted from US census data. I also have a flat file of select US area codes, useful for generating phone numbers. The area code list includes values for the second three phone number digits (what's the word for that?), but I have a 'safe' flag that automatically sets this to '555' to help avoid publishing real phone numbers.

Both methods can be keyed to state and thus can be coordinated for greater verisimilitude. I have a function somewhere for generating a street name (using the last name database). I'll have to integrate that in order to generate a full street address.

A sample generated data array:

Array
(
[first_name] => averil
[last_name] => malcolm
[user_name] => amalcolm
[full_name] => averil malcolm
[gender] => f
[email] => amalcolm11041@sbcglobal.net
[zip] => 38018
[city] => Cordova
[state] => TN
[phone] => (901) 555-6329
)

 

Wednesday, May 10, 2006

Simple Demonstration

Array created by databug object:

Array
(
[first_name] => waylin
[last_name] => byron
[user_name] => wbyron
[full_name] => waylin byron
[gender] => 2
[email] => wbyron_7bd2@hotmail.com
)

 

Databug Blog Established

Databug is a PHP class I've been working on. It creates random user profiles. Sounds lame, but I've found it useful for testing and haven't really seen anything like it.

I'll publish the source code as soon as I've cleaned it up and made it presentable. This blog will demonstrate its usage and may include some notes on its development.