Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

When there are no arguments, we have these two options:

$obj = new MyClass;

vs.

$obj = new MyClass();

I always pick the former, just because.

Any thoughts?

share|improve this question
3  
Duplicate from stackoverflow: stackoverflow.com/questions/6830401/… –  Asaf Aug 31 '12 at 21:27
    
And also: stackoverflow.com/questions/3873111/… –  Jack Sep 1 '12 at 1:43
4  
You can't duplicate questions cross-network. Specific, answerable questions about coding standards/conventions are on-topic here. –  user8 Sep 5 '12 at 12:45
    
However, given the existence of the question on Stack Overflow you have to wonder why felt the need to ask it here. –  ChrisF Sep 5 '12 at 12:56
1  
@ChrisF Oh I'm sorry. Next time I'll just read the entire internet to avoid bothering you with my "duplicate". –  ChocoDeveloper Sep 6 '12 at 9:22

2 Answers 2

up vote 7 down vote accepted

Include them. It isn't much extra work and it won't confuse people that don't know that leaving them off the parenthesis is an option.

share|improve this answer
1  
+1 I didn't know you could leave them off. It would have confused me! –  MrMisterMan Sep 5 '12 at 13:03

Include them; with PHP, you want to be as specific and unambiguous as you can.

share|improve this answer
5  
In ANY programming, you want to be as specific and unambiguous as you can. –  Jeremy J Starcher Sep 1 '12 at 0:25
1  
@JeremyJStarcher Though this isn't really ambiguous, just confusing for people who don't know about this optional syntax. –  ChocoDeveloper Sep 1 '12 at 4:17
    
Yes, it's not really possible for one to be ambiguous in a programming language, as far as the computer is concerned, because it still knows what to do. Rather I meant that dropping little bits of unnecessary syntax here and there is a slippery slop of special cases that results in code that simply takes longer for other humans, or your future self, to understand. –  Eliot Ball Sep 1 '12 at 10:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.