Here is a little tip and the reason behind it: If you have any code on an XPage, replace it with a single function call and move the code to a script library.
Example:
If you have code like this on your XPage
Here's why:
First, it consolidates all of the code so there is never any question where to find it.
Second, in an environment with multiple developers, you can assign out different sections of code and each person can own a single script library and there will not be any replication conflicts when two people are working on their code at once.
Third, in an environment that requires builds to only be done on the server (when you have multiple developers working on local replicas rather than the server copy), changing a script library does not require a rebuild, but changing an XPage does.
Example:
If you have code like this on your XPage
<xp:this.querySaveDocument><![CDATA[#{javascript: var foo = "hi";var bar="there";return (foo==bar?True:False);}]]></xp:this.querySaveDocument>Replace it with this
<xp:this.querySaveDocument><![CDATA[#{javascript: return foobarQuerySave();}]]></xp:this.querySaveDocument>And create and include a script library with this
function foobarQuerySave() { var foo = "hi"; var bar = "there"; return (foo==bar?True:False);}Even if there is no code there currently, if you think there may ever be a need for it you should add a stub function that just returns true and call it.
Here's why:
First, it consolidates all of the code so there is never any question where to find it.
Second, in an environment with multiple developers, you can assign out different sections of code and each person can own a single script library and there will not be any replication conflicts when two people are working on their code at once.
Third, in an environment that requires builds to only be done on the server (when you have multiple developers working on local replicas rather than the server copy), changing a script library does not require a rebuild, but changing an XPage does.
Comments
Post a Comment