Skip to main content

closures, Ajax, javascript and the hard easy....

A key aspect of AJAX based development is the use of javascript to provide the A in the Jax, all the buzz over web 2.0 is boiled down to one single javascript object now implemented in all major browsers that was first conceived (amazingly) by Microsoft.

XmlHttpRequest

This object allows the set up of an asynchronous http request, essentially a request that is not tied to the state of the currently requested page resource by the users. Allowing separating of requests from the resource allows us to retrieve resources at different times , hence the that Asynchronous word. Anyway , the object is great , has simple methods for passing in the url and does what it was made to do but because javascript forces some interesting issues to crop up.

Closures:

In javascript the closures allow a function declaration to persists the current state of a calling function in order to await a response from another objects execution. Since XHR objects process asynchronously they are tailor made to be used with closures in order to perform important functions. (Like allow background updates to sections of an html page without refreshing the whole page) There you go, all of web 2.0 bubbles out of clever use of this object to provide the illusion of more responsive web applications. Unfortunately, closures are not very elegant programming constructs and as implemented in javascript , they can lead to the leaking of resources (memory) especially when periodic polling using the XHR object of server resources continue to await asynchronous results. Since the reference to the XHR object is always contingent on a previous asynchronous result being returned they (more specifically the associated resources for any variables defined in the XHR asynchronous call object scope) end up piling up in the memory of the browser and in time reduce the responsiveness of the application.

I spent all day today trying to come up with a solution for the slow leak that results from the necessary use of closures and XHR objects in my management UI, what struck me is just how many articles there are online that have a mistaken understanding of what is going on. There are a few great sources and then a ton of misnomers, many believed that simply setting objects after use would solve the problem but the particular invocation steps taken by javascript thwarts that potential solution. This brings me to a funny truth, the media is all in a tizzy sometimes over making a distinction between AJAX and javascript and anyone who has done AJAX knows you do it with javascript (that's the "J" ) It is funny how often this mistake is made in the trade magazines that are supposed to keep technology professionals aware of the latest trends. It just underscores an observation I've made since I was an undergraduate electrical engineering student.

Things are a lot easier than most people believe them to be.

Learning a thing always brings it from the stratospheric realm of the impossible to the trivial the difference in perceptions lies in how much relative work is done by individuals to get to a given level of understanding of the topic, but once that knowledge is had ..what was hard or impossible, many times looks exceedingly easy.



Comments

Popular posts from this blog

Highly targeted Cpg vaccine immunotherapy for a range of cancer

Significance?


This will surely go down as a seminal advance in cancer therapy. It reads like magic:

So this new approach looks for the specific proteins that are associated with a given tumors resistance to attack by the body's T cells, it then adjusts those T cells to be hyper sensitive to the specific oncogenic proteins targeted. These cells become essentially The Terminator​ T cells in the specific tumor AND have the multiplied effect of traveling along the immune pathway of spreading that the cancer many have metastasized. This is huge squared because it means you can essentially use targeting one tumor to identify and eliminate distal tumors that you many not even realize exist.

This allows the therapy for treating cancer to, for the first time; end the "wack a mole" problem that has frustrated traditional shot gun methods of treatment involving radiation and chemotherapy ...which by their nature unfortunately damage parts of the body that are not cancer laden but …

Engineers versus Programmers

I have found as more non formally trained people enter the coding space, the quality of code that results varies in an interesting way.

The formalities of learning to code in a structured course at University involve often strong focus on "correctness" and efficiency in the form of big O representations for the algorithms created.

Much less focus tends to be placed on what I'll call practical programming, which is the type of code that engineers (note I didn't use "programmers" on purpose) must learn to write.

Programmers are what Universities create, students that can take a defined development environment and within in write an algorithm for computing some sequence or traversing a tree or encoding and decoding a string. Efficiency and invariant rules are guiding development missions. Execution time for creating the solution is often a week or more depending on the professor and their style of teaching code and giving out problems. This type of coding is devo…

AgilEntity Architecture: Action Oriented Workflow

Permissions, fine grained versus management headache
The usual method for determining which users can perform a given function on a given object in a managed system, employs providing those Users with specific access rights via the use of permissions. Often these permissions are also able to be granted to collections called Groups, to which Users are added. The combination of Permissions and Groups provides the ability to provide as atomic a dissemination of rights across the User space as possible. However, this granularity comes at the price of reduced efficiency for managing the created permissions and more importantly the Groups that collect Users designated to perform sets of actions. Essentially the Groups serve as access control lists in many systems, which for the variable and often changing environment of business applications means a need to constantly update the ACL’s (groups) in order to add or remove individuals based on their ability to perform certain actions. Also, the…