Monthly Archives: January 2015

Visual Studio 2015 + Cordova + Android Device deployment for Debugging

Purpose of this blog in to provide additional steps that needs to be done post installation of Cordova  tools for Visual Studio 2015.

  • Follow steps to install Visual Studio 2015 and Cordova tools as per MSDN documentation. You can follow the steps as mentioned in the MSDN documentation  https://msdn.microsoft.com/en-us/library/dn879821(v=vs.140).aspx
  • Had followed steps of not installing manually, followed default installation steps of installing cordova tools which gets installed post visual studio installation.
  • Post this for my Application was getting errors of
    • Exit Code 2
    • Exist Code 8.
  • To resolve these steps did following steps
    • Add Environment Variable JAVA_HOME and set the value to “C:\Program Files (x86)\Java\jdk1.7.0_55” which is default installation location by Visual Studio Installation
    • Added ADT_HOME environment variable with value “C:\Program Files (x86)\Android\android-sdk” which is default installation location by Visual Studio Installation
    • Added ANT_HOME environment variable with value “C:\Program Files (x86)\Microsoft Visual Studio 14.0\Apps\apache-ant-1.9.3” which is default installation location by Visual Studio Installation
    • Configure path variable to append following “%JAVA_HOME%\bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%ANT_HOME%\bin;”
Advertisements

Revealing Module Pattern in Java Script

The Revealing Module Pattern is based on a pattern referred to as the Module Pattern. It focuses on public & private methods. The only difference is that the revealing module pattern was engineered as a way to ensure that all methods and variables are kept private until they are explicitly exposed; usually through an object literal returned by the closure from which it’s defined. it help in following ways

  • Cleaner approach for developers
  • Supports private members and functions
  • Less clutter in the global namespace
  • Localization of functions and variables through closures.
  • Syntax of our scripts are even more consistent
  • Explicitly defined public methods and variables which lead to increased readability

This pattern allows the syntax of our scripts to be more consistent. It also makes it more clear at the end of the module which of our functions and variables may be accessed publicly which eases readability.

var math = (function () {
    function addition(a, b)
    {
        return a + b;
    }
 
    function subtraction(a, b)
    {
        return a - b;
    }
 
    return {
        add: addition,
        subtract : subtraction
    };
})();

Client consuming the math module would consume in following manner.

<script >
     var a = 30;
     var b = 20;
     console.log(math.add(a, b));
     console.log(math.subtract(a, b));
 </script>

A disadvantage of this pattern is that if a private function refers to a public function, that public function can’t be overridden if a patch is necessary. This is because the private function will continue to refer to the private implementation and the pattern doesn’t apply to public members, only to functions. Public object members which refer to private variables are also subject to the no-patch rule notes above.

Tech Interview App – Android Store – Try it and let me know Feedback…

Try my Android Store App – App Contains Categorized Q&A for tech categories focus on OSS stack (Angular, Node) for building hybrid apps as well as  MS Stack (.NET, ASP.NET, MVC, Web API…). Provides Question Count Statistics as well categorized question count break down. Questions and Answers periodically without app upgrade.

Tech Interview App

Android Store Listing

App is built using HTML 5, Angular JS and Web API in the back Ground.

Plan is to add Questions Weekly to the Respository and make more enhancements :).

1 2 3 4 5 6 7

Send Feedback…..

Hash Table Data Structure Demistified

A hash table is made up of two parts: an array (the actual table where the data to be searched is stored) and a mapping function, known as a hash function. The hash function is a mapping from the input space to the integer space that defines the indices of the array. In other words, the hash function provides a way for assigning numbers to the input data such that the data can then be stored at the array index corresponding to the assigned number.

  • Hash tables are used to quickly store and retrieve data (or records).
  • Records are stored in buckets using hash keys
  • Hash keys are calculated by applying a hashing algorithm to a chosen value contained within the record. This chosen value must be a common value to all the records.
  • Each bucket can have multiple records which are be organized in a particular order.

So a hash table is a data structure that stores key/value pairs and can be quickly searched by the key. Because insertion and removal are operations dependent on the speed of the search, they tend to be fast as well.
HashTable

Handling the collisions
In the small number of cases, where multiple keys map to the same integer, then elements with different keys may be stored in the same “slot” of the hash table. It is clear that when the hash function is used to locate a potential match, it will be necessary to compare the key of that element with the search key. But there may be more than one element which should be stored in a single slot of the table. Various techniques are used to manage this problem:

  • chaining
  • overflow areas
  • re-hashing
  • using neighbouring slots (linear probing)
  • quadratic probing
  • random probing
  • Chaining : Hangs an additional data structure off of the buckets. For example the bucket array becomes an array of link list. So to find an item we first go to the bucket then compare keys.. This is a popular method, and if link list is used the hash never fills up.
    HashTable1
  • Overflow areas: It will divide the pre-allocated table into two sections: the primary area to which keys are mapped and an area for collisions, normally termed the overflow area. When a collision occurs, a slot in the overflow area is used for the new element and a link from the primary slot established as in a chained system. This is essentially the same as chaining, except that the overflow area is pre-allocated and thus possibly faster to access. As with re-hashing, the maximum number of elements must be known in advance, but in this case, two parameters must be estimated: the optimum size of the primary and overflow areas.
    HashTable2
  • Re-hashing: Re-hashing schemes use a second hashing operation when there is a collision. If there is a further collision, we re-hash until an empty “slot” in the table is found. The re-hashing function can either be a new function or a re-application of the original one. As long as the functions are applied to a key in the same order, then a sought key can always be located. Build a second table twice as large as the original and rehash there all the keys of the original table. Rehashing is expensive operation, with running time O(N). However, once done, the new hash table will have good performance.
    HashTable3
  • Linear Probing:On a collision, look in the neighbouring slot in the table. It calculates the new address extremely quickly and may be extremely efficient. Distance between probes is constant (i.e. 1, when probe examines consequent slots)
    HashTable4
  • Quadratic Probing: Distance between probes increases by certain constant at each step (in this case distance to the first slot depends on step number quadratically). The simplest form of quadratic probing is really just adding consequent squares to the calculated position instead of linear 1, 2, 3.