Mule : Coding Style
This page last changed on Aug 22, 2006 by holger.
This page contains CheckStyle rules to be applied to any code committed to the Mule project. Coding StyleHaving a constant coding style accross the whole project has proved ToolsWe take, as a reference tool, Checkstyle and you will find relevance Checkstyle also has a maven plugin which could be dropped in the ConventionsJavaDoc commentsThe JavadocType, JavadocMethod accompained with JavadocStyle should <!-- http://checkstyle.sf.net/config_javadoc.html --> <module name="JavadocMethod"/> <module name="JavadocType"/> <module name="JavadocVariable"/> Naming conventionsAll the standard naming convention should be enforced, maybe just the <!-- http://checkstyle.sf.net/config_naming.html --> <module name="LocalFinalVariableName"/> <module name="LocalVariableName"/> <module name="MethodName"/> <module name="PackageName"/> <module name="ParameterName"/> <module name="StaticVariableName"/> <module name="TypeName"/> <module name="MemberName"/> <!-- <module name="ConstantName"/> --> ImportsWe should AvoidStarImport even if it makes java files longer is a source <!-- http://checkstyle.sf.net/config_import.html --> <module name="AvoidStarImport"/> <module name="IllegalImport"/> <module name="RedundantImport"/> <module name="UnusedImports"/> SizeJust some checks for the sake of sanity files longer the 2000 lines and <!-- http://checkstyle.sf.net/config_sizes.html --> <module name="FileLength"/> <module name="ParameterNumber"/> WhitespaceI think this are just part of the default Sun coding convention. <!-- http://checkstyle.sf.net/config_whitespace.html --> <module name="EmptyForIteratorPad"/> <module name="NoWhitespaceAfter"/> <module name="NoWhitespaceBefore"/> <module name="OperatorWrap"/> <module name="TabCharacter"/> <module name="WhitespaceAfter"/> <module name="WhitespaceAround"/> Modifier orderFollow the order of the Java Language specification and avoid redudant
<!-- http://checkstyle.sf.net/config_modifiers.html --> <module name="ModifierOrder"/> <module name="RedundantModifier"/> Block checksThe braces should be around every block just like there should be no if () <\!-\- [http://checkstyle.sf.net/config_blocks.html] \--> <module name="AvoidNestedBlocks"/> <module name="EmptyBlock"/> <module name="NeedBraces"/> <module name="LeftCurly"> <property name="option" value="nl"/> </module> <module name="RightCurly"> <property name="option" value="alone"/> </module> I don't agree with this one, I think the placement of curly brackets is a matter of personal preference and either way can produce nice, readable code if the programmer uses a little aesthetic sense. CodingThis should be fairly usual even if I think that sometimes InlineConditionals <\!-\- [http://checkstyle.sf.net/config_coding.html] \--> <module name="AvoidInlineConditionals"/> <module name="DoubleCheckedLocking"/> <module name="EmptyStatement"/> <module name="EqualsHashCode"/> <module name="HiddenField"/> <module name="IllegalInstantiation"/> <module name="InnerAssignment"/> <module name="MagicNumber"/> <module name="MissingSwitchDefault"/> <module name="RedundantThrows"/> <module name="SimplifyBooleanExpression"/> <module name="SimplifyBooleanReturn"/> DesignTo enforce some encapsulation and keep up on some standard coding design which
<\!-\- [http://checkstyle.sf.net/config_design.html] \--> <module name="DesignForExtension"/> <module name="FinalClass"/> <module name="HideUtilityClassConstructor"/> <module name="InterfaceIsType"/> <module name="VisibilityModifier"/> MiscSome miscellaneous check could be added, like the ArrayTypeStyle and FinalParameter,
<\!-\- [http://checkstyle.sf.net/config_misc.html] \--> <module name="TodoComment"/> <module name="UpperEll"/> <module name="Translation"/> <\!-\- to the Checker \--> I've prepared a checkstyle.xml config file for Checkstyle which you can find attached here As usual feedback is more then welcome. Preferences for eclipseImportable preferences for eclipse are attached to this page. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
Document generated by Confluence on Oct 03, 2006 09:23 |