Ninjakreborn Posted July 31, 2011 Share Posted July 31, 2011 I have been programming for awhile. I have always had a specific style, but lately noticing with C++ and other languages it gets easier with another format....let me explain. DO you setup your brackets as below: function whatever () { // stuff if (whatever) { //whatever }else if { // whatever } } Or: function whatever () { if (whatever) { //Whatever }else if { //Whatever } } I have always found the second one ugly, but in most third party systems (and frameworks for that matter) I see the second one. What is your personal style/preference, and why. Quote Link to comment https://forums.phpfreaks.com/topic/243347-bracket-usage/ Share on other sites More sharing options...
Pikachu2000 Posted July 31, 2011 Share Posted July 31, 2011 I started out using the second one, and soon changed to the first one. I find it easier to read and match the closing brace with the opening part of the control structure. The second one just seems too disjointed to me. Quote Link to comment https://forums.phpfreaks.com/topic/243347-bracket-usage/#findComment-1249666 Share on other sites More sharing options...
remybink Posted July 31, 2011 Share Posted July 31, 2011 it makes no difference how you set up your style use the method which you like the best and can read easier. in your one example I layout like so to show relevance for me, also I separate with comments or symbols if code gets too messed up from constant changes to each his/her own function whatever () { // stuff if (whatever) { //whatever }else if { // whatever } } Quote Link to comment https://forums.phpfreaks.com/topic/243347-bracket-usage/#findComment-1249668 Share on other sites More sharing options...
Ninjakreborn Posted July 31, 2011 Author Share Posted July 31, 2011 Good, at least glad to hear someone agrees with me. I have seen so many frameworks use that ackward structure. I have always used the first method, but was curious what other people were using. I find it easier to read, easier to write, and all around cleaner. Only reason I started getting curious because now even doing C++ whenever I use a codeblocks automatic project, it always formats in the second method, it's a pain. Thanks for the feedback. I was curious what other PHPFreaks users were doing as far as format was concerned. Only reason I was curious at all was every framework I have ever seen and their listed "coding practices" always showed the second. Was starting to think I was missing something. Quote Link to comment https://forums.phpfreaks.com/topic/243347-bracket-usage/#findComment-1249669 Share on other sites More sharing options...
trq Posted July 31, 2011 Share Posted July 31, 2011 I (and my employer - which is lucky) use Zend's guidelines which is a PEAR derivative. http://framework.zend.com/manual/en/coding-standard.coding-style.html It's a mix of both of the above. Functions and classes are defined as: Quote Link to comment https://forums.phpfreaks.com/topic/243347-bracket-usage/#findComment-1249672 Share on other sites More sharing options...
Ninjakreborn Posted July 31, 2011 Author Share Posted July 31, 2011 Thanks for the link Thorpe. Will have a look. Haven't spoken with you in awhile, hope things are going well for you. Thanks again guys for the feedback. Quote Link to comment https://forums.phpfreaks.com/topic/243347-bracket-usage/#findComment-1249686 Share on other sites More sharing options...
voip03 Posted July 31, 2011 Share Posted July 31, 2011 I am using 2nd method, start 2004 till now I find that a 2nd method is clean and easy to find errors. But now days for CSS I am using the 1st method. Quote Link to comment https://forums.phpfreaks.com/topic/243347-bracket-usage/#findComment-1249703 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.