Extending core classes
I have found it absolutely useful to extend any API class you ever use. For example JFile, JText, JRequest, JWatever. I usually create special file that I load in second line in admin.mycomponent.com. Why? Because later you probably will need to do some extra operations.
And yet you do not need to declare every function you use. Just extend the class. My file looks like this:
<?php class myFolder extends JFolder{} class myRequest extends JRequest{} class myError extends JError{} // and for example class myFile extends JFile { function upload($src, $dest) { // and here you can add the code return parent::upload($src, $dest); } } ?>
The above example shows class that extends JFile core joomla class. See, now you can set default upload directory or check for maximum upload size that can be part of component public configuration. You can process file to check for viruses, create thumbnail if it is image or whatever.
May be that is not best example for area of application but this is best practice for sure. See also how it is greatly applicable for automatic creating of language file during development or for example this.
<?php class myError extends JError{ function raiseWarning($num, $text) { // Log Error //alert admin $sub = "Important Error"; // extend text. More vlues can be added like user ID id // loged in, request url or any other that can help. $text .= "User IP: ".$_SERVER['REMOTE_ADDR']; // and more... $hdr = "From: Robot <robot @ sire . com>"; // and more... return parent::raiseWarning($num, $text); } } ?>
Then to alert admin on errors just num your error more the 1000.
Sure you like it :)

+1 (209) 800 1209