Philip_Baird
12 years agoCommunity Expert
NameSpace and Module patterns using JScript
I have just started working on a Test Complete JScript project (complete novice) and I am looking at introducing proper NameSpace and Module (as prescribed by idiomatic.js) patterns as it is currently descending into spaghetti code.
As a proof of concept I have created the following Script Units:
NameSpace.sj which contains
/**
Define NameSpaces
-TODO- Use correct pattern
*/
var com = {};
com.testcompany = {};
com.testcompany.testcomplete = {};
com.testcompany.testcomplete.utils = {};
MyModule.sj which contains:
//USEUNIT NameSpace
(function( namespace ) {
var TestModule = (function() {
// Private Members
var priv = "I am private";
// Public Members
return {
meth : function() {
return priv;
}
};
})();
namespace.TestModule = TestModule;
})(com.testcompany.testcomplete.utils);
and finally Unit1.sj which contatins:
//USEUNIT MyModule
// Alias namespace
var testModule = com.testcompany.testcomplete.utils.TestModule;
test = function() {
Log.Message(testModule.meth());
}
So far this all works as expected but I was wondering if someone who had experience using similar patterns in Test Complete could answer the following for me:
1. Is this actually a good way to develop in Test Complete?
2. Are there any considerations regarding load order?
3. Are there any memory considerations?
4. Any other considerations you can think of would be useful