Showing posts with label Diffrence. Show all posts
Showing posts with label Diffrence. Show all posts

Friday, 25 September 2015

Abstract Vs Virtual


1. abstract function doesn't contain any body but a virtual function contain body
2. we must be implement the abstract function in derived class but it is not necessary for virtual function
3. abstract function can only use in abstract class but it is not necessary for virtual function
4. abstract function are called pure virtual function

Abstract Functions can not have any body or implementation while virtual Functions can have body or implementation ,abstract functions must be implementation by derived classes and virtual not must implementation by derived classes,both are override in derived classes


Abstract function:-->
1) An abstract function has no implementation. It can only be declared. This forces the derived class to provide the implementation of it.
2) Abstract means we MUST override it.
3) An abstract member is implicitly virtual. Abstract can be called as pure virtual in some of the languages.

Virtual Function:-->
1) Virtual Function has an implementation. When we inherit the class we can override the virtual function and provide our own logic.
2) We can change the return type of Virtual function while implementing the function in the child class(which can be said as concept of Shadowing).

3) Virtual means we CAN override it.

Thursday, 24 September 2015

Object, Dynamic and Var in c#

In this post I am going to write the points about the three type of the variable Object, Var and Dynamic. Most of the developer not able to get what is difference between this three kind of variable.ObjectDynamicVarCan able to store any kind of value, because object is the base class of all type in
In this post I am going to write the points about the three type of the variable Object, Var and Dynamic. Most of the developer not able to get what is difference between this three kind of variable.
ObjectDynamicVar
Can able to store any kind of value, because object is the base class of all type in .net framework.Can able to store any type of the variable, similar to old VB language variable.Can able to store any type of value but it require to initialize at the time of declaration.

Compiler has little information about the type

Compiler doesn't have any information about the this type of variable.

It's compiler safe i.e compiler has all information about the stored value, so that it doesn't cause any issue at run-time.

Object type can be passed as function argument and function also can return object typeDynamic type can be passed as function argument and function also can return object typeVar type can not be passed as function argument and function can not return object type. This type of variable can work in the scope where it defined.

Require to cast object variable to original type before using it. So this assigning to object type and converting to original type called as Boxing and Un-Boxing for value type and for the reference type its casting of types. It's actually increasing the overhead when we do this both operation.
Allows to perform operation of given type once it get cast any user defined or primitive data type.
Casting is not require but you need to know the property and methods related to stored typeNo need to cast because compiler has all information to perform operation.
Cause the problem at run time if the stored value is not get converted to underlying data type.

Cause problem if the wrong method or property accessed because all the information about stored value is get resolve only at run time

Doesn't cause problem because compiler has all info about stored value.
Useful when doesn't have more information about the data type.Useful when coding using reflection or dynamic language support or with the COM objects, because we require to write less amount of code.Useful when getting result out of the linq queries. In 3.5 framework it introduce to support linq feature.

Wednesday, 23 September 2015

Temp Table Vs Temp Variable in sql

Temporary Table
Table Variable
Temporary tables can be used in Stored Procedures, Triggers and Batches but not in user defined functions

Table variables can be used in user defined functions, stored procedures, and batches
Local temporary tables are temporary tables that are available only to the session that created them. Global temporary tables are temporary tables that are available to all sessions and all the users.
Its scope is in the stored procedure, user defined function or batch where it is declared like any local variable we create with a DECLARE statement.
Local temporary tables are automatically destroyed at the end of the procedure or session that created them. Global temporary tables are dropped automatically when the last session using the temporary table has completed
We can also drop temporary tables explicitly using drop command similar to normal table.

Table variables are automatically cleaned up at the end of the user defined function, stored procedure, or batch in which they are defined.
Temporary table name can be of maximum 116 characters
Table variable name can be of maximum 128 characters
PRIMARY KEY, UNIQUE, NULL, CHECK etc can be implemented at the time of creating temporary tables using CREATE TABLE statement or can be added after the table has been created. FOREIGN KEY not allowed.

PRIMARY KEY, UNIQUE, DEFAULT values, NULL, CHECK can be added, but they must be incorporated with the creation of the table in the DECLARE statement. FOREIGN KEY not allowed.
Temporary table supports adding Indexes explicitly even after creation and it can also have the implicit Indexes which are the result of Primary and Unique Key constraint.
Table Variables doesn’t allow the explicit addition of Indexes after it is declared, the only means is the implicit indexes which are created as a result of the Primary Key or Unique Key constraint defined at the time of declaring Table Variable.
Temporary tables can also be directly created and data can be inserted using Select Into statement without creating a temporary table explicitly.
Table variables can’t be created using Select Into statement because being a variable it must be declared before use

The SET IDENTITY_INSERT statement is supported in temporary table
The SET IDENTITY_INSERT statement is not supported in table variables
We can’t return a temporary table from a user-defined function

We can return a table variable from a user-defined function

Temporary Table can be truncated like normal table

Table variables can’t be truncated like normal table or temporary tables.

The data in the temporary table will be rolled back when a transaction is rolled back similar to normal table

The data in the table variable will not be rolled back when a transaction is rolled back

Temporary tables used in stored procedures cause more recompilations of the stored procedures than when table variables are used.

Table variables used in stored procedures cause fewer recompilations of the stored procedures than when temporary tables are used.

A temporary table will generally use more resources than table variable

A table variable will generally use less resources than a temporary table

Temporary tables can be access in nested stored procedures

Tables variables can’t be access in nested stored procedures

Can be altered using ALTER command
Does not support ALTER command

Temporary tables should be used for large result sets.
Table variables should be used for small result sets and the everyday type of data manipulation since they are faster and more flexible than temporary tables

Dotnet Hell or Dll-Hell

Problem of Dll-Hell

Introduction 
Before some time, if we install an application then dll of that application get stored in the registry, then if we install other application that has same name .dll  that means previously installed .dll get overwrite by the same name new .dll. Ok for newly installed application but previously installed application cant get execute further. This is big problem in context of version of same application. This is Dell-Hell problem.
OR
Dll Hell refers to a set of problems caused when multiple applications attempt to share a common component like a dynamic link library (DLL).The reason for this issue was that the version information about the different components of an application was not recorded by the system.

Solution of Dll-Hell Problem 
This problem of dynamic link library (.dll) is resolved through Versioning.

Versioning:
Versioning is the technique to provide version to the .dll to prevent them from replacement. GAC (Global assembly cache) is the separate memory like cache it is used to remove load form operating system.

To add version in assembly we just write in Program
 :

versin mmmmm.GIF

We can do versioning only with shared assembly because to install .dll in GAC so we need to have strong key name.

Authentication:verification, to be verify.

Authorization  :Providing Role, to provide power ,step after authentication in role. 

To see the parts of an assembly:
open cmd prompt of Visual studio and write - ILDASM

ILDASM: is a tool to see the content (metadata) of Assembly.

VB.net and c#.net difference


Advantages VB.NET :-
  • Has support for optional parameters which makes COM interoperability much easy.
  • With Option Strict off late binding is supported.Legacy VB functionalities can be
    used by using Microsoft.Visual Basic name-space.
  • Has the WITH construct which is not in C#.
  • The VB.NET part of Visual Studio .NET compiles your code in the background.
  • While this is considered an advantage for small projects, people creating very large projects have found that the IDE slows down considerably as the project gets larger.

Advantages of C#
XML documentation is generated from source code but this is now been incorporated
in Whidbey.
  • Operator overloading which is not in current VB.NET but is been introduced in
    Whidbey.
  • The using statement, which makes unmanaged resource disposal simple.
  • Access to Unsafe code. This allows pointer arithmetic etc, and can improve
    performance in some situations. However, it is not to be used lightly, as a lot of the
    normal safety of C# is lost (as the name implies).This is the major difference that you
    can access unmanaged code in C# and not in VB.NET.

Thursday, 10 September 2015

Difference between layer and tire

layer = a part of your code, if your application is a cake, this is a slice.
tier = a physical machine, a server.
A tier hosts one or more layers.

Example of layers:
  • Presentation layer = usually all the code related to the User Interface
  • Data Access layer = all the code related to your database access
Tier:
Your code is hosted on a server = Your code is hosted on a tier.
Your code is hosted on 2 servers = Your code is hosted on 2 tiers.
For example, one machine hosting the Web Site itself (the Presentation layer), another machine more secured hosting all the more security sensitive code (real business code - business layer, database access layer, etc.).

There are so many benefits to implement a layered architecture. This is tricky and properly implementing a layered application takes time. If you have some, have a look at this post of Microsoft:http://msdn.microsoft.com/en-gb/library/ee658109.aspx


N-layers of application may reside on the same physical computor(same tier) and the components in each layer communicates with the components of other layer by well defined interfaces. Layered architecture focuses on the grouping of related functionality within an application into distinct layers that are stacked vertically on top of each other. Communication between layers is explicit and loosely coupled. With strict layering, components in one layer can interact only with components in the same layer or with components from the layer directly below it.
The main benefits of the layered architectural style are:
Abstraction,Isolation, Manageability, Performance, Reusability, Testability.
N-tier architecture usually has atleast three separate logical parts, each located on separate physical server. Each tier is responsible for a specific functionality. Each tier is completely independent from all other tiers, except for those immediately above and below it. Communication between tiers is typically asynchronous in order to support better scalability.
The main benefits of tier achitecture styles are:
  • Maintainability: Because each tier is independent of the other tiers, updates or changes can be carried out without affecting the application as a whole.
  • Scalability: Because tiers are based on the deployment of layers, scaling out an application is reasonably straightforward.
  • Flexibility: Because each tier can be managed or scaled independently, flexibility is increased.
  • Availability: Applications can exploit the modular architecture of enabling systems using easily scalable components, which increases availability.

Types Of JIT Compiler :


·        PRE JIT Compiler.
·        ECONO JIT Compiler.
·         NORMAL JIT compiler.

   (1) PRE JIT Compiler : 
 
               Pre-JIt  compiler compiles complete source(MSIL)code to Native code in a single Compilation.

(2) ECONO JIT Compiler :

                This compiler compiles only MSIL code of those methods that are called at Runtime.

3) NORMAL JIT compiler:

                 This compiler compiles only MSIL code of those methods that are called at Runtime and that converted (native) code is stored in Cache.This happens beccause,when these methods called again it will retrieve code from cache itself without sending request to CLR.Thus,inturn saves much of Executiom time

Monday, 7 September 2015

Web Farm and Web Garden

Web Farm

This is the case where you have only one web server and multiple clients requesting for resources from the same server. But when are is huge amount of incoming traffic for your web sites, one standalone server is not sufficient to process the request. You may need to use multiple servers to host the application and divide the traffic among them. This is called “Web Farm”. So when you are hosting your single web site on multiple web servers over load balancer is called “Web Farm”. The below diagram shows the overall representation of Web Farms.
Web Farms
In general web farm architecture, a single application is hosted on multiple IIS Server and those are connected with the VIP (Virtual IP) with Load Balancer. Load Balancer IPs are exposed to external world to access. So whenever some request will come to server from clients, it will first hit the Load Balancer, then based on the traffic on each server, LB distributes the request to the corresponding web server. These web servers may share the same DB server or may be they can use a replicated server in the back end.
So, in a single statement, when we host a web application over multiple web servers to distribute the load among them, it is called Web Farm.

Web Garden

Now, let’s have a look at what is Web Garden? Both the terms sound the same, but they are totally different from each other. Before starting with Web Garden, I hope you have a fundamental idea of what an Application Pool is and what a Worker Process is. If you have already read the article, “How IIS Processes ASP.NET Request ?”, then I can expect that you now have a good idea about both of them.
Just to recall, when we are talking about requesting processing within IIS, Worker Process (w3wp.exe) takes care of all of these. Worker Process runs the ASP.NET application in IIS. All the ASP.NET functionality inside IIS runs under the scope of worker process. Worker Process is responsible for handling all kinds of request, response, session data, cache data. Application Pool is the container of worker process. Application pool is used to separate sets of IIS worker processes and enables a better security, reliability, and availability for any web application.
apppools
Now, by default, each and every Application pool contains a single worker process. Application which contains the multiple worker process is called “Web Garden”. Below is the typical diagram for a web garden application.
WebGarden Basic
In the above diagram, you can see one of the applications containing the multiple worker processes, which is now a web garden.
So, a Web application hosted on multiple servers and access based on the load on servers is called Web Farms and when a single application pool contains multiple Worker processes, it is called a web garden.


Advantages of Web Farm and Web Garden

Now, let’s have a look into the advantages of both the Web Farms and Web Gardens.

Advantages of Web Farm

  • It provides high availability. If any of the servers in the farm goes down, Load balancer can redirect the requests to other servers.
  • Provides high performance response for client requests.
  • Provides better scalability of the web application and reduces the failure of the application.
  • Session and other resources can be stored in a centralized location to access by all the servers.

Advantages of Web Garden

  • Provides better application availability by sharing requests between multiple worker process.
  • Web garden uses processor affinity where application can be swapped out based on preference and tag setting.
  • Less consumption of physical space for web garden configuration.



Difference between Array and ArrayList

Arrays

Arrays are strongly typed collection of same datatype and these arrays are fixed length that cannot be changed during runtime. Generally in arrays we will store values with index basis that will start with zero. If we want to access values from arrays we need to pass index values.

Declaration of Arrays

Generally we will declare arrays with fixed length and store values like as shown below


string[] arr=new string[2];
arr[0] = "welcome";
arr[1] = "Aspdotnet-suresh";
In above code I declared array size 2 that means we can store only 2 string values in array.

Arraylists

Array lists are not strongly type collection. It will store values of different datatypes or same datatype. Array list size will increase or decrease dynamically it can take any size of values from any data type. These Array lists will be accessible with “System.Collections” namespace

Declaration of Arraylist

To know how to declare and store values in array lists check below code


ArrayList strarr = new ArrayList();
strarr.Add("welcome"); // Add string values
strarr.Add(10);   // Add integer values
strarr.Add(10.05); // Add float values
If you observe above code I haven’t mentioned any size in array list we can add all the required data there is no size limit and we will use add method to bind values to array list

Difference between Array and ArrayList

Arrays
ArrayLists
These are strong type collection and allow to store fixed length
Array Lists are not strong type collection and size will increase or decrease dynamically

In arrays we can store only one datatype either int, string, char etc…

In arraylist we can store all the datatype values
Arrays belong to System.Array namespace
Arraylist belongs to System.Collection namespaces