Java Code Conventions. September 12, 1997
|
|
|
- Theresa Robbins
- 9 years ago
- Views:
Transcription
1 Java Code Conventions September 12, 1997
2 Copyright Information 1997, Sun Microsystems, Inc. All rights reserved Garcia Avenue, Mountain View, California U.S.A. This document is protected by copyright. No part of this document may be reproduced in any form by any means without prior written authorization of Sun and its licensors, if any. The information described in this document may be protected by one or more U.S. patents, foreign patents, or pending applications. TRADEMARKS Sun, Sun Microsystems, Sun Microelectronics, the Sun Logo, SunXTL, JavaSoft, JavaOS, the JavaSoft Logo, Java, HotJava Views, HotJJavaChips, picojava, microjava, UltraJava, JDBC, the Java Cup and Steam Logo, Write Once, Run Anywhere and Solaris are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. UNIX is a registered trademark in the United States and other countries, exclusively licensed through X/Open Company, Ltd. Adobe is a registered trademark of Adobe Systems, Inc. Netscape Navigator is a trademark of Netscape Communications Corporation. All other product names mentioned herein are the trademarks of their respective owners. THIS DOCUMENT IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THIS DOCUMENT COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN; THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THE DOCUMENT. SUN MICROSYSTEMS, INC. MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THIS DOCUMENT AT ANY TIME. Please Recycle ii
3 June 2, Introduction Why Have Code Conventions Acknowledgments File Names File Suffixes Common File Names File Organization Java Source Files Beginning Comments Package and Import Statements Class and Interface Declarations Indentation Line Length Wrapping Lines Comments Implementation Comment Formats Block Comments Single-Line Comments Trailing Comments End-Of-Line Comments Documentation Comments Declarations Number Per Line Placement Initialization Class and Interface Declarations Statements Simple Statements Compound Statements return Statements if, if-else, if-else-if-else Statements for Statements while Statements do-while Statements switch Statements try-catch Statements White Space Blank Lines Blank Spaces Naming Conventions Programming Practices Providing Access to Instance and Class Variables iii
4 June 2, Referring to Class Variables and Methods Constants Variable Assignments Miscellaneous Practices Parentheses Returning Values Expressions before? in the Conditional Operator Special Comments Code Examples Java Source File Example iv
5 2 - File Names Java Code Conventions 1 - Introduction 1.1 Why Have Code Conventions Code conventions are important to programmers for a number of reasons: 80% of the lifetime cost of a piece of software goes to maintenance. Hardly any software is maintained for its whole life by the original author. Code conventions improve the readability of the software, allowing engineers to understand new code more quickly and thoroughly. If you ship your source code as a product, you need to make sure it is as well packaged and clean as any other product you create. 1.2 Acknowledgments This document reflects the Java language coding standards presented in the Java Language Specification, from Sun Microsystems. Major contributions are from Peter King, Patrick Naughton, Mike DeMoney, Jonni Kanerva, Kathy Walrath, and Scott Hommel. For questions concerning adaptation, modification, or redistribution of this document, please read our copyright notice at Comments on this document should be submitted to our feedback form at docs/forms/sendusmail.html. 2 - File Names This section lists commonly used file suffixes and names. 1
6 2 - File Names 2
7 3 - File Organization 2.1 File Suffixes JavaSoft uses the following file suffixes: File Type Java source Java bytecode Suffix.java.class 2.2 Common File Names Frequently used file names include: File Name GNUmakefile README Use The preferred name for makefiles. We use gnumake to build our software. The preferred name for the file that summarizes the contents of a particular directory. 3 - File Organization A file consists of sections that should be separated by blank lines and an optional comment identifying each section. Files longer than 2000 lines are cumbersome and should be avoided. For an example of a Java program properly formatted, see Java Source File Example on page Java Source Files Each Java source file contains a single public class or interface. When private classes and interfaces are associated with a public class, you can put them in the same source file as the public class. The public class should be the first class or interface in the file. Java source files have the following ordering: Beginning comments (see Beginning Comments on page 4) Package and Import for example: import java.applet.applet; import java.awt.*; import java.net.*; Class and interface declarations (see Class and Interface Declarations on page 4) 3
8 3 - File Organization Beginning Comments All source files should begin with a c-style comment that lists the programmer(s), the date, a copyright notice, and also a brief description of the purpose of the program. For example: /* * Classname * * Version info * * Copyright notice */ Package and Import Statements The first non-comment line of most Java source files is a package statement. After that, import statements can follow. For example: package java.awt; import java.awt.peer.canvaspeer; Class and Interface Declarations The following table describes the parts of a class or interface declaration, in the order that they should appear. See Java Source File Example on page 19 for an example that includes comments. Part of Class/Interface Declaration 1 Class/interface documentation comment (/**...*/) Notes See Documentation Comments on page 9 for information on what should be in this comment. 2 class or interface statement 3 Class/interface implementation comment (/*...*/), if necessary This comment should contain any class-wide or interface-wide information that wasn t appropriate for the class/interface documentation comment. 4 Class (static) variables First the public class variables, then the protected, and then the private. 5 Instance variables First public, then protected, and then private. 6 Constructors 4
9 4 - Indentation Part of Class/Interface Declaration Notes 7 Methods These methods should be grouped by functionality rather than by scope or accessibility. For example, a private class method can be in between two public instance methods. The goal is to make reading and understanding the code easier. 4 - Indentation Four spaces should be used as the unit of indentation. The exact construction of the indentation (spaces vs. tabs) is unspecified. Tabs must be set exactly every 8 spaces (not 4). 4.1 Line Length Avoid lines longer than 80 characters, since they re not handled well by many terminals and tools. Note: Examples for use in documentation should have a shorter line length generally no more than 70 characters. 4.2 Wrapping Lines When an expression will not fit on a single line, break it according to these general principles: Break after a comma. Break before an operator. Prefer higher-level breaks to lower-level breaks. Align the new line with the beginning of the expression at the same level on the previous line. If the above rules lead to confusing code or to code that s squished up against the right margin, just indent 8 spaces instead. Here are some examples of breaking method calls: function(longexpression1, longexpression2, longexpression3, longexpression4, longexpression5); var = function1(longexpression1, function2(longexpression2, longexpression3)); 5
10 4 - Indentation Following are two examples of breaking an arithmetic expression. The first is preferred, since the break occurs outside the parenthesized expression, which is at a higher level. longname1 = longname2 * (longname3 + longname4 - longname5) + 4 * longname6; // PREFER longname1 = longname2 * (longname3 + longname4 - longname5) + 4 * longname6; // AVOID Following are two examples of indenting method declarations. The first is the conventional case. The second would shift the second and third lines to the far right if it used conventional indentation, so instead it indents only 8 spaces. //CONVENTIONAL INDENTATION somemethod(int anarg, Object anotherarg, String yetanotherarg, Object andstillanother) {... //INDENT 8 SPACES TO AVOID VERY DEEP INDENTS private static synchronized horkinglongmethodname(int anarg, Object anotherarg, String yetanotherarg, Object andstillanother) {... Line wrapping for if statements should generally use the 8-space rule, since conventional (4 space) indentation makes seeing the body difficult. For example: //DON T USE THIS INDENTATION if ((condition1 && condition2) (condition3 && condition4)!(condition5 && condition6)) { //BAD WRAPS dosomethingaboutit(); //MAKE THIS LINE EASY TO MISS //USE THIS INDENTATION INSTEAD if ((condition1 && condition2) (condition3 && condition4)!(condition5 && condition6)) { dosomethingaboutit(); //OR USE THIS if ((condition1 && condition2) (condition3 && condition4)!(condition5 && condition6)) { dosomethingaboutit(); Here are three acceptable ways to format ternary expressions: alpha = (alongbooleanexpression)? beta : gamma; alpha = (alongbooleanexpression)? beta : gamma; alpha = (alongbooleanexpression)? beta : gamma; 6
11 5 - Comments 5 - Comments Java programs can have two kinds of comments: implementation comments and documentation comments. Implementation comments are those found in C++, which are delimited by /*...*/, and //. Documentation comments (known as doc comments ) are Java-only, and are delimited by /**...*/. Doc comments can be extracted to HTML files using the javadoc tool. Implementation comments are mean for commenting out code or for comments about the particular implementation. Doc comments are meant to describe the specification of the code, from an implementation-free perspective. to be read by developers who might not necessarily have the source code at hand. Comments should be used to give overviews of code and provide additional information that is not readily available in the code itself. Comments should contain only information that is relevant to reading and understanding the program. For example, information about how the corresponding package is built or in what directory it resides should not be included as a comment. Discussion of nontrivial or nonobvious design decisions is appropriate, but avoid duplicating information that is present in (and clear from) the code. It is too easy for redundant comments to get out of date. In general, avoid any comments that are likely to get out of date as the code evolves. Note: The frequency of comments sometimes reflects poor quality of code. When you feel compelled to add a comment, consider rewriting the code to make it clearer. Comments should not be enclosed in large boxes drawn with asterisks or other characters. Comments should never include special characters such as form-feed and backspace. 5.1 Implementation Comment Formats Programs can have four styles of implementation comments: block, single-line, trailing and end-of-line Block Comments Block comments are used to provide descriptions of files, methods, data structures and algorithms. Block comments should be used at the beginning of each file and before each method. They can also be used in other places, such as within methods. Block comments inside a function or method should be indented to the same level as the code they describe. A block comment should be preceded by a blank line to set it apart from the rest of the code. Block comments have an asterisk * at the beginning of each line except the first. /* * Here is a block comment. */ 7
12 5 - Comments Block comments can start with /*-, which is recognized by indent(1) as the beginning of a block comment that should not reformatted. Example: /* * Here is a block comment with some very special * formatting that I want indent(1) to ignore. * * one * two * three */ Note: If you don t use indent(1), you don t have to use /*- in your code or make any other concessions to the possibility that someone else might run indent(1) on your code. See also Documentation Comments on page Single-Line Comments Short comments can appear on a single line indented to the level of the code that follows. If a comment can t be written in a single line, it should follow the block comment format (see section 5.1.1). A single-line comment should be preceded by a blank line. Here s an example of a single-line comment in Java code (also see Documentation Comments on page 9): if (condition) { /* Handle the condition. */ Trailing Comments Very short comments can appear on the same line as the code they describe, but should be shifted far enough to separate them from the statements. If more than one short comment appears in a chunk of code, they should all be indented to the same tab setting. Avoid the assembly language style of commenting every line of executable code with a trailing comment. Here s an example of a trailing comment in Java code (also see Documentation Comments on page 9): if (a == 2) { return TRUE; /* special case */ else { return isprime(a); /* works only for odd a */ End-Of-Line Comments The // comment delimiter begins a comment that continues to the newline. It can comment out a complete line or only a partial line. It shouldn t be used on consecutive multiple lines for text comments; however, it can be used in consecutive multiple lines for commenting out sections of code. Examples of all three styles follow: 8
13 5 - Comments if (foo > 1) { // Do a double-flip.... else return false; // Explain why here. //if (bar > 1) { // // // Do a triple-flip. //... // //else // return false; 5.2 Documentation Comments Note: See Java Source File Example on page 19 for examples of the comment formats described here. For further details, see How to Write Doc Comments for Javadoc which includes information on the doc comment For further details about doc comments and javadoc, see the javadoc home page at: Doc comments describe Java classes, interfaces, constructors, methods, and fields. Each doc comment is set inside the comment delimiters /**...*/, with one comment per API. This comment should appear just before the declaration: /** * The Example class provides... */ class Example {... Notice that classes and interfaces are not indented, while their members are. The first line of doc comment (/**) for classes and interfaces is not indented; subsequent doc comment lines each have 1 space of indentation (to vertically align the asterisks). Members, including constructors, have 4 spaces for the first doc comment line and 5 spaces thereafter. If you need to give information about a class, interface, variable, or method that isn t appropriate for documentation, use an implementation block comment (see section 5.1.1) or single-line (see section 5.1.2) comment immediately after the declaration. For example, details about the implementation of a class should go in in such an implementation block comment following the class statement, not in the class doc comment. Doc comments should not be positioned inside a method or constructor definition block, because Java associates documentation comments with the first declaration after the comment. 9
14 6 - Declarations 6 - Declarations 6.1 Number Per Line One declaration per line is recommended since it encourages commenting. In other words, int level; // indentation level int size; // size of table is preferred over int level, size; In absolutely no case should variables and functions be declared on the same line. Example: long dbaddr, getdbaddr(); // WRONG! Do not put different types on the same line. Example: int foo, fooarray[]; //WRONG! Note: The examples above use one space between the type and the identifier. Another acceptable alternative is to use tabs, e.g.: int level; // indentation level int size; // size of table Object currententry; // currently selected table entry 6.2 Placement Put declarations only at the beginning of blocks. (A block is any code surrounded by curly braces { and.) Don t wait to declare variables until their first use; it can confuse the unwary programmer and hamper code portability within the scope. void MyMethod() { int int1; // beginning of method block if (condition) { int int2;... // beginning of "if" block The one exception to the rule is indexes of for loops, which in Java can be declared in the for statement: for (int i = 0; i < maxloops; i++) {... Avoid local declarations that hide declarations at higher levels. For example, do not declare the same variable name in an inner block: 10
15 7 - Statements int count;... func() { if (condition) { int count; // AVOID! 6.3 Initialization Try to initialize local variables where they re declared. The only reason not to initialize a variable where it s declared is if the initial value depends on some computation occurring first. 6.4 Class and Interface Declarations When coding Java classes and interfaces, the following formatting rules should be followed: No space between a method name and the parenthesis ( starting its parameter list Open brace { appears at the end of the same line as the declaration statement Closing brace starts a line by itself indented to match its corresponding opening statement, except when it is a null statement the should appear immediately after the { class Sample extends Object { int ivar1; int ivar2; Sample(int i, int j) { ivar1 = i; ivar2 = j; int emptymethod() {... Methods are separated by a blank line 7 - Statements 7.1 Simple Statements Each line should contain at most one statement. Example: argv++; argc--; // AVOID! 11
16 7 - Statements Do not use the comma operator to group multiple statements unless it is for an obvious reason. Example: if (err) { Format.print(System.out, error ), exit(1); //VERY WRONG! 7.2 Compound Statements Compound statements are statements that contain lists of statements enclosed in braces { statements. See the following sections for examples. The enclosed statements should be indented one more level than the compound statement. The opening brace should be at the end of the line that begins the compound statement; the closing brace should begin a line and be indented to the beginning of the compound statement. Braces are used around all statements, even singletons, when they are part of a control structure, such as a if-else or for statement. This makes it easier to add statements without accidentally introducing bugs due to forgetting to add braces. 7.3 return Statements A return statement with a value should not use parentheses unless they make the return value more obvious in some way. Example: return; return mydisk.size(); return (size? size : defaultsize); 7.4 if, if-else, if-else-if-else Statements The if-else class of statements should have the following form: if (condition) { if (condition) { else { if (condition) { else if (condition) { else if (condition) { 12
17 7 - Statements Note: if statements always use braces {. Avoid the following error-prone form: if (condition) //AVOID! THIS OMITS THE BRACES {! statement; 7.5 for Statements A for statement should have the following form: for (initialization; condition; update) { An empty for statement (one in which all the work is done in the initialization, condition, and update clauses) should have the following form: for (initialization; condition; update); When using the comma operator in the initialization or update clause of a for statement, avoid the complexity of using more than three variables. If needed, use separate statements before the for loop (for the initialization clause) or at the end of the loop (for the update clause). 7.6 while Statements A while statement should have the following form: while (condition) { An empty while statement should have the following form: while (condition); 7.7 do-while Statements A do-while statement should have the following form: do { while (condition); 7.8 switch Statements A switch statement should have the following form: 13
18 8 - White Space switch (condition) { case ABC: /* falls through */ case DEF: break; case XYZ: break; default: break; Every time a case falls through (doesn t include a break statement), add a comment where the break statement would normally be. This is shown in the preceding code example with the /* falls through */ comment. Every switch statement should include a default case. The break in the default case is redundant, but it prevents a fall-through error if later another case is added. 7.9 try-catch Statements A try-catch statement should have the following format: try { catch (ExceptionClass e) { 8 - White Space 8.1 Blank Lines Blank lines improve readability by setting off sections of code that are logically related. Two blank lines should always be used in the following circumstances: Between sections of a source file Between class and interface definitions One blank line should always be used in the following circumstances: Between methods Between the local variables in a method and its first statement Before a block (see section 5.1.1) or single-line (see section 5.1.2) comment 14
19 9 - Naming Conventions Between logical sections inside a method to improve readability 8.2 Blank Spaces Blank spaces should be used in the following circumstances: A keyword followed by a parenthesis should be separated by a space. Example: while (true) {... Note that a blank space should not be used between a method name and its opening parenthesis. This helps to distinguish keywords from method calls. A blank space should appear after commas in argument lists. All binary operators except. should be separated from their operands by spaces. Blank spaces should never separate unary operators such as unary minus, increment ( ++ ), and decrement ( -- ) from their operands. Example: a += c + d; a = (a + b) / (c * d); while (d++ = s++) { n++; prints("size is " + foo + "\n"); The expressions in a for statement should be separated by blank spaces. Example: for (expr1; expr2; expr3) Casts should be followed by a blank. Examples: mymethod((byte) anum, (Object) x); myfunc((int) (cp + 5), ((int) (i + 3)) + 1); 9 - Naming Conventions Naming conventions make programs more understandable by making them easier to read. They can also give information about the function of the identifier for example, whether it s a constant, package, or class which can be helpful in understanding the code. The conventions given in this section are high level. Further conventions are given at (to be determined). 15
20 10 - Programming Practices Identifier Type Rules for Naming Examples Classes Interfaces Methods Variables Constants Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML). Interface names should be capitalized like class names. Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized. Except for variables, all instance, class, and class constants are in mixed case with a lowercase first letter. Internal words start with capital letters. Variable names should be short yet meaningful. The choice of a variable name should be mnemonic that is, designed to indicate to the casual observer the intent of its use. One-character variable names should be avoided except for temporary throwaway variables. Common names for temporary variables are i, j, k, m, and n for integers; c, d, and e for characters. The names of variables declared class constants and of ANSI constants should be all uppercase with words separated by underscores ( _ ). (ANSI constants should be avoided, for ease of debugging.) class Raster; class ImageSprite; interface RasterDelegate; interface Storing; run(); runfast(); getbackground(); int i; char *cp; float mywidth; int MIN_WIDTH = 4; int MAX_WIDTH = 999; int GET_THE_CPU = 1; 10 - Programming Practices 10.1 Providing Access to Instance and Class Variables Don t make any instance or class variable public without good reason. Often, instance variables don t need to be explicitly set or gotten often that happens as a side effect of method calls. 16
21 10 - Programming Practices One example of appropriate public instance variables is the case where the class is essentially a data structure, with no behavior. In other words, if you would have used a struct instead of a class (if Java supported struct), then it s appropriate to make the class s instance variables public Referring to Class Variables and Methods Avoid using an object to access a class (static) variable or method. Use a class name instead. For example: classmethod(); AClass.classMethod(); anobject.classmethod(); //OK //OK //AVOID! 10.3 Constants Numerical constants (literals) should not be coded directly, except for -1, 0, and 1, which can appear in a for loop as counter values Variable Assignments Avoid assigning several variables to the same value in a single statement. It is hard to read. Example: foobar.fchar = barfoo.lchar = 'c'; // AVOID! Do not use the assignment operator in a place where it can be easily confused with the equality operator. Example: if (c++ = d++) {... // AVOID! Java disallows should be written as if ((c++ = d++)!= 0) {... Do not use embedded assignments in an attempt to improve run-time performance. This is the job of the compiler, and besides, it rarely actually helps. Example: d = (a = b + c) + r; // AVOID! should be written as a = b + c; d = a + r; 17
22 10 - Programming Practices 10.5 Miscellaneous Practices Parentheses It is generally a good idea to use parentheses liberally in expressions involving mixed operators to avoid operator precedence problems. Even if the operator precedence seems clear to you, it might not be to others you shouldn t assume that other programmers know precedence as well as you do. if (a == b && c == d) // AVOID! if ((a == b) && (c == d)) // RIGHT Returning Values Try to make the structure of your program match the intent. Example: if (booleanexpression) { return TRUE; else { return FALSE; should instead be written as return booleanexpression; Similarly, if (condition) { return x; return y; should be written as return (condition? x : y); Expressions before? in the Conditional Operator If an expression containing a binary operator appears before the? in the ternary?: operator, it should be parenthesized. Example: (x >= 0)? x : -x Special Comments Use XXX in a comment to flag something that is bogus but works. Use FIXME to flag something that is bogus and broken. 18
23 11 - Code Examples 11 - Code Examples 11.1 Java Source File Example The following example shows how to format a Java source file containing a single public class. Interfaces are formatted similarly. For more information, see Class and Interface Declarations on page 4 and Documentation Comments on page 9 /* * %W% %E% Firstname Lastname * * Copyright (c) Sun Microsystems, Inc. All Rights Reserved. * * This software is the confidential and proprietary information of Sun * Microsystems, Inc. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Sun. * * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package java.blah; import java.blah.blahdy.blahblah; /** * Class description goes here. * Oct 1996 Firstname Lastname */ public class Blah extends SomeClass { /* A class implementation comment can go here. */ /** classvar1 documentation comment */ public static int classvar1; /** * classvar2 documentation comment that happens to be * more than one line long */ private static Object classvar2; /** instancevar1 documentation comment */ public Object instancevar1; /** instancevar2 documentation comment */ protected int instancevar2; /** instancevar3 documentation comment */ private Object[] instancevar3; 19
24 11 - Code Examples /** *...method Blah documentation comment... */ public Blah() { //...implementation goes here... /** *...method dosomething documentation comment... */ public void dosomething() { //...implementation goes here... /** *...method dosomethingelse documentation comment... someparam description */ public void dosomethingelse(object someparam) { //...implementation goes here... 20
Code convention document Argus-viewer
Code convention document Projectnaam: Auteur(s): Reviewer(s): Software Process case voor master-studie Software Engineering 2007/2008. Robert Baarda (Q&A) Studentnr.: 5821258 Martijn van Beest (Q&A) Ka-Sing
Software Development (CS2500)
(CS2500) Lecture 15: JavaDoc and November 6, 2009 Outline Today we study: The documentation mechanism. Some important Java coding conventions. From now on you should use and make your code comply to the
C Coding Style Guide. Technotes, HowTo Series. 1 About the C# Coding Style Guide. 2 File Organization. Version 0.3. Contents
Technotes, HowTo Series C Coding Style Guide Version 0.3 by Mike Krüger, [email protected] Contents 1 About the C# Coding Style Guide. 1 2 File Organization 1 3 Indentation 2 4 Comments. 3 5 Declarations.
C# Code Style Guide. Version 1.2 Scott Bellware
Version 1.2 Scott Bellware 80% of the lifetime cost of a piece of software goes to maintenance. Hardly any software is maintained for its whole life by the original author. Code conventions improve the
CSE 308. Coding Conventions. Reference
CSE 308 Coding Conventions Reference Java Coding Conventions googlestyleguide.googlecode.com/svn/trunk/javaguide.html Java Naming Conventions www.ibm.com/developerworks/library/ws-tipnamingconv.html 2
Taxi Service Coding Policy. Version 1.2
Taxi Service Coding Policy Version 1.2 Revision History Date Version Description Author 2012-10-31 1.0 Initial version Karlo Zanki 2012-11-18 1.1 Added a section relative to Java/Android Fabio Kruger 2013-01-02
Object Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction
egovernment Authority [Sharmila Naveen] [07/04/2010]
Java Standards [Sharmila Naveen] [07/04/2010] Saved 8 May, 2011 Page 1 of 31 Table of Contents 1. Introduction 3 2. Purpose and Scope 3 3. File Organization 3 4. Source code style guidelines 4 4.1 Beginning
Moving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
Example of a Java program
Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);
Official Android Coding Style Conventions
2012 Marty Hall Official Android Coding Style Conventions Originals of Slides and Source Code for Examples: http://www.coreservlets.com/android-tutorial/ Customized Java EE Training: http://courses.coreservlets.com/
General Software Development Standards and Guidelines Version 3.5
NATIONAL WEATHER SERVICE OFFICE of HYDROLOGIC DEVELOPMENT Science Infusion Software Engineering Process Group (SISEPG) General Software Development Standards and Guidelines 7/30/2007 Revision History Date
Java Coding Style Guide
Java Coding Style Guide Achut Reddy Server Management Tools Group Sun Microsystems, Inc. Created: January 27, 1998 Last modified: May 30, 2000 ABSTRACT The importance and benefits of a consistent coding
A Coding Style Guide for Java WorkShop and Java Studio Programming
A Coding Style Guide for Java WorkShop and Java Studio Programming The importance and benefits of a consistent coding style are well known. This document describes a set of coding standards and recommendations
Object Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction
Dinopolis Java Coding Convention
Dinopolis Java Coding Convention Revision : 1.1 January 11, 2001 Abstract Please note that this version of the Coding convention is very much based on IICM s internal Dino coding convention that was used
Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.
1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays
JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved.
1 6 JavaScript: Introduction to Scripting 2 Comment is free, but facts are sacred. C. P. Scott The creditor hath a better memory than the debtor. James Howell When faced with a decision, I always ask,
AppendixA1A1. Java Language Coding Guidelines. A1.1 Introduction
AppendixA1A1 Java Language Coding Guidelines A1.1 Introduction This coding style guide is a simplified version of one that has been used with good success both in industrial practice and for college courses.
Chapter 2 Introduction to Java programming
Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break
JavaScript: Control Statements I
1 7 JavaScript: Control Statements I 7.1 Introduction 2 The techniques you will learn here are applicable to most high-level languages, including JavaScript 1 7.2 Algorithms 3 Any computable problem can
Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
CS 241 Data Organization Coding Standards
CS 241 Data Organization Coding Standards Brooke Chenoweth University of New Mexico Spring 2016 CS-241 Coding Standards All projects and labs must follow the great and hallowed CS-241 coding standards.
PL / SQL Basics. Chapter 3
PL / SQL Basics Chapter 3 PL / SQL Basics PL / SQL block Lexical units Variable declarations PL / SQL types Expressions and operators PL / SQL control structures PL / SQL style guide 2 PL / SQL Block Basic
Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C
Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection
JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.
http://www.tutorialspoint.com/java/java_quick_guide.htm JAVA - QUICK GUIDE Copyright tutorialspoint.com What is Java? Java is: Object Oriented Platform independent: Simple Secure Architectural- neutral
Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:
Introduction to Programming and Algorithms Module 2 CS 146 Sam Houston State University Dr. Tim McGuire Introduction To Computers And Java Chapter Objectives To understand: the meaning and placement of
Introduction to Python
WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language
Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
Informatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
CS 111 Classes I 1. Software Organization View to this point:
CS 111 Classes I 1 Software Organization View to this point: Data Objects and primitive types Primitive types operators (+, /,,*, %). int, float, double, char, boolean Memory location holds the data Objects
CS106A, Stanford Handout #38. Strings and Chars
CS106A, Stanford Handout #38 Fall, 2004-05 Nick Parlante Strings and Chars The char type (pronounced "car") represents a single character. A char literal value can be written in the code using single quotes
Import Filter Editor User s Guide
Reference Manager Windows Version Import Filter Editor User s Guide April 7, 1999 Research Information Systems COPYRIGHT NOTICE This software product and accompanying documentation is copyrighted and all
Java Application Developer Certificate Program Competencies
Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle
PHP Tutorial From beginner to master
PHP Tutorial From beginner to master PHP is a powerful tool for making dynamic and interactive Web pages. PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.
Java Program Coding Standards 4002-217-9 Programming for Information Technology
Java Program Coding Standards 4002-217-9 Programming for Information Technology Coding Standards: You are expected to follow the standards listed in this document when producing code for this class. Whether
Some Scanner Class Methods
Keyboard Input Scanner, Documentation, Style Java 5.0 has reasonable facilities for handling keyboard input. These facilities are provided by the Scanner class in the java.util package. A package is a
First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
The Rules 1. One level of indentation per method 2. Don t use the ELSE keyword 3. Wrap all primitives and Strings
Object Calisthenics 9 steps to better software design today, by Jeff Bay http://www.xpteam.com/jeff/writings/objectcalisthenics.rtf http://www.pragprog.com/titles/twa/thoughtworks-anthology We ve all seen
UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming
UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming 1 2 Foreword First of all, this book isn t really for dummies. I wrote it for myself and other kids who are on the team. Everything
C Compiler Targeting the Java Virtual Machine
C Compiler Targeting the Java Virtual Machine Jack Pien Senior Honors Thesis (Advisor: Javed A. Aslam) Dartmouth College Computer Science Technical Report PCS-TR98-334 May 30, 1998 Abstract One of the
Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.
Retrieving Data Using the SQL SELECT Statement Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL SELECT statements Execute a basic SELECT statement
Software Engineering Techniques
Software Engineering Techniques Low level design issues for programming-in-the-large. Software Quality Design by contract Pre- and post conditions Class invariants Ten do Ten do nots Another type of summary
Debugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go
Debugging ESE112 Java Programming: API, Psuedo-Code, Scope It is highly unlikely that you will write code that will work on the first go Bugs or errors Syntax Fixable if you learn to read compiler error
Software documentation systems
Software documentation systems Basic introduction to various user-oriented and developer-oriented software documentation systems. Ondrej Holotnak Ondrej Jombik Software documentation systems: Basic introduction
Selection Statements
Chapter 5 Selection Statements 1 Statements So far, we ve used return statements and expression ess statements. e ts. Most of C s remaining statements fall into three categories: Selection statements:
CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013
Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)
C Language Tutorial. Version 0.042 March, 1999
C Language Tutorial Version 0.042 March, 1999 Original MS-DOS tutorial by Gordon Dodrill, Coronado Enterprises. Moved to Applix by Tim Ward Typed by Karen Ward C programs converted by Tim Ward and Mark
AP Computer Science Java Subset
APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall
csce4313 Programming Languages Scanner (pass/fail)
csce4313 Programming Languages Scanner (pass/fail) John C. Lusth Revision Date: January 18, 2005 This is your first pass/fail assignment. You may develop your code using any procedural language, but you
Building a Multi-Threaded Web Server
Building a Multi-Threaded Web Server In this lab we will develop a Web server in two steps. In the end, you will have built a multi-threaded Web server that is capable of processing multiple simultaneous
Install Java Development Kit (JDK) 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html
CS 259: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center 319 8/19/2015 Install
Lecture 5: Java Fundamentals III
Lecture 5: Java Fundamentals III School of Science and Technology The University of New England Trimester 2 2015 Lecture 5: Java Fundamentals III - Operators Reading: Finish reading Chapter 2 of the 2nd
Statements and Control Flow
Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10. Introduction to
Computer Programming I
Computer Programming I COP 2210 Syllabus Spring Semester 2012 Instructor: Greg Shaw Office: ECS 313 (Engineering and Computer Science Bldg) Office Hours: Tuesday: 2:50 4:50, 7:45 8:30 Thursday: 2:50 4:50,
6.170 Tutorial 3 - Ruby Basics
6.170 Tutorial 3 - Ruby Basics Prerequisites 1. Have Ruby installed on your computer a. If you use Mac/Linux, Ruby should already be preinstalled on your machine. b. If you have a Windows Machine, you
VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0
VISUAL GUIDE to RX Scripting for Roulette Xtreme - System Designer 2.0 UX Software - 2009 TABLE OF CONTENTS INTRODUCTION... ii What is this book about?... iii How to use this book... iii Time to start...
StreamLink 5.0. StreamLink Configuration XML Reference. November 2009 C O N F I D E N T I A L
StreamLink Configuration XML Reference November 2009 C O N F I D E N T I A L Contents Contents 1 Preface... 1 1.1 1.2 1.3 1.4 1.5 1.6 What... this document contains 1 About... Caplin document formats 1
An Overview of Java. overview-1
An Overview of Java overview-1 Contents What is Java Major Java features Java virtual machine Java programming language Java class libraries (API) GUI Support in Java Networking and Threads in Java overview-2
Sources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void
1. Explain C tokens Tokens are basic building blocks of a C program. A token is the smallest element of a C program that is meaningful to the compiler. The C compiler recognizes the following kinds of
Chapter 3 Operators and Control Flow
Chapter 3 Operators and Control Flow I n this chapter, you will learn about operators, control flow statements, and the C# preprocessor. Operators provide syntax for performing different calculations or
Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators
Conditional Statements For computer to make decisions, must be able to test CONDITIONS IF it is raining THEN I will not go outside IF Count is not zero THEN the Average is Sum divided by Count Conditions
Pemrograman Dasar. Basic Elements Of Java
Pemrograman Dasar Basic Elements Of Java Compiling and Running a Java Application 2 Portable Java Application 3 Java Platform Platform: hardware or software environment in which a program runs. Oracle
Coding Rules. Encoding the type of a function into the name (so-called Hungarian notation) is forbidden - it only confuses the programmer.
Coding Rules Section A: Linux kernel style based coding for C programs Coding style for C is based on Linux Kernel coding style. The following excerpts in this section are mostly taken as is from articles
Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas
CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage
Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2015 The third
Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2014 Jill Seaman
Computer Programming C++ Classes and Objects 15 th Lecture
Computer Programming C++ Classes and Objects 15 th Lecture 엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University Copyrights 2013 Eom, Hyeonsang All Rights Reserved Outline
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java
Computer Programming Tutorial
Computer Programming Tutorial COMPUTER PROGRAMMING TUTORIAL by tutorialspoint.com tutorialspoint.com i ABOUT THE TUTORIAL Computer Prgramming Tutorial Computer programming is the act of writing computer
Conditional Statements. 15-110 Summer 2010 Margaret Reid-Miller
Conditional Statements 15-110 Summer 2010 Margaret Reid-Miller Conditional statements Within a method, we can alter the flow of control (the order in which statements are executed) using either conditionals
IBM VisualAge for Java,Version3.5. Remote Access to Tool API
IBM VisualAge for Java,Version3.5 Remote Access to Tool API Note! Before using this information and the product it supports, be sure to read the general information under Notices. Edition notice This edition
Chapter 1 Java Program Design and Development
presentation slides for JAVA, JAVA, JAVA Object-Oriented Problem Solving Third Edition Ralph Morelli Ralph Walde Trinity College Hartford, CT published by Prentice Hall Java, Java, Java Object Oriented
3rd Edition, June 2005. http://www.ecma-international.org/publications/ standards/ecma-334.htm.
Introduction style:1b. the shadow-producing pin of a sundial. 2c. the custom or plan followed in spelling, capitalization, punctuation, and typographic arrangement and display. Webster s New Collegiate
WA2099 Introduction to Java using RAD 8.0 EVALUATION ONLY. Student Labs. Web Age Solutions Inc.
WA2099 Introduction to Java using RAD 8.0 Student Labs Web Age Solutions Inc. 1 Table of Contents Lab 1 - The HelloWorld Class...3 Lab 2 - Refining The HelloWorld Class...20 Lab 3 - The Arithmetic Class...25
Nimsoft Monitor. ntevl Guide. v3.6 series
Nimsoft Monitor ntevl Guide v3.6 series Legal Notices Copyright 2012, CA. All rights reserved. Warranty The material contained in this document is provided "as is," and is subject to being changed, without
PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON
PROBLEM SOLVING WITH SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON Addison Wesley Boston San Francisco New York London
Xcode User Default Reference. (Legacy)
Xcode User Default Reference (Legacy) Contents Introduction 5 Organization of This Document 5 Software Version 5 See Also 5 Xcode User Defaults 7 Xcode User Default Overview 7 General User Defaults 8 NSDragAndDropTextDelay
Chapter 5 Names, Bindings, Type Checking, and Scopes
Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Scope Scope and Lifetime Referencing Environments Named
Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur
Module 10 Coding and Testing Lesson 23 Code Review Specific Instructional Objectives At the end of this lesson the student would be able to: Identify the necessity of coding standards. Differentiate between
VB.NET Programming Fundamentals
Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements
java.util.scanner Here are some of the many features of Scanner objects. Some Features of java.util.scanner
java.util.scanner java.util.scanner is a class in the Java API used to create a Scanner object, an extremely versatile object that you can use to input alphanumeric characters from several input sources
Course Title: Software Development
Course Title: Software Development Unit: Customer Service Content Standard(s) and Depth of 1. Analyze customer software needs and system requirements to design an information technology-based project plan.
Keil C51 Cross Compiler
Keil C51 Cross Compiler ANSI C Compiler Generates fast compact code for the 8051 and it s derivatives Advantages of C over Assembler Do not need to know the microcontroller instruction set Register allocation
Introduction to Python
Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment
Hypercosm. Studio. www.hypercosm.com
Hypercosm Studio www.hypercosm.com Hypercosm Studio Guide 3 Revision: November 2005 Copyright 2005 Hypercosm LLC All rights reserved. Hypercosm, OMAR, Hypercosm 3D Player, and Hypercosm Studio are trademarks
Oracle Agile Engineering Data Management
Oracle Agile Enterprise Integration Platform Development Guide for Agile e6.1.3.0 Part No. E50950-01 January 2014 Copyright and Trademarks Copyright 1995, 2014,Oracle and/or its affiliates. All rights
bbc Developing Service Providers Adobe Flash Media Rights Management Server November 2008 Version 1.5
bbc Developing Service Providers Adobe Flash Media Rights Management Server November 2008 Version 1.5 2008 Adobe Systems Incorporated. All rights reserved. Adobe Flash Media Rights Management Server 1.5
Chapter 2: Elements of Java
Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction
CA Nimsoft Monitor. Probe Guide for NT Event Log Monitor. ntevl v3.8 series
CA Nimsoft Monitor Probe Guide for NT Event Log Monitor ntevl v3.8 series Legal Notices Copyright 2013, CA. All rights reserved. Warranty The material contained in this document is provided "as is," and
Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)
Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating
SQL Server Database Coding Standards and Guidelines
SQL Server Database Coding Standards and Guidelines http://www.sqlauthority.com Naming Tables: Stored Procs: Triggers: Indexes: Primary Keys: Foreign Keys: Defaults: Columns: General Rules: Rules: Pascal
Iteration CHAPTER 6. Topic Summary
CHAPTER 6 Iteration TOPIC OUTLINE 6.1 while Loops 6.2 for Loops 6.3 Nested Loops 6.4 Off-by-1 Errors 6.5 Random Numbers and Simulations 6.6 Loop Invariants (AB only) Topic Summary 6.1 while Loops Many
JavaScript. JavaScript: fundamentals, concepts, object model. Document Object Model. The Web Page. The window object (1/2) The document object
JavaScript: fundamentals, concepts, object model Prof. Ing. Andrea Omicini II Facoltà di Ingegneria, Cesena Alma Mater Studiorum, Università di Bologna [email protected] JavaScript A scripting language:
Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language
Simple C++ Programs Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input and Output Basic Functions from
Lecture 2 Notes: Flow of Control
6.096 Introduction to C++ January, 2011 Massachusetts Institute of Technology John Marrero Lecture 2 Notes: Flow of Control 1 Motivation Normally, a program executes statements from first to last. The
Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl
First CGI Script and Perl Perl in a nutshell Prof. Rasley shebang line tells the operating system where the Perl interpreter is located necessary on UNIX comment line ignored by the Perl interpreter End
Creating Carbon Menus. (Legacy)
Creating Carbon Menus (Legacy) Contents Carbon Menus Concepts 4 Components of a Carbon Menu 4 Carbon Menu Tasks 6 Creating a Menu Using Nibs 6 The Nib File 7 The Menus Palette 11 Creating a Simple Menu
