Docsity

Coding Standard - Software Engineering I | EEL 5881, Study Guides, Projects, Research of Electrical and Electronics Engineering

Toggle sidebar
bg1
Coding Standard
v0.0
October 4, 2000
Page 1 of 1
Coding Standard
Version Description
Version Date Who Comment
v0.0 10/03/00 Manu Bhatia Document Created
v0.1 10/04/00 Vickie Westmark Document updated to adhere to Document
Standard.
v2.0
v3.0
Contents of this Document
• General
• Naming Conventions
• Commenting Code
• Parenthesis
• Constants
• Line Spacing
• Braces
• Declarations
General
Since the project intends to use some sort of Object oriented language, and Java seems to be a
strong contestant, coding standards will closely follow the Java coding standards.
Following are two basic, but very important goals are recognized:
1. The use of these guidelines should result in readable code and should encourage adherence.
2. The resulting documentation should be easy to maintain.
Naming Conventions
Package Names: Package names should be single lowercase words.
Class Names: Concrete classes should use natural descriptive names, begin with a capital, and
have mixed case: FooBarReader
Member Function Names: Method ("member function") names should begin with a lowercase
letter with each subsequent new word in uppercase, and subsequent letters in each word in lower
pf3
pf4

Partial preview of the text

Download Coding Standard - Software Engineering I | EEL 5881 and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!

v0. October 4, 2000

Coding Standard

Version Description

Version Date Who Comment v0.0 10/03/00 Manu Bhatia Document Created v0.1 10/04/00 Vickie Westmark Document updated to adhere to Document Standard. v2. v3.

Contents of this Document

  • General
  • Naming Conventions
  • Commenting Code
  • Parenthesis
  • Constants
  • Line Spacing
  • Braces
  • Declarations

General

Since the project intends to use some sort of Object oriented language, and Java seems to be a

strong contestant, coding standards will closely follow the Java coding standards.

Following are two basic, but very important goals are recognized:

1. The use of these guidelines should result in readable code and should encourage adherence.

2. The resulting documentation should be easy to maintain.

Naming Conventions

Package Names: Package names should be single lowercase words.

Class Names: Concrete classes should use natural descriptive names, begin with a capital, and

have mixed case: FooBarReader

Member Function Names: Method ("member function") names should begin with a lowercase

letter with each subsequent new word in uppercase, and subsequent letters in each word in lower

v0. October 4, 2000

case. Methods for debug implementation can begin with the word "debug". Static methods

should begin with a capital letter with each subsequent new word in uppercase, and subsequent

letters in each word in lower case.

Example:

public class MyClass { void doSomethingNeat(int aValue); void debugDumpToScreen(); static void SomeClassMethod(int aValue); };

Commenting Code

All interfaces and public classes should have JavaDoc comments. See the JavaDoc

documentation available from JavaSoft.

Parenthesis

Parentheses are recommended for Boolean expressions to ensure proper evaluation.

Example:

if (((someValue<foo(theParm)) && anotherValue) || todayIsMyBirthday)

Constants

Constants will use mixed case and begin with lowercase k. They offer compile time type

checking.

Example:

static final float kPi = 3.14159; static final int kDaysInWeek = 7;

Line Spacing

Line width should not ordinarily exceed 80 characters. Tab sizes should be set equal to 4 spaces

and set to be expanded to spaces.

Braces

The starting brace is on the next line aligned with the conditional. The ending brace must be on

a separate line and aligned with the conditional. It is strongly recommended that all conditional

v0. October 4, 2000

TRY/CATCH/FINALLY: The try/catch construct is similar to the others. TRY keyword

should appear on its own line; followed by the open brace; followed by the statement body;

followed by the close brace on its own line. Any number of CATCH phrases are next consisting

of the CATCH keyword and the exception expression on its own line; followed by the CATCH

body; followed by the close brace on its own line. The FINALLY clause is the same as a

CATCH.

Example:

try { statement; } catch (ExceptionClass e) { statement; } finally { statement; }

Declarations

All type declarations should follow standard Java package naming.

Package: The project needs to pick a prefix (usually choose 2 letters). The project may split

itself into any number of packages below this prefix. All package names are entirely lower case.

Remember, Java tools are case sensitive, and as of this writing somewhat inconsistent across

platforms concerning package names.

Interface: It is encouraged to use the prefix "I" in interface classes, such as IPart. This is

optional, but strongly encouraged.

Constants: begin with k

Example: kMyConstant

Global Types: begin with g

Example: gDays (or "globalDays" is ok.)