tags:

views:

176

answers:

8

Is it safe to have single letter class names like A, B, P, etc?

+10  A: 

Why should it be unsafe? You may use them, if you want. It only is discouraged, because single char class names aren't very descriptive...

Maybe you want to give the class a normal name but let the user import it with a short alias?

use Some\Long\But\Descriptive\Classname as A;
nikic
Thanks, I believe they'll be descriptive in the context of the application..
Click Upvote
+1  A: 

Safe, yes. Readable, no.

nukefusion
In other words, `safe != smart`
Joel Mueller
+1  A: 

There's no reason why it shouldn't be, but it's more useful to give your classes a meaningful name

EDIT

Link to PHP naming guide

Mark Baker
+1  A: 

Yeah there is nothing stopping you except for the confusion factor.

dewalla
+4  A: 

It's interpreter-safe. But it may not keep you "safe" from fellow programmers who have to support it :)

Out of curiosity, what would be the compelling reason for that? I assume there must be one.

David
They are representing html tags such as `<b>`, `<p>`, etc
Click Upvote
How about Btag, Ptag
FarmBoy
Or BoldElement, ParagraphElement, etc. Maybe shorten them a bit, but the HTML tags themselves represent something to which the class names can be more descriptive.
David
+1  A: 

only safe if it's a class that communicates with no other by the same name

stillstanding
+17  A: 

No.

Your future self will build a time machine for the sole purpose of slapping you for writing such unreadable code. And then, a paradox will result, and all of reality as we know it will be destroyed.

Paul Nathan
best answer, lol
Click Upvote
A: 

You should never give anything such awful names.

http://www.objectmentor.com/resources/articles/Naming.pdf

edit: on second thought, lets purposefully give things the wrong name, for example, a name mutator method could be setAge. This will make our code even harder to follow and ensure jobs for all time!!