3 oct 2014 · This document contains Java coding standards to be followed by all BAE Systems Code Conventions for the Java TM Programming Language See http://findbugs sourceforge net/manual/anttask html for more details
Previous PDF | Next PDF |
[PDF] Java Code Conventions - Oracle
4 oct 1996 · Java Code Conventions September 12, 1997 For an example of a Java program properly formatted, see “Java Source File Example” on
[PDF] Code Conventions for JavaTM - Squarespace
Each Java source file should contain at most one public class or interface When private classes and interfaces are associated with a public class, put them in the
[PDF] JAVA CODING STANDARDS
4 mai 2002 · 0 Naming Convention standards 17 9 0 Variable Assignments 18 10 0 Standards for Classes, Interfaces, Packages, and Compilation Units
[PDF] Java Coding Guidelines Version 132 All code must follow best
Add JavaDoc to all of your code, including classes, methods, etc Follow the Java Coding Conventions from inventors of Java (see class page for document)
[PDF] JavaScript Coding Standards
3 jui 2019 · Chapter 3: Code Conventions for the JavaScript Programming JavaScript Coding Standards Version: 5 11-CO::1 ii 3/6/2019 3 9 7 eval is Evil It is heavily modified of course because JavaScript is not Java The long-term
[PDF] Java Coding Standards
31 mai 2019 · 5/31/2019 Java Coding Standards 3 3 Configure Code Style Scheme for Android Studio There is the Code Style Scheme xml file (“Google
Important Java Programming Concepts
general Java programming primer, but rather as a refresher and orientation Springer Nature Switzerland AG 2019 Coding conventions are guidelines for organizing the presentation of source The Unified Modeling Language Manual
[PDF] BAE Java coding standards
3 oct 2014 · This document contains Java coding standards to be followed by all BAE Systems Code Conventions for the Java TM Programming Language See http://findbugs sourceforge net/manual/anttask html for more details
[PDF] java code to retrieve data from database
[PDF] java code to retrieve data from database and display in table
[PDF] java code to retrieve data from mysql database
[PDF] java coding exercises online
[PDF] java coding in hindi
[PDF] java coding standards 2019
[PDF] java coding standards 2020
[PDF] java coding standards and best practices
[PDF] java coding standards and best practices pdf
[PDF] java coding standards checklist
[PDF] java collection ppt
[PDF] java collections beginners book pdf
[PDF] java collections hands on
[PDF] java collections interview questions pdf
Copyright © 2014 BAE Systems. All Rights Reserved.
BAE SYSTEMS is a re
gistered trademark of BAE Systems plcJava Coding Standards
Applied Intelligence
Application Services Practice
By Jack Dexter, Steven Bilotta, Peter Moore and Richard Molland03 October 2014
Document Reference : BAES AI-JavaCodeStd-1.2
68 pages including cover
BAES AI-JavaCodeStd-1.1 Page 2 of 68
Copyright © 2014 BAE Systems. All Rights Reserved.BAE SYSTEMS is a re
gistered trademark of BAE Systems plcVersion history
Version Date Author Action
1.0 24 Sep 2013 JD Issued.
1.1 25 Jul 2014 RJCM Revised for issue to Steve Cummins (Cambridge University)
1.2 03 Oct 2014 RJCM Incorporate feedback from Alastair Beresford
1.2.1 13/10/2015 SAC Identified optional items on annotated copy for Cambridge
University assessment.
Copyright statement
Copyright © 2014 BAE Systems.
All Rights reserved. BAE SYSTEMS, the BAE SYSTEMS Logo and the product names referenced herein are trade marks of BAE Systems plc. Other company names, trade marks or products referenced herein are the property of their respective owners and are used only to describe such companies, trade marks or products. BAE Systems Applied Intelligence Limited is registered in England & Wales under company number01337451 and has its registered office at Surrey Research Park, Guildford, England, GU2 7YP.
Permission is granted to copy and re-distribute this document for non-commercial purposes providing the source is acknowledged and the copyright notice above and this notice are reproduced.BAES AI-JavaCodeStd-1.1 Page 3 of 68
Copyright © 2014 BAE Systems. All Rights Reserved.BAE SYSTEMS is a re
gistered trademark of BAE Systems plcExecutive summary
This document contains Java coding standards to be followed by all BAE Systems AppliedIntelligence Java projects.
The code standards can be summarised as:
1. Code defensively - you must check all parameters to ensure they conform to the
expected (handled values).2. Handle all errors - do not swallow exceptions.
3. Think about security - defend your code from attack.
4. Think about performance - think how the code will cope with real datasets.
5. Consider the supportability of the code - log what's going on, put in good
comments, think about those developers who will work with code after you.6. Be consistent in code style - it doesn't actually matter where the curly braces go, as
long as they are consistent across the project.BAES AI-JavaCodeStd-1.1 Page 4 of 68
Copyright © 2014 BAE Systems. All Rights Reserved.BAE SYSTEMS is a re
gistered trademark of BAE Systems plcReferences
Mnemonic Document Details
[1] Title: Oracle Java Code Conventions Doc Ref: http://www.oracle.com/technetwork/java/codeconv-138413.html [2] Title: Geosoft Code Coding Standards Doc Ref: http://geosoft.no/development/javastyle.html [3] Title: Effective Java ™, Prentice Hall Doc Ref: http://my.safaribooksonline.com/book/programming/java/9780137150021 [4] Title: Exception Handling Best Practices in Java Programming Doc Ref: http://javarevisited.blogspot.co.uk/2013/03/0-exception-handling-best-practices-in-Java-Programming.html
[5] Title: Exception Handling Best Practices Doc Ref: http://www.onjava.com/pub/a/onjava/2003/11/19/exceptions.html [6] Title: Secure Coding Guidelines for the Java Programming Language Doc Ref: http://www.oracle.com/technetwork/java/seccodeguide-139067.html [7] Title: CERT Secure Programming Doc Ref: https://www.securecoding.cert.org/confluence/display/java/Introduction [8] Title: Java performance tuning, O'Reilly Media Doc Ref: http://shop.oreilly.com/product/9780596000158.do [9] Title: Code Conventions for the Java TM Programming Language Doc Ref: http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-135099.html#367
BAES AI-JavaCodeStd-1.1 Page 5 of 68
Copyright © 2014 BAE Systems. All Rights Reserved.BAE SYSTEMS is a re
gistered trademark of BAE Systems plcList of contents
Executive summary ............................................................................................................................. 3
References ........................................................................................................................................... 4
1. Introduction...................................................................................................................................... 7
1.1 Purpose
1.2 How to read the document ........................................................................................................... 7
1.3 Document Layout ......................................................................................................................... 8
1.4 Document control ......................................................................................................................... 8
1.5 Recommended further reading .................................................................................................... 8
2. Coding Standards on a Page (or three) ......................................................................................... 9
3. The Golden Rules .......................................................................................................................... 12
3.1Code defensively .......................................................................................................... 12
3.2Use Exceptions Correctly ............................................................................................. 13
For a full break down of the Exception standards refer to A.2 ......................................................... 13
3.3Focus on security ......................................................................................................... 14
3.4Consider performance in all the code you write ........................................................... 15
3.5Consistency in Coding Style and Naming Conventions ............................................... 16
3.6Make use of Tool Support ............................................................................................ 17
Appendix A.Common Java mistakes ........................................................................................ 18
Appendix B.Coding Standards .................................................................................................. 23
Code Defensively ......................................................................................................... 23
Exceptions .................................................................................................................... 25
Logging ......................................................................................................................... 32
Performance ................................................................................................................. 33
Miscellaneous ............................................................................................................... 35
BAES AI-JavaCodeStd-1.1 Page 6 of 68
Copyright © 2014 BAE Systems. All Rights Reserved.BAE SYSTEMS is a re
gistered trademark of BAE Systems plcAppendix C.Code Style Standards ............................................................................................ 38
C.1Code Files .................................................................................................................... 38
C.2Naming Conventions .................................................................................................... 39
C.3Specific Naming Conventions ...................................................................................... 43
C.4Comments .................................................................................................................... 49
C.5Layout ........................................................................................................................... 51
C.6White Space ................................................................................................................. 56
C.7Statements ................................................................................................................... 58
C.8Classes and Interfaces ................................................................................................. 59
C.9Methods ........................................................................................................................ 59
C.10Types ............................................................................................................................ 60
C.11Variables ...................................................................................................................... 60
C.12Loops ............................................................................................................................ 61
C.13Conditionals .................................................................................................................. 62
Appendix D.Useful tools ............................................................................................................ 65
C.14Find Bugs ..................................................................................................................... 65
3.6.2Checkstyle .................................................................................................................... 66
3.6.3PMD ............................................................................................................................. 67
3.6.4SonarQube ................................................................................................................... 67
3.6.5Cobertura ..................................................................................................................... 67
3.6.6JavaNCSS .................................................................................................................... 68
BAES AI-JavaCodeStd-1.1 Page 7 of 68
Copyright © 2014 BAE Systems. All Rights Reserved.BAE SYSTEMS is a re
gistered trademark of BAE Systems plc1. Introduction
This document lists Java coding recommendations common in the Java development community. The recommendations are based on established standards collected from a number of sources, individual experience, business requirements/needs, and suggestions given in [1] and [2].There are several reasons for introducing guidelines rather than just referring to the ones above. The
main reason is that these guides are far too general in their scope and that more specific rules need
to be established. Developers and code reviewers should be pragmatic in applying coding standards. This guide cannot possibly cover every code eventuality, so ultimately developers should ensure that their code is written in a way that maximises its readability and maintainability.1.1 Purpose
The purpose of this document is to capture the distilled wisdom that senior developers in Applied Intelligence have amassed over the years. They have made plenty of mistakes in their time and would prefer it if you didn't do the same. They want you to be creative and invent some nice new mistakes of your own and don't just repeat the ones they made.More formally, the document purpose is to:
Help programmers reduce probability of runtime errors in code.Improve readability and maintainability of code.
Deliver consistent, professional source code.
1.2 How to read the document
The following code standards are a guideline, a steer in the right direction. They are not an absolute
concrete rulebook that must be followed. The main reason to have these coding standards is so that the whole company has a common starting ground, and we fully understand that certain teams/projects will need to advance, amend or drop certain standards for historic, technology or preference reasons. Please feel free to do so, but what we do ask is that you are consistent throughout your project and that you share any standards or better ways of working with the wider community.BAES AI-JavaCodeStd-1.1 Page 8 of 68
Copyright © 2014 BAE Systems. All Rights Reserved.BAE SYSTEMS is a re
gistered trademark of BAE Systems plc1.3 Document Layout
The document is big. You won't read it all. To help ensure you read the bits that you should, the document is broken into 3 chapters and 3 appendixes. The main document provides a summary and a set of Golden Rules to follow. The, perhaps less exciting, detail is in the Appendices.The document structure is as follows:
Chapter 1 is this introduction;
Chapter 2 is a practical summary with the 'Coding Standards on a Page (or three)'; Chapter 3 gives the Golden Rules of successful, professional programming; Appendix A details some common Java specific mistakes to avoid;Appendix B details general coding standards;
Appendix C details code style and naming conventions you could/should use. In the appendix the standards are grouped by topic and each standard is numbered for ease of reference.Layout for each standard is as follows:
Ref#.Standardshortdescription
Code Example
1.4 Document control
This document is owned and controlled by the BAE Systems Applied Intelligence Application ServicesPractice.
The Practice welcomes review comments and updates. Please contact the Head of the Practice.1.5 Recommended further reading
In addition to this code standard, 'Effective Java: Second Edition' by Joshua Bloch is highly recommended reading and provides guidelines for writing efficient, well designed Java programs.BAES AI-JavaCodeStd-1.1 Page 9 of 68
Copyright © 2014 BAE Systems. All Rights Reserved.BAE SYSTEMS is a re
gistered trademark of BAE Systems plc2. Coding Standards on a Page (or three)
Opt - Indicates Optional Rule for
Cambridge Courses.
Opt Opt Opt Opt Opt OptMember
BAES AI-JavaCodeStd-1.1 Page 10 of 68
Copyright © 2014 BAE Systems. All Rights Reserved.BAE SYSTEMS is a re
gistered trademark of BAE Systems plc Opt O pt Opt Opt O ptO pt Opt O pt OptBAES AI-JavaCodeStd-1.1 Page 11 of 68
Copyright © 2014 BAE Systems. All Rights Reserved.BAE SYSTEMS is a re
gistered trademark of BAE Systems plc Opt Opt O pt O pt Opt O ptRemove all commented out code
BAES AI-JavaCodeStd-1.1 Page 12 of 68
Copyright © 2014 BAE Systems. All Rights Reserved.BAE SYSTEMS is a re
gistered trademark of BAE Systems plc3. The Golden Rules
These are the golden rules for successful, happy coding. Follow them!Or, at least, these are the rules that give you a good chance to write robust, secure, functionally and
non-functionally correct code, which is nearly as good.Some of these rules result in code that is "a bit boring" as it is not compact, complicated and clever.
Not boring, "good." Good code is well documented, well laid out and easy to understand for all. Goodquotesdbs_dbs14.pdfusesText_20