|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
| View Poll Results: Coding Style | |||
| C-Style | | 12 | 54.55% |
| Java-Style | | 10 | 45.45% |
| VB-Style | | 0 | 0% |
| Voters: 22. You may not vote on this poll | |||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Coding Style
I've been meaning to poll you guys concerning coding style for awhile.
This mainly deals with control structures. C-Style PHP Code:
Java-Style (PEAR Coding Standard) PHP Code:
VB-Style (PHP Alternative syntax) PHP Code:
|
|
#2
|
|||
|
|||
|
C 4 me
![]()
__________________
-- Jason |
|
#3
|
|||
|
|||
|
Just for the record, there are several styles and probably more than I can find information about, but I just listed the two most popular being C-Style and Java-Style along with the disputed VB-Style that has stirred up so much commotion.
Allman-Style Named for Eric Allman, a Berkeley hacker who wrote a lot of the BSD utilities in it (it is sometimes called `BSD style'). Resembles normal indent style in Pascal and Algol. It is the only style other than K&R in widespread use among Java programmers. Basic indent per level shown here is eight spaces, but four (or sometimes three) spaces are generally preferred by C++ and Java programmers. K&R Style Named after Kernighan & Ritchie, because the examples in K&R are formatted this way. Also called kernel style because the Unix kernel is written in it, and the One True Brace Style (abbrev. 1TBS) by its partisans. In C code, the body is typically indented by eight spaces (or one tab) per level, as shown here. Four spaces are occasionally seen in C, but in C++ and Java four tends to be the rule rather than the exception. Whitesmiths Style popularized by the examples that came with Whitesmiths C, an early commercial C compiler. Basic indent per level shown here is eight spaces, but four spaces are occasionally seen. GNU style Used throughout GNU EMACS and the Free Software Foundation code, and just about nowhere else. Indents are always four spaces per level, with { and } halfway between the outer and inner indent levels. |
|
#4
|
||||
|
||||
|
Mine's a mixture of C & java style.. I just write the code and then go back later and clean it up..
![]() |
|
#5
|
|||
|
|||
|
Well, when I first started out... I used the C style... But having coded in Java for the last 2 years, I strictly use the Java style coding...
I find it easier to read, and less messy... Especially with having the { brace on the same line as the IF statement, as opposed to having it underneath.... But that's just a personal preference! This is a great thread... Kriek, where did you learn about all these different styles? They're quite extensive.
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#6
|
|||
|
|||
|
I learned to program in the 70's when structure was more rigidly imposed. I picked up PHP more by OSDN examples than from any formal text so I saw many different 'looks.' Personally, I like the braces on a separate line and a default indent of 4 or 5 spaces per level. For me any style is okay if it is consistent and readable.
Methods of applying commentary reduce readability more than the code style itself. Those little comment tags hanging onto the end of a code line are usually too splintered to be meaningful. They're like roadside litter. |
|
#7
|
|||
|
|||
|
I use C++ style! Teached by a great teacher I had! I still use it depply inspired by Borland's VCL code style!
After I made a couple of 'jobs' in Java I got the felling that that is the best code style (personal opinion)! I don't use it still! But probably will! One of the major subjects on the diference is not (to me) on the indentation or the controls structures but in one small detail! In C++ code style the class name begins with a capital letter and an instance of an object also begins with a capital letter! This raises a problem with is visible both on VCL and MFC: //class defenition - there's a need for the T (or C on MFC) class TCar { } //becuse of the intantiation of the class so it can hava a 'natural' name TCar Car; This doesn't happend with Java because class defenition and instationtion is done like: class Car { } Car car; regards |
|
#8
|
|||
|
|||
|
Java style for me. Just because it's vertically shorter, I guess.
I also like this style, because all the nested lines are beautifully aligned with their braces. It looks easier to read, but I haven't used it myself: PHP Code:
Something like that... Not sure what it's called. |
|
#9
|
|||
|
|||
|
ack!,...I hate that style,...
![]() |
|
#10
|
|||
|
|||
|
I'm starting a "Support the ternary campaign!"
PHP Code:
![]() |
|
#11
|
|||
|
|||
|
ack,..thats even worse
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Coding Style |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|