We often use $class_object->class_procedure or self::class_procedure in PHP OOP. While reading aloud your code, how do you read out these conventions?
Asked
Active
Viewed 1,682 times
14
Peter Mortensen
- 30,738
- 21
- 105
- 131
Ruturaj
- 143
- 5
-
Curious, in what cases do you need to spell it? Cannot think of a case from my experience I ever needed that. – zerkms Jan 16 '13 at 03:48
-
3he wants to know how you would say it in conversation – iedoc Jan 16 '13 at 03:52
-
1@iedoc: and I asked in what cases you need to use it in conversation? I'd just say - you call object's method. That's enough to get what I mean – zerkms Jan 16 '13 at 03:55
-
yeah, that's exactly how i answered, haha, but it looks like not everyone agrees – iedoc Jan 16 '13 at 03:56
-
4apparently people believe you should say "class object arrow class method" in conversation? I would probably laugh if i heard someone say it like that – iedoc Jan 16 '13 at 03:59
-
5"Tiny rocket". Maybe that's =>, I can't remember. – John Brodie Jan 16 '13 at 04:03
-
@JohnBrodie `return ':)';`. – Alix Axel Jan 16 '13 at 04:06
-
@JohnBrodie Tiny rocket!! ha ha ha. – Ruturaj Jan 16 '13 at 15:45
4 Answers
9
-> is the object operator. Typically called the arrow in conversation. If I were reading the code, I might say:
class object arrow class method
:: is the static resolution operator. I doesn't read as well in conversation. The docs say double colon. I might say:
class colon colon static method
Note: Reading code aloud can be awkward regardless of how you name syntax. Furthermore, it will depend greatly on your audience. I am sharing what I've heard, seen used in books, or found in the docs.
Jason McCreary
- 71,546
- 23
- 135
- 174
-
Yeah, I think I will take this. This goes much in tune with .Net convention where we read "txtText.Text" as "txtText dot Text"... straight as it comes. How about self::proc though? Should I read out "self procedure proc"? – Ruturaj Jan 16 '13 at 03:50
-
-
2I have never heard someone say "class object arrow class method" in conversation – iedoc Jan 16 '13 at 03:58
-
1Thanks. Now this will help me in long run... in seminars, presentations and group discussions etc. :-) – Ruturaj Jan 16 '13 at 03:59
-
1@iedoc: I actually may think of a use case for that: let's suppose you have a secretary in your office and you want her to fix something in your code straight on the production server. So you call her and start telling what to put to the file, while blocked by traffic jam. – zerkms Jan 16 '13 at 03:59
-
-
Just answering the question. Don't hate. At least I didn't break out the *spaceship*, `<=>`. :) – Jason McCreary Jan 16 '13 at 13:04
4
You could use their token names:
->(Object Operator AKA Arrow)::(Paamayim Nekudotayim OR Double Colon OR Static Object Operator)
Or just say:
[static] method X of object Y
Alix Axel
- 151,645
- 95
- 393
- 500
-
1
-
-
why not call `+` math operator then? "Object operator" doesn't express well what it does. – zerkms Jan 16 '13 at 03:50
-
@zerkms: That would be the addition or plus operator. I don't follow the logic. – Alix Axel Jan 16 '13 at 03:51
-
well, `+` is a `number operator` then. `->` is used with objects ---> then it's object operator. `+` is used with numbers ---> then it's number operator. "object operator" isn't expressive enough. Something like "object members access operator" would be better – zerkms Jan 16 '13 at 03:53
-
+ for a concise answer. However, I agree with @zerkms that you missed *arrow*. – Jason McCreary Jan 16 '13 at 03:56
-
@JasonMcCreary: I use arrow all the time, but I was aiming for something more formal. Edited. – Alix Axel Jan 16 '13 at 03:58
1
Class object's class procedure
Self's class procedure
Peter Mortensen
- 30,738
- 21
- 105
- 131
iedoc
- 2,266
- 3
- 30
- 53
-
"class object's class procedure" O_o --- "class object's" --- is redundant. Object always created as a class instance. "class procedure" -- there is no such term in php. – zerkms Jan 16 '13 at 03:52
-
the class contains the procedure, so you use "'s" to represent possession. It's how i learned it in school, and how i've always said and heard it said – iedoc Jan 16 '13 at 04:04
-
2
-
@zerkms: ...plus `::` doesn't necessarily represent a call to [it]self. – Alix Axel Jan 16 '13 at 04:15
1
For the static version (self::class_procedure), keep it simple.. "double colon"
Brad
- 159,648
- 54
- 349
- 530
Nick Parsons
- 8,377
- 13
- 48
- 70