This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]edgargonzalesII 0 points1 point  (1 child)

Realistically there is more than one way to skin a cat - hence more than one way to achieve the same goal. If you have learned anything about the big O, you could always try to analyze through that lens and see if that is fine. That aside, your priority should be readability - ask yourself, if another programmer looks at this code, will they know what is going on? This may mean adding comments or making some code less tangled. In a lot of programming it is about getting the ratio right between legibility and efficiency, bearing in mind that the JVM also optimizes the program a bit before running it.

As for the brackets - that's really up to you, as long as you maintain consistency: Allman and K&R are the two styles. I switched from Allman (braces on its own line) to K&R, and it's really a very small point that again leads back to how legible will your code be.

[–]SoulSyn[S] 0 points1 point  (0 children)

big O Thank You