<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.opentaps.org/docs/index.php?action=history&amp;feed=atom&amp;title=Opentaps_Coding_Standards</id>
	<title>Opentaps Coding Standards - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://docs.opentaps.org/docs/index.php?action=history&amp;feed=atom&amp;title=Opentaps_Coding_Standards"/>
	<link rel="alternate" type="text/html" href="https://docs.opentaps.org/docs/index.php?title=Opentaps_Coding_Standards&amp;action=history"/>
	<updated>2026-05-15T16:16:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.32.1</generator>
	<entry>
		<id>https://docs.opentaps.org/docs/index.php?title=Opentaps_Coding_Standards&amp;diff=5649&amp;oldid=prev</id>
		<title>Sichen: /* opentaps Guidelines */</title>
		<link rel="alternate" type="text/html" href="https://docs.opentaps.org/docs/index.php?title=Opentaps_Coding_Standards&amp;diff=5649&amp;oldid=prev"/>
		<updated>2010-03-17T00:59:00Z</updated>

		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;opentaps Guidelines&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 00:59, 17 March 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l48&quot; &gt;Line 48:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 48:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Returning error vs. failure'''  When writing services, use returnError only when it is a fatal error that should abort the entire process.  Otherwise, use returnFailure so that an error message is logged and returned, but the rest of the process could continue.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Returning error vs. failure'''  When writing services, use returnError only when it is a fatal error that should abort the entire process.  Otherwise, use returnFailure so that an error message is logged and returned, but the rest of the process could continue.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Keep names consistent.'''  I once saw a developer spend four days trying to fix a bug because the webapp controller URL request was &amp;quot;updatePostalAddress&amp;quot; but the back end service was &amp;quot;updatePartyPostalAddress&amp;quot;.  Unless it is impossible, use the same field name on the entities in your services and web forms.  Use the same webapp controller name as your service or servlet method.  Use the name for your controller's request and view maps and the names for the screen, the freemarker template, and the beanshell script.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Keep names consistent.'''  I once saw a developer spend four days trying to fix a bug because the webapp controller URL request was &amp;quot;updatePostalAddress&amp;quot; but the back end service was &amp;quot;updatePartyPostalAddress&amp;quot;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; (There was also a service called &amp;quot;updatePostalAddress&amp;quot;.) &lt;/ins&gt; Unless it is impossible, use the same field name on the entities in your services and web forms.  Use the same webapp controller name as your service or servlet method.  Use the name for your controller's request and view maps and the names for the screen, the freemarker template, and the beanshell script.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Organize your code logically.'''  Put all code and services in the same application component.  If the same service is used by different applications, put it into the commons component.  Use the same sub-directory prefixes for all the freemarker, beanshell, script, services files.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Organize your code logically.'''  Put all code and services in the same application component.  If the same service is used by different applications, put it into the commons component.  Use the same sub-directory prefixes for all the freemarker, beanshell, script, services files.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Sichen</name></author>
		
	</entry>
	<entry>
		<id>https://docs.opentaps.org/docs/index.php?title=Opentaps_Coding_Standards&amp;diff=5648&amp;oldid=prev</id>
		<title>Sichen: /* opentaps Guidelines */</title>
		<link rel="alternate" type="text/html" href="https://docs.opentaps.org/docs/index.php?title=Opentaps_Coding_Standards&amp;diff=5648&amp;oldid=prev"/>
		<updated>2010-03-17T00:58:26Z</updated>

		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;opentaps Guidelines&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 00:58, 17 March 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l18&quot; &gt;Line 18:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 18:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Create Tests''' Always create some demo data which could be used to test your use case.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Create Tests''' Always create some demo data which could be used to test your use case.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Do not use minilang.'''  A small book could &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;probably &lt;/del&gt;be written about why not &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;to &lt;/del&gt;use minilang, but how about:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Do not use minilang.'''  A &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;not-too-&lt;/ins&gt;small book could &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;definitely &lt;/ins&gt;be written about why &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;you should &lt;/ins&gt;not use minilang, but how about:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* It has a non-standard syntax.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* It has a non-standard syntax.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* It encourages un-object-oriented coding.  &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* It encourages un-object-oriented coding.  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l42&quot; &gt;Line 42:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 42:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;and don't use it to layout your screens in XML.  Use FTL templates, which are more flexible and allow better control of the page, and [[Screen Widget Actions in Java]].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;and don't use it to layout your screens in XML.  Use FTL templates, which are more flexible and allow better control of the page, and [[Screen Widget Actions in Java]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Do not overuse the service engine.'''  If you are just looking up data, consider writing a Java method.  It is much faster.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Do not overuse the service engine.'''  &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;The service engine is a convenient way to map parameters to backend business logic and have actions such as storing and updating data occur inside of a transaction. In those cases, using the service engine is a good idea, though it is probably better to write the services as POJOs, so that they can also be reused in other Java frameworks. Avoid using the service engine for looking up data, in services such as getInventoryAvailableForFacility, etc. which are not really transactional services.   &lt;/ins&gt;If you are just looking up data, consider writing a Java method.  It is much faster. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Do not overuse transactions.'''  Unless you are storing data, add a use-transaction=&amp;quot;false&amp;quot; to your services XML definition so that it does not wrap it in a transaction automatically.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Do not overuse transactions.'''  Unless you are storing data, add a use-transaction=&amp;quot;false&amp;quot; to your services XML definition so that it does not wrap it in a transaction automatically.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Sichen</name></author>
		
	</entry>
	<entry>
		<id>https://docs.opentaps.org/docs/index.php?title=Opentaps_Coding_Standards&amp;diff=5128&amp;oldid=prev</id>
		<title>Sichen: Protected &quot;Opentaps Coding Standards&quot;: Sysop page [edit=sysop:move=sysop]</title>
		<link rel="alternate" type="text/html" href="https://docs.opentaps.org/docs/index.php?title=Opentaps_Coding_Standards&amp;diff=5128&amp;oldid=prev"/>
		<updated>2009-12-12T00:55:24Z</updated>

		<summary type="html">&lt;p&gt;Protected &amp;quot;&lt;a href=&quot;/docs/index.php?title=Opentaps_Coding_Standards&quot; title=&quot;Opentaps Coding Standards&quot;&gt;Opentaps Coding Standards&lt;/a&gt;&amp;quot;: Sysop page [edit=sysop:move=sysop]&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 00:55, 12 December 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Sichen</name></author>
		
	</entry>
	<entry>
		<id>https://docs.opentaps.org/docs/index.php?title=Opentaps_Coding_Standards&amp;diff=5127&amp;oldid=prev</id>
		<title>Sichen: New page: __TOC__  ==Why Coding Standards?==   Hey, that used to work! What happened to it?  Good code is not just code that runs today, but code that is easy to maintain and easy for other people t...</title>
		<link rel="alternate" type="text/html" href="https://docs.opentaps.org/docs/index.php?title=Opentaps_Coding_Standards&amp;diff=5127&amp;oldid=prev"/>
		<updated>2009-12-12T00:55:24Z</updated>

		<summary type="html">&lt;p&gt;New page: __TOC__  ==Why Coding Standards?==   Hey, that used to work! What happened to it?  Good code is not just code that runs today, but code that is easy to maintain and easy for other people t...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
==Why Coding Standards?==&lt;br /&gt;
&lt;br /&gt;
 Hey, that used to work! What happened to it?&lt;br /&gt;
&lt;br /&gt;
Good code is not just code that runs today, but code that is easy to maintain and easy for other people to understand and work with.   Here are some guidelines we've come up with to help make opentaps better, and we hope they will help your project as well.&lt;br /&gt;
&lt;br /&gt;
==opentaps Guidelines==&lt;br /&gt;
&lt;br /&gt;
'''Java is Your Friend.'''  Using these tools will make your code easier and faster to write with IDE's such as Eclipse or NetBeans and easier to maintain and re-factor:&lt;br /&gt;
* [[Base Entity Classes]]&lt;br /&gt;
* [[Java Wrapper for OFBiz Services]]&lt;br /&gt;
* [[Screen Widget Actions in Java]]&lt;br /&gt;
* [[Java Classes for Constants]]&lt;br /&gt;
* [[POJO Service Engine]]&lt;br /&gt;
&lt;br /&gt;
'''Create Tests''' Always create some demo data which could be used to test your use case.&lt;br /&gt;
&lt;br /&gt;
'''Do not use minilang.'''  A small book could probably be written about why not to use minilang, but how about:&lt;br /&gt;
* It has a non-standard syntax.&lt;br /&gt;
* It encourages un-object-oriented coding. &lt;br /&gt;
* It offers limited logging support.&lt;br /&gt;
* It is slower.&lt;br /&gt;
* It doesn't support a lot of basic operations of a real programming language.&lt;br /&gt;
* There is no backward or forward compatibility.&lt;br /&gt;
&lt;br /&gt;
Even if you enjoy coding in XML, other developers will have trouble  maintaining or debugging your code.  You can always use Java or another Java scripting language, including beanshell, Groovy, Jython, JRuby, etc.&lt;br /&gt;
&lt;br /&gt;
'''Do not use the form widget.''' You can make a simple form very quickly, but it is almost impossible to make a nice looking or sophisticated form.  You'd also find yourself writing code like:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;set field=&amp;quot;showCredit&amp;quot; value=&amp;quot;${bsh:(postedBalance.compareTo(java.math.BigDecimal.ZERO) &amp;amp;gt;= 0 &lt;br /&gt;
  &amp;amp;amp;&amp;amp;amp; org.ofbiz.accounting.util.UtilAccounting.isCreditAccount(glAccount)) || &lt;br /&gt;
  (postedBalance.compareTo(java.math.BigDecimal.ZERO) &amp;amp;lt; 0 &amp;amp;amp;&amp;amp;amp; &lt;br /&gt;
  org.ofbiz.accounting.util.UtilAccounting.isDebitAccount(glAccount))}&amp;quot; type=&amp;quot;Boolean&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the opentaps form macro or just freemarker/HTML instead.&lt;br /&gt;
&lt;br /&gt;
This also includes the menu widget, the tree widget, and other related XML widgets.&lt;br /&gt;
&lt;br /&gt;
'''Keep your ofbiz screen widgets simple.''' Use it as a basic tool to set data for a template.  Don't have complex minilang calls (entity-condition, entity-one),&lt;br /&gt;
and don't use it to layout your screens in XML.  Use FTL templates, which are more flexible and allow better control of the page, and [[Screen Widget Actions in Java]].&lt;br /&gt;
&lt;br /&gt;
'''Do not overuse the service engine.'''  If you are just looking up data, consider writing a Java method.  It is much faster.&lt;br /&gt;
&lt;br /&gt;
'''Do not overuse transactions.'''  Unless you are storing data, add a use-transaction=&amp;quot;false&amp;quot; to your services XML definition so that it does not wrap it in a transaction automatically.&lt;br /&gt;
&lt;br /&gt;
'''Returning error vs. failure'''  When writing services, use returnError only when it is a fatal error that should abort the entire process.  Otherwise, use returnFailure so that an error message is logged and returned, but the rest of the process could continue.&lt;br /&gt;
&lt;br /&gt;
'''Keep names consistent.'''  I once saw a developer spend four days trying to fix a bug because the webapp controller URL request was &amp;quot;updatePostalAddress&amp;quot; but the back end service was &amp;quot;updatePartyPostalAddress&amp;quot;.  Unless it is impossible, use the same field name on the entities in your services and web forms.  Use the same webapp controller name as your service or servlet method.  Use the name for your controller's request and view maps and the names for the screen, the freemarker template, and the beanshell script.&lt;br /&gt;
&lt;br /&gt;
'''Organize your code logically.'''  Put all code and services in the same application component.  If the same service is used by different applications, put it into the commons component.  Use the same sub-directory prefixes for all the freemarker, beanshell, script, services files.&lt;br /&gt;
&lt;br /&gt;
'''Put in log messages whenever there is unexpected behavior.'''  For example, this is very mysterious:&lt;br /&gt;
&lt;br /&gt;
 if (! &amp;quot;SALES_INVOICE&amp;quot;.equals(invoice.get(&amp;quot;invoiceTypeId&amp;quot;)))&lt;br /&gt;
   return ServiceUtil.returnSuccess();&lt;br /&gt;
&lt;br /&gt;
My service could run, and I might never know why.  Instead, do this:&lt;br /&gt;
&lt;br /&gt;
 if (InvoiceTypeConstants.SALES_INVOICE.equals(invoice.getInvoiceTypeId())) {&lt;br /&gt;
     Debug.logInfo(&amp;quot;Invoice [&amp;quot; + invoiceId + &amp;quot;] is not a sales invoice and will not be billed to a third party&amp;quot;, module);&lt;br /&gt;
     return ServiceUtil.returnSuccess();&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
'''Comment your code!'''  '''We recommend a least one line of comment per 10 lines of code.'''   But good comments also need to explain why things are done the way they are done.  Good comments don't just tell you what is happening but why.  For example, would a comment like this help anybody?&lt;br /&gt;
&lt;br /&gt;
      // set X to Y&lt;br /&gt;
      double x = y;&lt;br /&gt;
&lt;br /&gt;
Highly unlikely: you just re-wrote your code in English.  But this would be helpful:&lt;br /&gt;
&lt;br /&gt;
      //  x and y coordinates should be the same when we re-calibrate.&lt;br /&gt;
      double x = y&lt;br /&gt;
&lt;br /&gt;
'''Never assume your data is clean.'''  If you ever write &lt;br /&gt;
 creditCard = payment.getRelatedOne(&amp;quot;PaymentMethod&amp;quot;).getRelatedOne(&amp;quot;CreditCard&amp;quot;);  &lt;br /&gt;
&lt;br /&gt;
you are guaranteed to get a null pointer exception sooner or later.   Always check for null values first!&lt;/div&gt;</summary>
		<author><name>Sichen</name></author>
		
	</entry>
</feed>