Sunday, November 29, 2015

Angularjs Routing Recipe with classic asp.net mvc application

Introduction
In the last two years, I have been learning angular js Module Pattern. The power of the AngularJS Framework, It’s really amazing and the good stuff is that you can do quickly. One of the thing in AngularJS is impressed me is the routing Framework. Now I want to try and share some of the knowledge that I have found what is Routing and how to configure and work with classic asp.net mvc application.

Source Code Here 

Background

In a classic ASP.NET MVC application, stepping between parts of the application usually requires a trip to the web server to refresh the entire contents of the page. However, in a Single Page Application (SPA), only elements within the page are updated giving the user a better, more responsive experience.
In classic asp.net mvc implementation may still make transitions to other sections of the application with a full page refresh,but generally a single page manages the application’s functionality through dynamic views and web service (AJAX) calls.AngularJS supports dynamic views through routes and the ngView directive and your MVC application would provide the partial views that the ngView directive will dynamically load.

Using the code

In this example, the views, called Home, About, and Contact, are simple partial views rendered by the MVC controller.


 public class HomeController : Controller  
   {  
     public ActionResult Index()  
     {  
       return View();  
     }  
     public ActionResult Home()  
     {  
       return PartialView();  
     }  
     public ActionResult About()  
     {  
       return PartialView();  
     }  
     public ActionResult Contact()  
     {  
       return PartialView();  
     }  
   }  



App.js this is the file which is going to have the AngularJS application module declared in it. Also the state navigation declared.Ok, let us see the configurations one by one.

Routes are used by the ngView directive which has the responsibility of loading the route’s content. As the routes change, the content gets automatically updated.

<div ng-view></div>.


 'use strict';  
 var app = angular.module('App',['ngRoute']);  
 app.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {  
     $routeProvider.when('/', {  
       templateUrl: '/Home/Home',  
       controller: 'homeCtrl',  
     });  
     $routeProvider.when('/About', {  
       templateUrl: '/Home/About',  
       controller: 'aboutCtrl',  
     });  
     $routeProvider.when('/Contact', {  
       templateUrl: '/Home/Contact',  
       controller: 'contactCtrl'  
     });  
     $routeProvider.otherwise({  
       redirectTo: '/'  
     });  
   }]);  

This line delcares the AngularJS module and the 'ngRoute' module injected into it.


 App.config(function ($stateProvider, $urlRouterProvider) {  
 }  



The above line is the state routing configuration which will be declared using the .config function
the $routeProvider and $locationProviderare the services which are available to handle the state navigation. The state navigation declaration has the following parameters,
stateName, Template or TemplateURL and the Controller




Friday, November 27, 2015

Design Pattern Overview

Many people teach design patterns as a fundamental step to Object Oriented Programming.
In this post we are going to discussing ideas design pattern more details step by step
with my fellow code junkies.

Now question what actually design patterns represent in software development?
Design patterns represent the best practices used by experienced object-oriented software developers.Design patterns are solutions to general problems that software developers faced during software development.

Design Patterns have two main usages in software development. This are the common platform for developers and best practices.

In this article post discussion will be covering...

1)What they are?
2)Where they came form?
3)Why they matter?

Software professionals may be familiar with the term "Design Patterns," but many have no idea of where they come from and what they truly are.Consequently, some do not see the value and benefits design patterns bring to the software development process.

What Design Patterns are?


  1. General and reusable solutions or template to common problems in software design
  2. Not a finished solution
  3. A template or recipe for solving certain problems
  4. With names to identify them


Patterns deal with:


  1. Application and system design
  2. Abstractions on top of code
  3. Relactionships between classes or other collaborators
  4. Problems that have already been solved


Patterns are not concerned with:


  • Algorithms
  • Specific implementations or classes...


Design Patterns History:
 Design Patterns: Elements of Reusable Object-Oriented Software in 1994 by Gang of Four: Eric Gamma,Richard Helm, Ralph Johnson, and John Vlissides.
This book is considered to be the "coming out" of design patterns to the software community.
In 1998, the Gang Of Four were awarded Dr Dobbs Journal 1998 Excellence in Programming Award.


Design Patterns Structure:

Term Descrition
Pattern Name     Describes the essence of the pattern in a short
Intent Describes what the pattern does
Also Known As   List any synonyms for the pattern
Motivation Provides an example of a problem and how the pattern solves that problem
Applicability                Lists the situations where the pattern is applicable
Structure                     Set of diagrams of the classes and objects that depict the pattern
Collaborations Describes how the participants collaborate to carry out their responsibilities


Design Patterns Benefits
Design patterns have two major benefits. First one, they provide you with a way to solve issues related to software development using a proven solution.
Second one, design patterns make communication between designers more efficient.

Wednesday, November 11, 2015

What are the different types of Assembly?

There are two types of assemblies are there in .net. They are, 
1. Private Assemblies and 
2. Public/Shared Assemblies. 

Private Assembly:- An assembly is used only for a particular application. It is stored in the application's directory other wise in the application's sub directory. There is no version constraint in private assembly. 

Public Assembly:- It has version constraint. This public assembly is stored inside the global assembly cache or GAC.GAC contains a collection of shared assemblies.

What is a Assembly?


In more simple terms Assembly is unit of deployment like EXE or a DLL.
Precompiled code that can be executed by the .NET runtime environment.

Multiple versions can be deployed side by side in different folders. These different
versions can execute at the same time without interfering with each other.
Assemblies can be private or shared. For private assembly deployment, the
assembly is copied to the same directory as the client program that references it. No
registration is needed, and no fancy installation program is required. When the
component is removed, no registry cleanup is needed, and no uninstall program is
required. Just delete it from the hard drive.

In shared assembly deployment, an assembly is installed in the Global Assembly
Cache (or GAC). The GAC contains shared assemblies that are globally accessible
to all .NET applications on the machine.

What is a Managed Code?

Managed code runs inside the environment of CLR that is .NET runtime. In short, all IL i mean Intermediate Language  are managed code.

However, if you are using some third party software example VB6 or VC++
component they are unmanaged code, as .NET runtime (CLR) does not have control over the
source code execution of these languages.

Sunday, November 8, 2015

Remove duplicate from list c#




list.Sort();  
Int32 index = 0;  
while (index < list.Count - 1)  
{  
if (list[index] == list[index + 1])  
list.RemoveAt(index); 
        else index++; 
}

Thursday, October 29, 2015

What is an IL?

What is an IL?

(IL)Intermediate Language is also known as MSIL (Microsoft Intermediate Language) or CIL
(Common Intermediate Language). All .NET source code is compiled to IL. IL is then converted
to machine code at the point where the software is installed, or at run-time by a Just-In-Time
(JIT) compiler.