d11wtq wrote:arborint wrote:Looks good. I will need to actually use it and look through the code to give any real comments.
One thing I would recommend is to rename you classes in PEAR / Zend Framework style naming. It is the standard these days -- like it or not -- and it makes autoload easy.
class Dmail
class Dmail_SMTPConnection
class Dmail_SendmailConnection
Files:
Dmail.php
Dmail/SMTPConnection.php
Dmail/SendmailConnection.php
I've always had my own naming convention of classname.class.php

Class names themselves use the camelback style wording. I'll name them like you say if/when I SF this. Before I ever stick this on SF I'd like to add some of the extensions that were mentioned such as templating for emails and command-response logging in various formats.
Doh! Just realised I've completely neglected to sort out the email caching thingy....

I personally say PHP/Zend naming convention isn't as clear as it could be and for a few reasons not optimal...
I always do the following:
class.myname.php
module.myname.php
html.myname.php
...
File names are all lowercase with no characters but 0-9a-z and '_'
A hard lesson learned when I switched from classic ASP years ago to PHP and uploaded my files to a *nix server...
My file names were in windows style MyDocument.pdf but in HTML the links followed a more *nix feel in that mydocument.pdf where all file names were lower case...
When I loaded my web page and tried it only to find none of the pages worked as they did on my desktop...I became irate...only later to finally learn Apache was case-sensitive...
Also I avoid spaces as they cause some funny looking characters to appear in URL's so my dad once said...expressing his concern...
So I figured I would forever avoid that by simply using a '_' instead SPACE...
I also prefix every *module* with it's type so you get:
class.myname.php
html.myname.php
I do this because when I work with classes and templates and languages files, etc...
I can quickly dertermine which file is which in my IDE by looking at the first prefix on any file...
And the order...it's obvious...
class = Because thats what it is
name = Name of the class or module, etc
ext = Always PHP
As for class naming...
Thats easy as well...
If your going to develop software in a language derived from the mother of all languages C++ you might as well follow it's convention as it makes sense...
CMyClass - The C indicates class whereas
IMyClass - Indicates an interface
TMyClass - Indicates it's a template and so on...
I personally throw in a lower case x between the C and the name just to clearly seperate what is what...
This is handy when your working in VS IDE where your class browser can be listing 2,000 classes, templates, Interfaces, etc...the ability to quickly find the *class* as opposed to the Template is always nice
As for members, I use Hungarian notation, minus basic types and prefix everything with 'm_' which indicates this variable is without a dought a member and *not* a local variable or global...
So:
m_arrNames says this "member" is an array of names...
In PHP some might argue 'm_' is unnessecary because you *must* explicitly use the
this pointer to use members, which tells you right away it's an member of the object not a local or global...
I argue...ok fine...but at least using 'm_' distinguishes without a dought that you are using a member
variable NOT a member
function.
Besides...C++ developers know what they are doing, so you might as well follow those in the know as opposed to those that don't know
Global variables I use the same notation but instead of a 'm_' I use 'g_'
Only in local parameters do I use the *nix style of naming variables...where I use small case seperated by '_' but still follow a type_description convention...
$arr_names <= nice and easy on the eyes...I choose this because you spend most of your time writting function code, so I figured local variable names should be easiest to write and read...
This way I can always tell where data is coming from, from inside a function without having to determine if it's a global, member, etc...
I never understood not do I like PEAR style of naming...
HTML_Crypt
That tells me nothing...is it a class or a function or perhaps even a strange define/constant...
As it's indutry standard to use all UPPERCASE_NAMES for constants...
This has been my experience in every language I have spent time learning...
Although I agree with capitalizing acronyms, I feel those are best left for class name prefixes, ideally seperate by underscore
CxMySexyClass_HTML
You camel case the name and it's clearly a class not an interface and the confusion of uppercase letters is removed using the '_' to clearly seperate from a constant...as the very first character tells you it ain't a constant but a class...
Anyways, I've never understood some naming conventions other than...it's personal taste...which is fine, because programming is as much an art as it is a science...
You should have seen my conventions a few years ago...with VB, C++, Pascal, Assembler and COBOL experience...my code always looked like 40 people wrote it when in reality it was only me
But these are my arguments towards a naming convention...with quantifiable reasons to do so...
In the end though, dude...you write how you wanna write...thats part of the art behind programming...artistic creativity...take that away and you just might loose your interest in programming...
I also wanted to note...I use the 'x' between the C and the class name because it helps keep names clear, especially when the class name also starts with a C
Like: CClown looks more practical as CxClown
Cheers
