platform-ui-home/code-conventions/index.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (download) (as text) (annotate)
Fri Mar 18 14:06:04 2005 UTC (4 years, 8 months ago) by nick
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +38 -1 lines
Added conventions for component boundaries and mapping to IFile
<html>
	<head>
		<title>Code Conventions for the Platform UI Team</title>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<link rel="stylesheet" href="http://dev.eclipse.org/default_style.css" type="text/css">
	</head>
	<body bgcolor="#FFFFFF" text="#000000">
		<table border=0 cellspacing=5 cellpadding=2 width="100%" >
			<tr> 
		    	<td align=LEFT valign=TOP colspan="2" bgcolor="#0080C0">
		    		<b><font color="#FFFFFF" face="Arial,Helvetica">Code Conventions for the Platform UI Team</font></b>
		    	</td>
			</tr>
			<tr>
				<td align=right valign=top width="2%">
					<img src="http://dev.eclipse.org/images/Adarrow.gif" border=0 height=16 width=16 alt = "arrow">
				</td>
				<td width="98%">
		    		<p>The main Eclipse coding conventions can be found <a href="http://dev.eclipse.org/conventions.html">here</a>.</p>
		    		<p>The Platform UI team separates the issue of coding
		    		conventions into two components: formatting, and compiler
		    		warnings and errors.</p>
		    		<p>For formatting, all of our code is formatted using the
		    		built-in "Java Conventions" formatter provided by JDT.  All
		    		of imports should be organized using the default settings.
		    		We discourage the use of the "Sort Memebers" functionality;
		    		however, if you are creating new files, feel free to use it
		    		if you wish.  Do not use "Sort Members" on existing 
		    		code.</p>
		    		<p>For compiler settings, we recommend changing the 
		    		following items from "Ignore" to "Warning".  As a note, it
		    		is required that all Platform UI code (excluding code in
		    		"org.eclipse.ui.tests") does not contain non-externalized
		    		strings.
		    		<ul>
			    		<li>Style</li>
			    		<ul>
				    		<li>Indirect access to a static member</li>
				    		<li>Possible accidental boolean assignment</li>
				    		<li>Undocumented empty block</li>
				    	</ul>
				    	<li>Advanced</li>
				    	<ul>
				    		<li>Local variable declaration hides another field
				    		or variable</li>
				    		<li>Field declaration hides another field or 
				    		variable</li>
				    		<li>Usage of non-externalized strings</li>
				    	</ul>
				    	<li>Unused Code</li>
				    	<ul>
				    		<li>Local variable is never read</li>
				    		<li>Unused or unread private members</li>
				    		<li>Usage of deprecated API</li>
				    		<li>Unnecessary semicolon</li>
				    		<li>Unnecessary cast or 'instanceof' operation</li>
				    	</ul>
				    </ul>
				    <p>These settings can be imported from this 
				    <a href="codeconventions.epf">file</a>.
				</td>
			</tr>
			<tr>
				<td align=right valign=top width="2%">
					<img src="http://dev.eclipse.org/images/Adarrow.gif" border=0 height=16 width=16 alt = "arrow">
				</td>
				<td width="98%">
					<p>Platform UI covers several components: JFace, the Generic Workbench, and the IDE.
					</p>
					<p>
					Code in these components should respect the API boundaries of these other components 
					(i.e. treat other components as if they were owned by another team).
					In particular, code in the <code>org.eclipse.ui.ide</code> plug-in should not refer
					to internal classes in <code>org.eclipse.ui</code> or <code>org.eclipse.ui.workbench</code>.
					The IDE should follow the same rules as any other RCP application.
					<p>
					Code in these components should respect the API boundaries of these other components 
					(i.e. treat other components as if they were owned by another team).
					In particular, code in the <code>org.eclipse.ui.ide</code> plug-in should not refer
					to internal classes in <code>org.eclipse.ui</code> or <code>org.eclipse.ui.workbench</code>.
					The IDE should follow the same rules as any other RCP application.
					</p>
				</td>
			</tr>
			<tr>
				<td align=right valign=top width="2%">
					<img src="http://dev.eclipse.org/images/Adarrow.gif" border=0 height=16 width=16 alt = "arrow">
				</td>
				<td width="98%">
					<p>In the IDE, we occasionally need to map between workspace resources and workbench objects.
					For example, when closing a project, we need to determine the affected editors by checking
					whether their input corresponds to a file in the project.  Although the IDE provides IFileEditorInput
					and FileEditorInput, we must not assume that this is the only kind of editor input that
					can represent an workspace file.  When mapping from an editor input, use the adaptable mechanism
					rather than instanceof checks for [I]FileEditorInput.  See ResourceUtil.getFile(IEditorInput) for
					a convenience method that will do this properly.
					</p>
				</td>
			</tr>
		</table>
	</body>
</html>