Talk:Java Programming/Conventions
On rendering the code
This page encourages you to use the <source lang="java"> tag, but I think it would be a better idea to use the {{Java}} instead.
With the source-tag:
for(int i=0; i<10; i++) {
System.out.println("Hello!");
}
With the template:
![]() |
for(int i=0; i<10; i++) {
System.out.println("Hello!");
}
|
If you don't like those little computer screens then the template can be changed, and it would then change the looks of every piece of code in the book if the template was used. Without a template it's really troublesome to ever change the looks of the code again even if we'd want to. The template is already in use in many pages, so to unify the looks of the code samples either a) the template needs to be edited to look like the plain version achieved with just the source-tag, or b) all code examples need to be changed to use the template. Or we can do both. But the first priority should probably be on changing those code examples where neither method is used, and I vote for changing them to use the template. ZeroOne (discuss • contribs) 21:31, 15 May 2012 (UTC)
I agree with ZeroOne, the source tag doesn't offer the flexibility that the java template does. I will update this page accordingly. --Mattylaws (discuss • contribs) 13:18, 11 August 2012 (UTC)
- We can't use the
{{java}}
template as it is since||
is a part of the Java language (OR). I think we will have to type the<source/>
manually... I have almost proofread all the book and I tried to make the book homogeneous. Unfortunately, I have discovered this page only now. Ftiercel (discuss • contribs) 20:08, 26 November 2012 (UTC)
Code conventions
We should agree on some code conventions. I suggest we go with the official Java code conventions and write
![]() |
if (foo == bar) {
// do stuff
} else {
// do other stuff
}
|
instead of, for example, this:
![]() |
if( foo == bar )
{
// do stuff
}
else
{
// do other stuff
}
|