Skip to main content

Posts

Javascript: the module pattern

The module pattern is defined by two things. 1-An outter wrapping function 2-An returned object containing at least one function It was initially introduced a decade ago by Douglas Crockford in order to provide encapsulation, therefore exposing only what is needed, reducing the risk users would access, undocumented features.  

Javascript: Closure and Lexical Scope

The two are separate topics, I just happen to put them in the same post for now. Closure Closure is the capability to remember it's lexical scope, even when executed outside it's lexical scope. If two inner functions, are within the same scope, they share the same closure.     Lexical scope The lexical scope is the scope in which a variable is declared during the first pass of the javascript compilation, which has two passes, compilation and execution. During the compilation pass, the compiler goes through the code looking for formal declaration, that is, var, function and parameters of function. For each of these formal declarations, the compiler will check the current lexical scope, and add this identifier if it isn't already there. Then at the second pass, execution, the compiler will run the code as we are intuitively use to and once it reaches the the identifiers found earlier, will ask if they are left hand side(RHS), or right hand side (LHS). If th...

Javascript: The 'this' keyword

Here is a summary of the 4 rules defining the value of 'this': 1-Was the function called with the new keyword? If so, use that object. 2-Was the function called explicitly with call or apply? Use the passed in object. 3-Was the function called implicitly with the dot operator? Use the owning object, also called base object or context object, which means the object to the left of the dot of the function invocation. 4-If none of the above, the default rule applies, 'this' is the global object, except if in strict mode, 'this' is set to undefined.    

Javascript: It`s misunderstood concepts

Javascript gained in popularity in the last decade following Google`s V8 engine then client side frameworks like AngularJs and server side development in NodeJs. According to StackOverflow`s 2015 survey, Javascript is the most used programming language. Yet many still compare using this language to dancing in the minefield. Javascript does have many concepts that are often misunderstood. For example the `this` keyword, doesn't behave the same as in C, C++, or Java. Coming from these language means almost forgetting anything we know about 'this' when learning how 'this' behaves in Javascript. Other misunderstood concepts of Javascript are: Scope, proto chains, hoisting and closures. I will summarize some of these key concepts in the following blog posts.

70-562 Dynamic Data

Object Relational Mappers,  for example Linq and Entity Framework are well integrated in VS 2008, and have project template available; Dynamic Data Web Site. Creating a dynamic data web site project is a good way to explore the server controls and datasources offered via the toolbox menu. This template starts out witha basic website shell, but the connection string isnt configured. The Linq to SQL and Entity to SQL are the ORM offered and by default use the default databse located in App_Data folder of this template project. The designer.cs file defines the data model and wraps the objects around it in order to access the data model via code. In the global.asax contains the RegisterRoutes method that comes with a default model.RegisterContext method of the type YourDataConectType, you will replace this one with your data context which, after having created the model pointing to your database should be avaialble in intellisence under the name yourDatabaseNameDataContext. Sc...

70-562 Security Trimming

Security Triming is achieved by putting a web.config in each folder... each aspx file has its own folder denies * all users, and  db tables in the app_data folder can be maintained with the website administration tool wwebadmin tool can be started from website->configuration then you click on the security link, then manage users so there's two layers of security, the ones in the app_data folder and the ones in web.config that overide app_data. Web adminstration tool can use both both form and windows authentication, windows is handled by iis there is a control for the login button, and one to display the login user user in the sitemap section of the web.config needs to say securityTrimming enabled if a node doesnt have a page associated with it, the node needs to have roles attribute to allow to access to any pages in it's subfolder, or is this just to show the menu item in the sitepath control? Giving roles to a sitemap node just show the node do...

70-562 Navigation API

You can add custom attributes for each node in the xml file, like the sound and image of an animal to set to label and img you can check if there is a previous sibling to add a previous button(set the button to visible, do all this in page_load in general when testing new features, you can add a checkbox to display info to make sure you can read it, even it's if its irrevelant for the user to see, you just add labels at the bottom of the page, and you can even add this in the master page as a footer, you could put all this in the server div control and use innerHTML property you can use it for rewriting(rerouting) urls so they dont include query string, in the web.config in urlMappings element. Might want to put these mappings in an external .config (set the configSource attrtibute of the urlMappings elementconfiguration file, external config change doesnt cause an application restart. Setting the url in the sitemap file also allows to remap urls sitemap files to ...