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.