T
T
Tarasov Konstantin2014-03-05 19:20:36
Java
Tarasov Konstantin, 2014-03-05 19:20:36

How to properly place curly braces?

I understand that there is most likely no exact rule on this topic, but still, how would it be more correct to place brackets like this:

for (;;) {
//...
}

Or like this:
for (;;)
{
//...
}

This means not only in relation to for, but in general all places where brackets are placed.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Ruslan Kasymov, 2014-03-05
@saroff

Code style guidelines
In addition, we enforce the following code rules:
...
...
In general, it does not matter how you feel comfortable and do it. Modern IDEs can format properly. Well, or there are all sorts of beautifiers of the code.

N
niosus, 2014-03-05
@niosus

Pick one style and stick with it. The main thing is that you have the same style in all files and that it is convenient for your team to work with you, and for you with it.
As an example - google-styleguide.googlecode.com/svn/trunk/javagui...

N
nixischev, 2014-03-06
@nixischev

In my opinion, it's always best to do this:

foreach($elements as $element)
{
//code
}

Or (mostly used in views):
<?php foreach($elements as $element): ?>
<!--html code-->
<?php endforeach; ?>

It's much clearer, but that's just my personal opinion.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question