Source Style Guide?

So yea been hacking away, as I do. Just wondering if there is a official source style? I did a lot of commercial dev work in a previous life, and well I am use to sticking with one (20 years ago, prob got lots of Awesome habits now :wink: ), or using some filter that reformatted everything. Or whatever. Clearly i would just set it all up in eclipse.

Of course I stick to java conventions. But i am more talking about things like number of chars to a line, line wrap style. Bracket style etc.

Sorry if it somewhere obvious. I just canā€™t find anything. Google foo broken.

In general, we follow the standard Java conventionsā€¦ which includes bracing style, by the way. But there is some variation and some files donā€™t follow it. For changes to JME, Itā€™s generally frowned upon to change the formatting of a file just because you wanted to add something.

The good-old Java coding standard covers pretty much everything you mention.

If you contribute to JME, things definitely to never do:

  • never do the capital ā€˜iā€™ hungarian interface name thing. IFoo, IFruit, ISilly. This needlessly puts an implementation detail right in the name.
  • do not name local variables _foo, _bar, m_foo, whatever. foo, bar, is enough.
  • acronyms should be capitalized as words can camel cased. So HttpUdpIoAdapter instead of HTTPUDPIOAdapter. Even Sun started to get this one right later.

Otherwise, the only real advice is to be consistent.

1 Like

I just use the default NetBeans settings for Java formatting. Thereā€™s an option to format only changed lines which works really well. Unfortunately some of the older classes donā€™t follow these conventionsā€¦

I found it really funny that you (@pspeed) prescribe the usage of standard Java conventions, since you usually have this really special style with lots of whitespaces in function definitions and calls (between parentheses and arguments) that for the life of me I still havenā€™t been able to figure out, since it is quite non-deterministic (in some cases there are whitespaces, in others there are not, etc.). Also this style is not really consistent with what was there before, but probably already before it was not really stylized?

In any case, this is an open-source project, so I suppose there are as much styles as there are committers.
It would still be much nicer if we could have some widely accepted coding style, like @Momoko_Fan suggests. I personally use Eclipse default style (with spaces), but there are some differences I presume, which should be converged on. I suppose we could export the settings for the styling (I know Eclipse supports this, not sure about other editors) and let people use them. Possibly apply the styling to all currently available source code also.

I just want to provide constructive feedback and I donā€™t have any bad intentions or something, so please no hard feelings. :slight_smile:

Thank god. I hate the _bar local var thing. It is like everyone never heard of an IDE. It is not 1960s anymore! And even then, didnā€™t they have emacs :wink:

So yea went through the eclipse java convention, and it is not quite 100% per the ā€œcode styleā€ with tabs/spaces. I will use the built in java convention and you guys can let me know what ya thing a pull time :smiley:

Oh, yeahā€¦ tabs are evil. Spaces only for contributions.