File 1


Friday, July 8, 2011

Abstraction

Abstraction is a process of identifying the relevant qualities and behvaiors an object should possess.

Lets take an example to understand abstraction. A Laptop consists of many things such as processor, motherboard, RAM, keyboard,
LCD screen, wireless antena, web camera, usb ports, battery, speakers etc. To use it, you don't need to know how internally LCD screens,
keyboard, web camera, battery, wireless antena, speakers works. You just need to know how to operate the laptop by switching it on.

complexity is managed by using abstraction

Encapsulation

Encapsulation is a method for protecting data from unwanted access or alteration by packaging it in an object
where it is only accessible through the object's interface. Encapsulation are often referred to as information hiding.

For example, the Laptop is an object that encapsulates many technologies/hardwares that might not be understood clearly by most people who use it.

Inheritance

inheritance is a way to form new classes (instances of which are called objects) using classes that have already been defined.

Inheritance should not be confused with (subtype) polymorphism, commonly called just polymorphism in object-oriented programming.

Inheritance is a relationship between implementations, whereas subtype polymorphism is relationship between types (interfaces in OOP)

Polymorphism

Polymorphism is briefly described as "one interface, many implementations

There are two types of polymorphism.
Compile time polymorphism - It is achieved by overloading functions and operators
Run time polymorphism - It is achieved by overriding virtual functions


--------------------------------------------------------------------------------------
ASP.NET 2 Special Folders

App_Data
App_Code
App_Browsers
App_GlobalResources(.resx)
App_LocalResources
App_Themes
Bin
App_WebReferences

--------------------------------------------------------------------------------------
Global.asax

Application_Start
Application_End
Application_Error
Session_Start
Session_End


--------------------------------------------------------------------------------------
Access Specifiers

In C# .net the access specifiers are:
1.private
2.Internal
3.protected
4.protected Internal
5.Public

1)Public: if we declare any member as public then it can be
accessed from anywhere.
ex: Class Myclass1
{
public int x;
public int y;
}
Class Myclass2
{
public static void main()
{
Myclass1 mc=new Myclass1();
//direct accessing public member
mc.x=10;
mc.y=15;
console.writeline(mc.x,mc.y);
}
}

2)Private: Private members are accessible only within the
body of the class or the struct in which they are declared.
ex:
class Employee
{
public string name = "Jeet";
double salary = 100.00; // private access by default
public double AccessSalary() {
return salary;
}
}

class MainClass
{
public static void Main()
{
Employee e = new Employee();

// Accessing the public field:
string n = e.name;

// Accessing the private field:
double s = e.AccessSalary();
}
}
double s = e.salary; //can not be accessed due to private
lavel....

3)Protected: A protected member is accessible from within
the class in which it is declared, and from within any class
derived from the class that declared this member.

ex:class A
{
protected int x = 123;
}

class B : A
{
void F()
{
A a = new A();
B b = new B();
a.x = 10; // Error
b.x = 10; // OK
}
}
//a.x =10 generates an error because A is not derived from B.

4)internal - the members can access from the same project,
but any class

5)protected internal --> dual scope( internal + protected ).



--------------------------------------------------------------------------------------
There are six type of join in SQL 2000

1) INNER JOIN
2) OUTER JOIN
3) CROSS JOIN
4) EQUI JOIN
5) NATURAL JOIN
6) SELF JOIN


1) INNER JOIN :- PRODUCESS THE RESULT SET OF MATCHING ROWS
ONLY FROM THE SPECIFIED TABLES.

EXAMPLE---

SELECT COLUMN_LIST FROM 1ST_TABLE_NAME JOIN 2ND_TABLE_NAME
ON
1ST_TABLE_NAME.MATCING_COLUMN=2ND_TABLE_NAME.MATCING_COLUMN

2) OUTER JOIN :- DISPLAY ALL THE ROWS FROM THE FIRST TABLE
AND MATCHING ROWS FROM THE SECOND TABLE.

EXAMPLE---

SELECT COLUMN_LIST FROM 1ST_TABLE_NAME OUTER JOIN
2ND_TABLE_NAME
ON
1ST_TABLE_NAME.MATCING_COLUMN=2ND_TABLE_NAME.MATCING_COLUMN

THERE ARE THREE TYPES OF OUTER JOIN:

A)LEFT OUTER JOIN.
B)RIGHT OUTER JOIN.
C)FULL OUTER JOIN

A)LFET OUTER JOIN :- DISPLAYS ALL THE ROWS FROM THE FIRST
TABLE AND MATCHING ROWS FROM THE
SECOND TABLE.

EXAMPLE---

SELECT COLUMN_LIST FROM 1ST_TABLE_NAME LEFT OUTER JOIN
2ND_TABLE_NAME ON
1ST_TABLE_NAME.MATCING_COLUMN=2ND_TABLE_NAME.MATCING_COLUMN

A)RIGHT OUTER JOIN :- DISPLAYS ALL THE ROWS FROM THE
SECOND TABLE AND MATCHING ROWS FROM
THE FIRST TABLE.

EXAMPLE---

SELECT COLUMN_LIST FROM 1ST_TABLE_NAME RIGHT OUTER JOIN
2ND_TABLE_NAME ON
1ST_TABLE_NAME.MATCING_COLUMN=2ND_TABLE_NAME.MATCING_COLUMN

A)FULL OUTER JOIN :- DISPLAYS ALL MATCHING AND NONMATCHING
ROWS OF BOTH THE TABLES.

EXAMPLE---

SELECT COLUMN_LIST FROM 1ST_TABLE_NAME FULL OUTER JOIN
2ND_TABLE_NAME ON
1ST_TABLE_NAME.MATCING_COLUMN=2ND_TABLE_NAME.MATCING_COLUMN

3)CROSS JOIN :- IN THIS TYPE OF JOIN, EACH ROWS FROM THE
JOIN WITH EACH ROWS FROM THE SECOND TABLE
WITHOUT ANY CONDTION.
ALSO CALLED AS CARTESIAN PRODUCT.

EXAMPLE---

SELECT COLUMN_LIST FROM 1ST_TABLE_NAME CROSS JOIN
2ND_TABLE_NAME


4) EQUI JOIN :- DISPLAYS ALL THE MATHCING ROWS FROM JOINED
TABLE. AND ALSO DISPLAYS REDUNDANT VALUES.
IN THIS WE USE * SIGN TO JOIN THE TABLE.

EXAMPLE---

SELECT * FROM 1ST_TABLE_NAME JOIN 2ND_TABLE_NAME
ON
1ST_TABLE_NAME.MATCING_COLUMN=2ND_TABLE_NAME.MATCING_COLUMN

5)NATURAL JOIN :- DISPLAYS ALL THE MATHCING ROWS FROM
JOINED TABLE.IT RESTRICT
REDUNDANT VALUES.

6)SELF JOIN :- IN THIS TABLE JOIN WITH ITSELF WITH
DIFFERENT ALIAS NAME.

ASSUME DEPARTMENT IS A TABLE:

SELECT A.DEP_NAME,B.MANAGER_ID(COLUMN LIST) FROM DEPARTMENT
A JOIN
DEPARTMENT B
ON A.MANAGER_ID=B.MANAGER_ID



--------------------------------------------------------------------------------------
Validation in DotNet
1.RequiredFieldValidator
2.RangeValidator
3.regularexpressionvalidator
4.comparevalidator
5.customvalidator
6.validationsummary

--------------------------------------------------------------------------------------
lifecycle of asp.net cycle page

Page_Init -- Page Initialization

LoadViewState -- View State Loading

LoadPostData -- Postback data processing

Page_Load -- Page Loading

RaisePostDataChangedEvent -- PostBack Change Notification

RaisePostBackEvent -- PostBack Event Handling

Page_PreRender -- Page Pre Rendering Phase

SaveViewState -- View State Saving

Page_Render -- Page Rendering

Page_UnLoad -- Page Unloading



--------------------------------------------------------------------------------------
new feature in 3.5

ASP.NET AJAX
In ASP.NET 2.0, ASP.NET AJAX was used as an extension to it. You had to download the extensions and install it. However in ASP.NET 3.5, ASP.NET AJAX is integrated into the .NET Framework, thereby making the process of building cool user interfaces easier and intuitive.

New Controls
ListView
DataPager

LINQ
LINQ defines operators that allow you to code your query in a consistent manner over databases, objects and XML

You can have multiple versions of ASP.NET on the same machine.

New Assemblies
System.Core.dll - Includes the implementation for LINQ to Objects
System.Data.Linq.dll - Includes the implementation for LINQ to SQL
System.Xml.Linq.dll - Includes the implementation for LINQ to XML
System.Data.DataSetExtensions.dll - Includes the implementation for LINQ to DataSet
System.Web.Extensions.dll:

--------------------------------------------------------------------------------------
What is hte difference between the Gridview,Datalist and Repeater
Features of a GridView
•Displays data as a table
•Control over
–Alternate item
–Header
–Footer
–Colors, font, borders, etc.
–Paging
•Updateable
•Item as row

Features of Repeater
•List format
•No default output
•More control
•More complexity
•Item as row
•Not updateable


Features of DataList
•Directional rendering
•Good for columns
•Item as cell
•Alternate item
•Updateable

There are Five Session State Modes :

InProc mode, which stores session state in memory on the Web server. This is the default.

StateServer mode, which stores session state in a separate process called the ASP.NET state service. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.

SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.

Custom mode, which enables you to specify a custom storage provider.

Off mode, which disables session state.


in asp.net following ways to maintain server site and
client site state.
client site:
1. View State
2. Query String
3. Hiddne Field
4. Cookies

Server Site is:
1. Session
2. Application



what is view state,session,cookies,caching, and diff between viewstate and session?

ViewState:

Viewstate is a hidden fields in an ASP.NET page, contains state of those controls on a page whose “EnableViewstate” property is “true”.

You can also explicitly add values in it, on an ASP.NET page like:Viewstate.Add( "Totfeatures", "50" );

Viewstate should be used when you want to save a value between different roundtrips of a single page as viewstate of a page is not accessible by another page.

Because Viewstate renders with the page, it consumes bandwith, so be careful to use it in applications to be run on low bandwith

Session :-

Session variables are usually the most commonly used.

When a user visits a site, it’s sessions starts and when the user become idle or leave the site, the session ends.
Session variables should be used to save and retrive user specefic information required on multiple pages.

Session variables consumes server memory, so if your may have a huge amount visiters, use session very carefully and instead of put large values in it try to put IDs and references

Cookies:-

Cookies are some values saved in browsers for a particular website o publicly accessible

The purpose of cookies is to help websites to identify visitors and retrieve their saved preferences
Cookies are also used to facilitate auto login by persisting user id in a cookie save in user’s browser
Because cookies have been saved at client side, they do not create performance issues but may create security issues as they can be hacked from browser.

Difference Between Viewstate & Session

Unlike Session state ViewState is a property of the web controls.

Both are used to persist certain data.

Values stored in the session are available across different pages in an application.

Where as the vdata contained in a control is persisted between page's post back by using that controls ViewState property.

View state cannot be used if the page donot post back to itself.

No comments :