Running Angular 2 app in Android Emulator with NativeScript

This post is about running an Angular 2 app in Android emulator.

We have seen that the documentation provided on internet is not the way it should be. This is because it includes four entirely different setups (Node, Android SDK, NativeScript and GIT). Issues occurs and we end up in wasting much time in internet search to fix those issue. We know the issues well and hence have tried to document this process from scratch where you have just....
>>>> Windows 10 installed on your machine.  .... And Nothing Else

Please follow the mentioned steps in sequence (remember the only pre-requisite being Windows 10).

1) Install Node js version 6.7.0 or later. 

You can download the same from -

2) NodeJS version check.

Post node.js installation, open "Node.js command prompt" from Start menu. Check the node and npm versions. Make sure you have these or later versions.

For npm version : npm -v
For node version : node -v

3) Nativescript library for Nodejs installation.

Run the following command to install native script package from Node.js command prompt

npm install -g nativescript

4) Nativescript nodejs libriary installation verification.

To verify the telerik nativescript installation, type "tns" and hit enter in the command prompt.

5) Android SDK installation:

Go to the website -

Scroll to the bottom.

We don't need to install the entire Android Studio, just click on the highlighted link to download the Android Software Development Kit. Install the SDK after download.

Now, you should be seeing two applications installed in "All Programs" menu from Start button.

6) Android packages installation.

Right click SDK Manager and "Run as administrator".

Check three options under "Android 6.0 (API 23) and click "Install packages".

Also, Check four options under "Extras".

7) Android Virtual Device configuration.

Right click on AVD (Android Virtual Device) manager from "Start Menu" and click "run as administrator".

In AVD Manager home screen, click "Create" and enter the exact following information. Click OK.

After this, you should be seeing this screen.

8) Andriod HAXM installation.

Go to the folder - "C:\Program Files (x86)\Android\android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager"

Double click - "intelhaxm-android.exe" to execute the wizard and finish the set up.

9) Andriod Emulator preview.

Now in AVD Manager, click on "Start" on the right side options. The following screen should appear.

10) Nativescript for Windows installation.

Open Command prompt from "Start" menu as an administrator and paste the following command and hit enter to execute.

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString(''))" 

Verify the set up by executing the below command.

tns doctor

If you see "No issues were detected" you are good to go!

11) GIT installation.

Go to the URL -

and click "Windows" under "Downloads" section. After download install the setup.

12) Nativescript's Angular 2 sample app setup.

Create a folder in any location in your drive. (say test)

Now, from start menu - Open "Git Bash" as an administrator.

In Git bash, go to the location where you have created the "test" folder. Paste the following to Git clone a sample nativescript app.

git clone
In Git bash, go to the repo folder

cd sample-Groceries

In Git bash, check out the version

git checkout angular-start

11) Sample app execution in Andriod simulator.

Open command prompt as an administrator and go to the "sample-Groceries" folder created in previous step. Paste the below command and hit enter to execute.

tns platform add android

now run the following command :

tns run android --emulator

You should be seeing the "Hello World" app hosted in the Android emulator.

12) Congratulation! 

You have successfully created and Angular 2 app in Android with NativeScript.

Note : Please post comments, in case you find any issues. Thanks!

Object Oriented Programming - Design Patterns

Christopher Alexander says, "Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice". Even though Alexander was talking about patterns in buildings and towns, what he says is true about object-oriented design patterns. Our solutions are expressed in terms of objects and interfaces instead of walls and doors, but at the core of both kinds of patterns is a solution to a problem in a context.

Design patterns vary in their granularity and level of abstraction. Because there are many design patterns, we need a way to organize them. Patterns can have either Creation, Structural, or Behavioral purpose.


Factory Method

Template Method
Abstract Factory
Chain of Responsibility






Design pattern space

A) Creational Pattern

Creational design patterns abstract the instantiation process. They help make a system independent of how its objects are created, composed and represented.

1) Abstract Factory

Provide an interface for creating families of related or dependent objects without specifying their concrete classes.

2) Builder

Separate the construction of a complex object from its representation so that the same construction process can create different representations.

3) Factory Method

Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

4) Prototype

Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.

5) Singleton

Ensure a class only has one instance, and provide a global point of access to it.

B) Structural Pattern

Structural patterns are concerned with how classes and objects are composed to form larger structures.Structural class patterns use inheritance to compose interfaces or implementations.

1) Adapter

Aka: Wrapper
Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.

2) Bridge

Aka: Handle/Body
Decouple an abstraction from its implementation so that the two can vary independently.

3) Composite

Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

4) Decorator

Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

5) Façade

Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.

6) Flyweight

Use sharing to support large numbers of fine-grained objects efficiently.

7) Proxy

Provide a surrogate or placeholder for another object to control access to it.

Note : Composite versus Decorator versus Proxy

Composite and Decorator have similar structure diagrams, reflecting the fact that both rely on recursive composition to organize an open-ended number of objects. The similarity ends at recursive composition, again because of differing intents.
Decorator is designed to let you add responsibilities to objects without subclassing. It avoids the explosion of subclasses that can arise from trying to cover every combination of responsibilities statically. Composite focuses on structuring classes so that many related objects can be treated uniformly, and multiple objects can be treated as one.
In the Proxy pattern, the subject defines the key functionality, and the proxy provides (or refuses) access to it. In Decorator, the component provides only part of the functionality, and one or more decorators furnish the rest.

C) Behavioural Patterns

Behavioural patterns are concerned with algorithms and the assignment of responsibilities between objects. These patterns characterize complex control flow that's difficult to follow at run-time.
They shift your focus away from flow of control to let you concentrate just on the way objects are interconnected.

1) Chain of Responsibility

Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.

2) Command

Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undo-able operations.

Aka: Action, Transaction

3) Interpreter

Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.

4) Iterator

Provide a way to access the elements of an aggregate objects equentially without exposing its underlying representation.

Aka: Cursor

5) Mediator

Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.

6) Memento

Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later.

Aka: Token

7) Observer

Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

Aka: Dependents, Publish-Subscribe

8) State

Allow an object to alter its behavior when it’s internal state changes. The object will appear to change its class.

9) Strategy

Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

Aka: Policy

10) Template Method

Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.

11) Visitor

Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.

Credits : Gang of Four

Big Data Journey to MongoDB

MongoDB is being used as one of the key technology for storing data in recent time because of it's flexibility and scalability; but many of us don't know the journey behind it since Big Data concept came into picture. This is important to know so as to ensure its advantages can be utilized in a correct way. We at Witspry tried to make the explanation in the easiest possible way.

What is Big Data?

It is a data with these three characteristics:

1) Volume
2) Velocity, and
3) Variety

Big data can be subjected to three categories of data types:

1) Structured data for e.g. Relational data
2) Semi-structured data for e.g. XML which is more or less flexible, and
3) Unstructured data for e.g. Word, PDF. Text, Audio, Video etc.

Big Data technology class

Big data is categorized majorly in two technology classes - Operational & Analytical.

One Big Data implementation - Hadoop Framework

Hadoop is a framework that has implemented the Big Data concept.

One top key technology in Big Data - No SQL

Due to the flexible data structure, No SQL is one of the top data access storage framework of the Big Data implementation suite.

One implementation of No SQL Document data model - MongoDB

What is MongoDB?

MongoDB is an open-source document database that provides high performance, high availability and automatic scaling.

Document Database

A record in MongoDB is a document, which is a data structure composed of field and value pairs. MongoDB documents are similar to JSON objects. The values of fields may include other documents, arrays and arrays of documents.

Advantages of using documents:

1) Documents (i.e. objects) correspond to native data types in many programming languages.
2) Embedded documents and arrays reduce need for expensive joins.
3) Dynamic schema supports fluent polymorphism.

Key features:

High Performance

MongoDB provides high performance data persistence. In particular,
  • Support for embedded data models reduces I/O activity on database system.
  • Indexes support faster queries and can include keys from embedded documents and arrays.

High Availability

To provide high availability, MongoDB's replication facility, called replica sets, provide:
  • Automatic fail-over.
  • Data redundancy