NetBeans Code ConventionsAll NetBeans Java source code follows the "Code Conventions for the Java Programming Language" as published by Sun. This document is available online at http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.htmlHere we list those rules from the Code Conventions which are most important, plus some programming practices specific to NetBeans Formatting
Programming Practices
Code Example/* /* The contents of this file are subject to the terms of the Common Development and Distribution License (the License). You may not use this file except in compliance with the License. You can obtain a copy of the License at http://www.netbeans.org/cddl.html When distributing Covered Code, include this CDDL Header Notice in each file and include the License. If applicable, add the following below the CDDL Header, with the fields enclosed by brackets [] replaced by your own identifying information: "Portions Copyrighted [year] [name of copyright owner]" Copyright 2005 Sun Microsystems Inc. All Rights Reserved */ package org.netbeans.modules.nosuchpackage; import java.util.ArrayList; import java.util.List; import org.openide.nodes.Node; /** * This is a totally useless class with a summary sentence ending with a period. * Its only purpose is to demonstrate the NetBeans code conventions. */ public class NoSuchClass extends SomeClass { /** the default capacity */ public static final int DEFAULT_CAPACITY = 32; /** the objects being stored, of type <code>NoSuchElement</code> */ private final List/*<NoSuchElement>*/ storage = new ArrayList(50); /** * Creates a new instance of <code>NoSuchClass</code> with default capacity. */ public NoSuchClass() { this(DEFAULT_CAPACITY); } /** * Creates a new instance of <code>NoSuchClass</code> with a given capacity. * @param capacity number of slots to be preallocated */ public NoSuchClass(int capacity) { // ... implementation goes here } /** * Finds an entry with a given name. * @param name name to look for * @return an entry with a specified name or <code>null</code> if * no such entry is found */ public Entry findEntry(String name) { // ... boring code deleted ... if ("nef".equals(name)) { // NOI18N, backdoor :-) // ... } else { // ... } // ... boring code deleted ... } } Edited by Trung Duc Tran < > and Jesse Glick < > July 14, 2005 |
Releases & PlanningHow Do IFile BugsContribute Code
Develop RCP Apps on the NetBeans Platform NetBeans Platform APIs Guidelines Get ConnectedMailing ListsNetBeans Wiki Blogs News Events Teach with NetBeans IDE Translate NetBeans IDE |