Page 3 of 3
Posted: Sun Apr 02, 2006 9:14 pm
by Christopher
Gambler wrote:I do not consider myself a newbie, but it's a tough question. My best guess would be that "i" is taken from sigma notation of Reimann sum.
You are definitely on the right track. They are from general Summation Notation that, like many other mathmatical notations, worked its way into early languages -- specifically Fortran (remember its FORMula TRANSlation).
Posted: Sun Apr 02, 2006 9:15 pm
by d3ad1ysp0rk
Hockey wrote:Like the mysql_query() or addslashes()
One OR the other please...not both...
I frequently did (and sometimes still do) the add_slashes() thing because thats how I know PHP to work...then get an error at runtime because add_slashes() doesn't exist.
I'm not sure why you all hate that so much. I think it sorta makes sense (seperating the word 'mysql' from the actual function that it's doing (query). I almost think of mysql_ as a bunch of functions that deal with the database mysql, where add_slashes wouldn't make sense because slashes isn't a function that deals with the add class or anything like that.
If they were to ever put add_slashes into php, I'd hope they'd keep addslashes and such as well.
Posted: Sun Apr 02, 2006 9:23 pm
by John Cartwright
d3ad1ysp0rk wrote:Hockey wrote:Like the mysql_query() or addslashes()
One OR the other please...not both...
I frequently did (and sometimes still do) the add_slashes() thing because thats how I know PHP to work...then get an error at runtime because add_slashes() doesn't exist.
I'm not sure why you all hate that so much. I think it sorta makes sense (seperating the word 'mysql' from the actual function that it's doing (query). I almost think of mysql_ as a bunch of functions that deal with the database mysql, where add_slashes wouldn't make sense because slashes isn't a function that deals with the add class or anything like that.
If they were to ever put add_slashes into php, I'd hope they'd keep addslashes and such as well.
Agreed. Arn't all usages of *_ in php prefixes for similar functions?
ie..
mysql_*
preg_*
ereg_*
socket_*
Posted: Sun Apr 02, 2006 9:41 pm
by Roja
Hockey wrote:I wanna know what works for you and why...if you can even justify your answer...
Most of the items on my coding guidelines includes a brief explanation of why I chose them. ie, I choose spaces over tabs because of the difficulties in pasting between putty sessions causing diff to show changes where there aren't any.
Posted: Sun Apr 02, 2006 10:20 pm
by Christopher
I agree with d3ad1ysp0rk (how do you pronounce that?) and Jcart that PHP's naming is not as bad as the complainers claim. The core group even did a survey of the whole haystack/needle complaint and I think only found one or two that were backwards. Plus, the PHP naming is very human is its evolved conisistency. And names like substr() are more core functions than extensiions like mysql_*().
Maybe we should change the constructs to loop_for(), loop_while(), conditional_if() and conditional_switch()?

Posted: Sun Apr 02, 2006 10:22 pm
by alex.barylski
Roja wrote:Hockey wrote:I wanna know what works for you and why...if you can even justify your answer...
Most of the items on my coding guidelines includes a brief explanation of why I chose them. ie, I choose spaces over tabs because of the difficulties in pasting between putty sessions causing diff to show changes where there aren't any.
I'm looking into it
I never even thought of formalizing indices though...gotta say that was pure genius...totally gave me a solid idea...
I frequently write deeply nested for loops (nothing of practical nature yet - mostly experimental) and I always start with "i"
The it dawned on me, after reading your guidelines...it would make sense to start at "a" and count from there...totally prevents re-using a counter variable...which anyone can tell you can make for bad times and hard to find bugs
Anyways, I much appreciate that link to your specs...
Cheers

Posted: Sun Apr 02, 2006 10:25 pm
by alex.barylski
Jcart wrote:d3ad1ysp0rk wrote:Hockey wrote:Like the mysql_query() or addslashes()
One OR the other please...not both...
I frequently did (and sometimes still do) the add_slashes() thing because thats how I know PHP to work...then get an error at runtime because add_slashes() doesn't exist.
I'm not sure why you all hate that so much. I think it sorta makes sense (seperating the word 'mysql' from the actual function that it's doing (query). I almost think of mysql_ as a bunch of functions that deal with the database mysql, where add_slashes wouldn't make sense because slashes isn't a function that deals with the add class or anything like that.
If they were to ever put add_slashes into php, I'd hope they'd keep addslashes and such as well.
Agreed. Arn't all usages of *_ in php prefixes for similar functions?
ie..
mysql_*
preg_*
ereg_*
socket_*
As far as I know all extensions use that technique...procedural namespacing...but thats not the point I was getting at...
The fact that extensions use that convention and some core functions don't...doesn't make for a very argument in that PHP is already setting a standard convention...
You should use one or the other not both...in the procedural context anyways...
add & slashes are individual words...so they should follow suit and have a '_' between them

Posted: Sun Apr 02, 2006 10:33 pm
by John Cartwright
The _ represent an agglomeration of similar function libraries. It has nothing to do with number of words within the function.
I do partially agree that they should use one or the other, but they chose to take a different approach at it.
The bottom line is that it is actually consistant, even though you may not agree on what naming convention used.
Personally, I hadn't even though about it until this topic, and really... does it really matter? If you hate the underscores so much write a function wrapper

Posted: Sun Apr 02, 2006 10:36 pm
by Ambush Commander
write a function wrapper
Agreed. Especially with the database functions. You could even right a Regexp object modeled after JavaScript's Regexp wrapper.
Posted: Mon Apr 03, 2006 12:27 am
by alex.barylski
Jcart wrote:The _ represent an agglomeration of similar function libraries. It has nothing to do with number of words within the function.
I do partially agree that they should use one or the other, but they chose to take a different approach at it.
The bottom line is that it is actually consistant, even though you may not agree on what naming convention used.
Personally, I hadn't even though about it until this topic, and really... does it really matter? If you hate the underscores so much
write a function wrapper 
Not worth it...I'd rather put up with inconsistencies...but to be used as an example of a standard to follow Ihave a hard time with...
Clearly if there is a problem with any given technique or convention...there is room for improvment...is all I was saying

Posted: Mon Apr 03, 2006 12:47 am
by John Cartwright
but what I tried to say erlier is that just because it doesn't work for you doesn't mean it doesn't work for the rest of the population (l
ots of doesn't in that sentence)
I know there are standards that we all hate, but they arn't there for us to like them or look pretty -- they are there to make our lives easier through consistency.
Stupid standards ..

Posted: Mon Apr 03, 2006 1:28 am
by Christopher
To answer the original question:
Hockey wrote:So please, if someone has already answered with I use CAMELCASE because...
I use camel case because almost all the code that I use from other sources (whether Java, PHP, Python, Ruby) uses camel case (initial caps) for class names and camel case (initial lowercase) for method names -- and I have much more important things to even think about than why I would want to vary from such a widely used standard as that. Experence has taught me that I have yet to come up with anything related to software development that is better than what those smart guys who write books recommend.
Posted: Mon Apr 03, 2006 2:15 am
by timvw
arborint wrote:Ambush Commander wrote:Well, there's some wiggle room. Like bracing.
Yes. I see code with both this
And this
and I never hear anyone say anything one way or the other. Most of the common styles have some trivial variations that really aren't worth noting.
As long as you're using braces it shouldn't make any difference... Because a decent editor (formatter) can easily toggle between the styles and display them in whatever way you like them (btw, if you add an else switch to the statement there are even more variations possible

)