Coding Style
Moderator: General Moderators
I hear what you're saying. I chose a way and do it that way most of the time to until I get to work.maniac9 wrote:First of all, I don't understand what you people mean by C-style and Java-style, since they follow the same syntax, and work in both languages...I do mine the same in all languages...
And there is the reason right there. When bodies of code start to grow in size, importance, or both, then conventions become important. And as a result, the need for being able to name and identify these conventions.
Personally, I think something is suspect with what we are calling C or Java style. Java get's it's style from C. So does C++ and Perl. When you get right down to it, what Kriek labeled as the Java style is what K & R themselves used years before Java was ever an Oak (If you know what I mean). To me the idea that Java would even have a style named after it is kinda obscene.
Cheers,
BDKR
Hehe... True.To me the idea that Java would even have a style named after it is kinda obscene.
The question about how we code are a neverending subject. I prefer the (obscene hehe) 'Java-Style' way, and I think that thats the way I see it mostly. But as I said in another thread, I personally change the way I code to whom I code with.
At home, 'Java-Style'. At work, C-style.
Doesn't matter that much, as long as the idents and overall readability/comments is there.
-
onefocus99
- Forum Newbie
- Posts: 16
- Joined: Tue Oct 07, 2003 11:09 pm
- Location: Hamilton Ont., Montreal, Chibougamau,... PQ, Victoria BC, now Alberta Canada
Don't they all aim (in some way) to give you easy to understand code flow?devork wrote: c-style gives you easy to understand code flow
Really, when you get right down to it, it's just an organizational issue. Norhing more and nothing less. How are things arranged, or even name (uderscores, studly caps, hungarian notation), will all help somebody to some degree. Beyond that, with the exception of python, ...
Code: Select all
fucntion shoot_gun(&$player)
{
fire_weapon(&$player->weapon);
register_hit(&$player); /* If the player actually hits something */
}Code: Select all
fucntion shootGun(&$player) {
fireWeapon(&$player->weapon);
registerHit(&$player); /* If the player actually hits something */
}And that's ultimately the 'it'. Python, Ruby, VB all look incredibly bland and just mushed together becuase there are no brackets, braces, semicolons, or parenthesis. For those of us with a foundation in a C like syntax, this is maddening at first. The only visual clues you have as to what's going on are things like indentation, white space, and new lines.devork wrote: it depends from which background you have more experience
c-style will be easy for c lang ppl and same for other.
What if it's a n00b3 and he/she doesn't indent consistently. At least with a C based language there are still the braces. But in this case, Guido (the developer of Python) was smart and at least requries (at the engine level) indentation for code blocks. Having the indentation helps immensely.
Cheers,
BDKR
- Fredix
- Forum Contributor
- Posts: 101
- Joined: Fri Jul 18, 2003 2:16 pm
- Location: Wehr (Eifel) Germany
- Contact:
I voted for C-Style because I !!!HATE!!! what you call Java style, really!
I use that C-style in any language that has such block delimiters and even in pascal I handle those key words "BEGIN" and "END" as if they would be brackets.
Writing brackets in one column gives you the fastest overview over your code, while using "JAVA-Style" you need to _search_ the start of the code block.
For me there is no space for any other argumentation as I could not imagine that someone can read JAVA Style better.
I'm not concerned about VB so much because I hardly find anyone really using this a lot.
I use that C-style in any language that has such block delimiters and even in pascal I handle those key words "BEGIN" and "END" as if they would be brackets.
Writing brackets in one column gives you the fastest overview over your code, while using "JAVA-Style" you need to _search_ the start of the code block.
For me there is no space for any other argumentation as I could not imagine that someone can read JAVA Style better.
I'm not concerned about VB so much because I hardly find anyone really using this a lot.