Skip to main content

Posts

Showing posts from 2014

Single page application (SPA) using ext.js

what is spa? Single page application are applications that fit in one page with rich and fluid user experiences like a desktop based applications. Why is SPA? All web based elements (html, CSS,javascript) are downloaded from the server on single page load and avoid the continuous page post back. i can explain what this mean. Suppose your web application is made of certain flow and it consists of 5 different pages. Each page need to get data from the user and save before moving to the next page. So when we navigate from one page to other it need to make a round trip to server to store the data in one page and get the data for the next page to display. but in spa we can avoid the continuous post backs. The whole page will not post back any time other than the first load. But it communicate to the server dynamically behind the scene and can achieve the same functionality. Spa using ext.js designing a SPA using ext.js is a challenging task if you are unaware about the ext.js framework or simil…

Prototype in Javascript

Prototype are link or pointer to other objects. All objects have prototype. Objects are chained together by the prototype chain.

//Constructor
function Office(name, location, domain)
{
this.name=name;
this.location=location;
this.domain=domain;
}

//Prototype


Office.Prototype={
    interview: function(){
alert("Hi office location is"+ this.location);
}
};

var myoffice= new Office("expo-e", "london", "telecommunication");

myoffice.interview; // hi office location is london

In the above example

myoffice prototype is shared with Office
Office prototype is shared with object
Object prototype is shared with null

myoffice->Office->Object->null, makes the complete chain of prototype.

when you lookup a property on an object, it will walk up the prototype chain until its found. First my office  is checked then the Office is checked, then object and finally it reaches null.

Javascript Closures

A Javascript closure is when an inner function is inside of an outer function (a function inside a function). The inside function has access to

1. Variables defined in the outer function
2. Argument passed into the outer function

var CreateExample= function(example){
                                    return function(text){
                                              console.log(example +" "+ text);
                                       }
};


var example1= CreateExample("Hi");
var example2= CreateExample("Hello");

example1("test one");   //Hi test one
example2("test two");  //Hello test two.

In most object oriented languages like java/c#, when you reach return all variables declared inside that function get destroyed and memory is freed up.

IN javascript, when creating a closure and return as function, all local variable will remain in memory and accessible.

Can we store wifi and use it later?

I started using WIFI almost 8 years back (in 2006) when I moved to the UK. Before that, during the engineering degree I studied about WIFI energetically for achieving grades. Nowadays it’s a common friend and every day without her presence, it is awful to envisage. One day my data allowance on the mobile run out and I want to go to an event in central London and want to use the GPS. I had to take map printout and follow the route. I depend a lot on GPS navigation rather than a paper map. So I reached the location half an hour later in the event. Eventually I missed the event and while walking back to the tube station I was thinking about storing the WIFI somehow and using it later, like a battery. People might think why can’t I carry a portable modem and a laptop, but I am thinking about much sophisticated device than that like a battery for the phone. Did anyone think about a life without batteries now? It is there since most of us on this planet born. In 1749 Benjamin Franklin firs…

How to do Auditing in web application with Context Info

Background 
Last couple of days I had issues while trying to implement the audit in one of the asp.net application.  Especially if tables don’t have the structure to accommodate who modified or when modified fields. So what will do? Is it practical to add all this fields in tables and implement auditing? Yes if you have 5 or 10 tables. What happens if there are 100’s of tables?
 I came across this issue. Fortunately some one told about the ContextInfo. Before starting a database connection set the context info with the current user details. And when the operation finishes call a trigger and update the auditing table with contextInfo.
What time context info update? For all db operation a connection need to open. So conextinfo can be set after the open connection.
 create an OpenConnection() method in the base class which all Execute…() methods call, instead of calling cmd.Connection.Open() directly. Then call SetConext method there.
Implementation
1. OpenConnectioninternaloverridevoid OpenCon…