Yii Framework Forum: if curly bracket - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

if curly bracket Rate Topic: -----

#1 User is offline   compact_corpse 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 24-May 11

Posted 27 July 2012 - 11:51 AM

I just switched from doing this:

if(condition){
     //stuff
}


to this:

if(condition)
{
     //stuff
}


and I LOVE IT! I just wanted to let somebody know...
0

#2 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 27 July 2012 - 12:26 PM

Is this troll bait? :lol:

I favor curlies on their own line for C++, but oddly enough, I've grown to like the first way as it seems to look neater for PHP...
Strange, isn't it?
"Less noise - more signal"
0

#3 User is offline   compact_corpse 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 24-May 11

Posted 27 July 2012 - 12:46 PM

View Postjacmoe, on 27 July 2012 - 12:26 PM, said:

Is this troll bait? :lol:


No seriously.
I usually end up adding an empty line if I do it the first way anyway, and now I feel like my code has been cleaned up sooooo much.
0

#4 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 358
  • Joined: 23-July 09

Posted 27 July 2012 - 05:16 PM

Yii's style is the second method... plus the awful "no brackets" which I detest (except on single line).

I have not bothered to break out of my years long habit of the first method, except perhaps for method declarations (Yii influence)... anything inside the method still has my usual way...

I think first method looks better, takes up less space and is more readable.
We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

#5 User is offline   compact_corpse 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 24-May 11

Posted 27 July 2012 - 06:26 PM

View PostBackslider, on 27 July 2012 - 05:16 PM, said:

Yii's style is the second method... plus the awful "no brackets" which I detest (except on single line).


I agree with the "no brackets" - they are the bane of my coding existence!
0

#6 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,346
  • Joined: 17-January 09
  • Location:Russia

Posted 27 July 2012 - 06:40 PM

Yii2 will use K&R.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
1

#7 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,165
  • Joined: 05-January 12
  • Location:Morocco

Posted 27 July 2012 - 07:35 PM

K&R is cool (although I didn't know it has a name :D)
0

#8 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,045
  • Joined: 16-February 11
  • Location:Japan

Posted 27 July 2012 - 09:18 PM

@bennouna
http://en.wikipedia....ki/Indent_style

I'd prefer Allman style.
(The discussion on coding style is very much fun, as long as it doesn't flame up to be a religious war. :D )
0

#9 User is offline   compact_corpse 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 24-May 11

Posted 28 July 2012 - 12:23 AM

Good link on indent style. I now know that I'm an Allman Stylist.

Ewww, imagine using Whitesmiths style. Sick.
0

#10 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 358
  • Joined: 23-July 09

Posted 28 July 2012 - 03:02 AM

View Postsamdark, on 27 July 2012 - 06:40 PM, said:

Yii2 will use K&R.


Coolies.... have been using it for years... slightly corrupted now by Yii, but will be easy to slip back into what I am accustomed to.

Any idea when we can get a peek at Yii2?
We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

#11 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 28 July 2012 - 07:16 AM

I was Allman all the way until a few years ago.
Now I'm K&R-ish.
So it sounds great that Yii will follow the latter convention. :)
"Less noise - more signal"
0

#12 User is offline   twisted1919 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 634
  • Joined: 23-October 10
  • Location:Romania

Posted 28 July 2012 - 08:18 AM

View Postsamdark, on 27 July 2012 - 06:40 PM, said:

Yii2 will use K&R.

Wait, what ? Why is that ? one of the reasons i choose yii in the first place was the coding style, why do you change to K&R which i personally(and many others) don't like it ?
I prefer the Allman style, which looks better. With k&r, nested structures looks like shit, too hard to follow.
Shouldn't this be a pool at least so that we have something to say about ?

I just see myself wasting tone of time correcting the Gii generated code, this is a real bummer...
0

#13 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 28 July 2012 - 09:16 AM

Since it's already using K&R what's the problem?
The only change will be that it will be consistent. :)

I agree that the generator could use customizable templates, or at least have some options (spaces/tabs/etc).
"Less noise - more signal"
0

#14 User is offline   kiran sharma 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 492
  • Joined: 21-May 11
  • Location:India

Posted 30 July 2012 - 03:40 AM

i m using Allman style... ::)
Thanks,
Kiran Sharma.
1

#15 User is offline   Ivica 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 315
  • Joined: 25-May 11

Posted 25 October 2012 - 05:47 AM

I also prefer Allman style, it is more readable, and easy to pair open and close brackets without IDE help.
Zurmo: Yii Powered Open Source CRM
zurmo.org
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users