Guidelines
This document lays down coding guidelines, best practices and gotchas for developers to keep in mind.
Bahmni Core Guidelines
Try and move all Data setup XMLs to bahmni-test-commons, avoid duplication of data setup XMLs at all costs. Also try to move all builders, or any code which might be relevant for other unit tests to the bahmni-test-commons module.
Avoid redundancy of Hibernate mapping files, there is no need for that. If a Maven Module is a dependency then the application Context XML will be included in the parent module as well, so the mapping will be inherited.
Take care of spring wiring, don't do a blind huge component scan on all the packages where some of them might not even include components, this increases the applications startup time.
Avoid repetition of similar task in each and every test, since the Before annotation setup method runs before each and ever test, and if you need something run before class then use the BeforeClass
annotation.
Bahmni UI Coding Guidelines
- The mobile browsers (iPad and Android) do not support parsing ISO dates. Avoid using
new Date(dateString
) for parsing dates. UseDateUtil.parse
() instead (which uses moment.js). - In order to disable a "Submit" button, rely on checking the form's validity, rather than checking if a validation method passes. Make validation methods mark the input control as invalid, which indirectly will make form as invalid. That way the Submit button will get enabled only if the form is valid, which means all input controls on the form is valid. This will keep your submit method enabled/disable logic straightforward.
Avoid using self-closing html tags for span, divs. The
<span/>
will be converted to<span>
by grunt html validator and minifiers. The "dist" doesn't work as expected. Use<span></span>
instead of<span/>
. See http://stackoverflow.com/questions/3558119/are-self-closing-tags-valid-in-html5More angular guidelines related to performance boost is here.