September 2011 - Posts

Javascript Namespace and Module Pattern

I’ve just got a chance to review this Book “Java script Pattern”, the author is the SA of Yahoo, as you might guess YUI.

For ages we know how to make Namespace in JS, but making as a function , that rocks.

I’ve only quick look on Chapter 5.

//Declare the root and namespace function

var Myapplication = Myapplication || {};
Myapplication.namespace = function (ns_string) {    
var parts = ns_string.split('.'),        
parent = MYAPP,        i;   
 // strip redundant leading global  
 if (parts[0] === "MYAPP") {     
   parts = parts.slice(1);   
 for (i = 0; i < parts.length; i += 1) {        // create a property if it doesn't exist   
     if (typeof parent[partsIdea] === "undefined") {         
   parent[partsIdea] = {};      
  }        parent = parent[partsIdea]; 
   }    return parent;};
//to get the module example
var IneedModule2=Myapplication.namespace('Myapplication.Order.module2');
//Declaring dependency on top of function declaration,So that when minified it doesn’t break
var myFunction = function () {
    // dependencies
    var event = YAHOO.util.Event,
        dom = YAHOO.util.Dom;
    // use event and dom variables
    // for the rest of the function...


Way of creating object , could use regular function constructor, or wrap it in immediate function

//using function for creating object
function Gadget() {
    // private member
    var specs = {
        screen_width: 320,
        screen_height: 480,
        color: "white"
    // public function
    this.getSpecs = function () {
        return specs;
//Creating Object not using regular function
//can we still have private memberS?
//everything inside closure by making immidiate function is private
var toy;
(function () {
 // private member
    var specs = {
        screen_width: 320,
        screen_height: 480,
        color: "white"
    // public function
    toy= {
    getSpecs :function () {
        return specs;
Passing in globalobject and application to consume locally
var GLOBALUTILIY={d:1,e:2};   
var MYAPP = MYAPP || {};
MYAPP.utilities.module = (function (app, global) {
    // references to the global object
    // and to the global app namespace object
    // are now localized

}(MYAPP, this)); // DIRECTLY CALL IT passing GLOBAL as THIS(global scope)
                   // Passing MYAPP as app;


You can all read a long , how to declare other thing on that chapter by your self

Share this post: | | | |
Posted by cipto with no comments

CRM 2011, Could not load file or assembly Microsoft.Crm.Sdk, Version=

If you had a previous application from CRM 4 SDK., running on a Server which has CRM 2011 installed, this message appear.

although you have the CRM 4.0 SDK.dll In your bin, it will still look for 5 th version.

the reason is the publisher policy file, told it automatically use the latest one when encountered this dll.

if you still want your existing app to run on that box,the solution is to turn it off

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity name="Microsoft.Crm.Sdk" publicKeyToken="31bf3856ad364e35"
<publisherPolicy apply="

Share this post: | | | |
Posted by cipto with no comments