Posts

Abstract Factory design pattern analysis

Image
What is Abstract Factory design pattern?


The intent or definition of Abstract Factory is
Provide an interface for creating families of related or dependent objects without specifying their concrete classes
It is kind of an obscure definition, in order to understand it we need to break it into meaningful pieces.



1.  "Provide an interface" 
When we talk about Abstract Factory we talk about interface not abstract class, Basically this design pattern gives us an Interface, like Interface in Java, C# , Typescript (abstract class).   
Why interface?  Whenever we talk about any design pattern, it emphasizes more on how we are going to use it rather than implement it.
Interface is always the right type to prefer because concrete class creates tight coupling whereas an interface isolates it from the rest of the system. At runtime we can get different solution, without updating our code.

For example

interfaceSecurityFactory{AuthenticationManagergetAuthenticationManager();AuthorizationManage…

AngularJs Tutorials : Bootstrap

Image
Every application starts with bootstrap process which initialize application and wire it other with dependencies and configurations.

AngularJs is not different from other application. It also starts application with bootstrap process.

Following operation happens inside AngularJs bootstrap process.
Load application module. Create dependency injector and load dependencies. Compile HTML and create scope for application.
All these steps happens inside angular.js scripting file. therefore we need to include it first. we can include it inside HEAD tag or at end of BODY tag.
Note: Adding angular.js file at end of body tag will allow browser to load of HTML elements without any delay and afterwards load angular.js and begin bootstrapping process.
You can get angular.js source file from https://code.angularjs.org/

<script src=”https://code.angularjs.org/1.3.0/angular.js”type=”text/javascript”>
AngularJs bootstrap process happens on document ready event.


lets see the simple AngularJs example.

<html&…

MongoDB Tutorials : Aggregation Framework

Image
MongoDB Aggregation Framework groups set of documents together and performs certain operation on this grouped documents and returns results in the form of documents. MongoDB aggregation answer to those query which requires grouping of documents.

Aggregation framework works on three type of model Aggregation pipelineMap ReduceSingle Purpose Aggregation Operations

Now let see how MongoDB Aggregation Framework works with simple example.
Suppose you are MongoDB application developer in a respected company and you have been given a MongoDB database that holds information about human population which is distributed according to cities and their states.
here is one sample document.


{"city":"ACMAR","loc":[-86.51557,33.584132],"pop":6055,"state":"AL","_id":"35004"}
for this tutorial collection name is zips.
on first day your manager come and asks you to calculate total population of state DC.
your simplest approach to solve…