August 2, 2009
July 27, 2009
.Net Coding Standards
.Net Coding Standards
Written by – Vinay Hatwal
28-Jul-2009
Code, anybody can write. By having only few months of programming study or experience, anybody can write a “working application”, but writing a good code is like a passion. By writing a working code you can develop an application but as soon as it will become larger, even you will not be able to understand it. Even when u will want to add some new functionality or you will want to modify your application, you will face a lot of problems.
So do not just write Working Applications, always write Good Code for your application so that u can make it programmer friendly.
Writing a good code should be included in your good habits, in your hobbies, so that your application should be highly manageable. For this purpose you have to follow some standards regarding writing code for you application not only in .Net but also in other programming languages.
After a lot of study and a lot of analysis on the Coding Standards, I am summarizing these coding standards in my article.
1) Naming Conventions
| Object | Notation | Good | Bad |
| Class,
Structure, Method, Property Enumeration, Namespaces, Delegates
|
Pascal Casing | EmployeeMaster,
StudentMaster |
employeeMaster, EMPLOYEEMASTER,
employee_master |
| Interface | Pascal Casing but start with I | IUnknown | iUnknown ,
iunknown, IUNKNOWN |
| Variables
Objects Method Parameters |
Camel Casing | userName
userId userAge |
Userid
User_Id USERID UserId |
| Class level variables | Camel Casing starting with a underscore | _userName
_userId |
Userid
User_Id USERID UserId userId |
| Constants | All Caps with underscore | CONS_SUPERUSER | Cons_superuser
consSuperuser |
2) Variable Naming Conventions
- Do not use Hungarian Notation with the variable names because they will become more complex to understand with it. Like –
Dim m_strRefUserName as String
It shows module level string variable with reference for holding Username. Now think lot of variable declaration in your project. Don’t you think these will create a lot of confusion?
- Do not use underscore (_) with local variables.
- Do not use single character variable name like I, j, k. Instead use meaning full variable names like Index, Counter.
- Do not use abbreviation with the variable names. Like instead of writing
Dim add as string
Use
Dim address as string
- Never use reserved keywords for variable names.
3) Good Programming Practice
- Do not hardcode numbers. Instead use XML Serialization Classes to provide the common setting for your Software. So that you would be able to change these values without making changes in the code.
- Never hardcode the Strings, Images and Icons. Always use resource file.
- Always use is as prefixing Boolean return type methods –
Private Function IsListEmpty() as Boolean
End Sub
- Use String.Empty() instead of using “” for the empty string.
- Try to use less class level variables. Instead use local variable. Because you can’t be sure which method is responsible for changing its value.
- Do not use String for Discrete Values. Instead use Enums.
-
- Never hardcode a path or drive name in code. Get the application path programmatically and use relative path.
- Error messages should help the user to solve the problem. Never give error messages like “Error in Application”, “There is an error” etc. Instead give specific messages like “Failed to update database. Please make sure the login id and password are correct.”
- Do not have more than one class in a single file.
- Use the AssemblyInfo file to fill information like version number, description, company name, copyright notice etc.
- Logically organize all your files within appropriate folders. Use 2 level folder hierarchies. You can have up to 10 folders in the root folder and each folder can have up to 5 sub folders. If you have too many folders than cannot be accommodated with the above mentioned 2 level hierarchy, you may need re factoring into multiple assemblies
- If you are opening database connections, sockets, file stream etc, always close them in the finally block. This will ensure that even if an exception occurs after opening the connection, it will be safely closed in the finally block
- Always create the Log for your application. So that you can easily investigate where is the problem in your application. Even u can log for many of the information like
- Error Messages
- Incomming Data
- Outgoing Data
- Warning Messages
- Results
- Normal Messages
- DateTime
- Etc
- Always mark your name, date of creation, and main use at the top of the module. And make a revision history with the same information whenever the changes are required.
- Always write default values of the Setting with the constants.
- Do not code like a structure programming. Always use OOPs with .net.
4) Architecture
- Always use multi layer (N-Tier) architecture.
- Never access database from the UI pages. Always have a data layer class which performs all the database related tasks. This will help you support or migrate to another database back end easily.
- Separate your application into multiple assemblies. Group all independent utility classes into a separate class library. All your database related files can be in another class library.
5) Comments
- Do not write comments for every line of code and every variable declared.
- Write comments wherever required. But good readable code will require very less comments. If all variables and method names are meaningful, that would make the code very readable and will not need many comments
- Always write XML Comments to describe the functionality of a class and Methods. They will help you and others to understand the functionality of the Method at the time you r using them.
Resources
July 3, 2009
June 16, 2009
Inheritance
Inheritance
Written by – Vinay Hatwal
Dt. 16-Jun-2009
Inheritance is the OOPs concept in which new classes form from the existing classes i.e. using the class functionality in the new classes. Inheritance was first introduced in 1967 for Simula, a language which was used for simulation so the name is Simula.
Inheritance is intended to help reuse existing code with little or no modification. Inheritance is also sometimes called generalization, because the is-a relationships represent a hierarchy between classes of objects.
For Example, A “vehicle” is the generalization of “Car”, “Scooter”, “Bus” etc and the “Car”, “Scooter”, ”Bus” are the specialization of the “Vehicle”. Because the “Car” is a Vehicle so “Car” naturally inherits properties common to the entire vehicle like Color, No of Wheels, and EnginPower etc.
Following example show the inheritance in action. Shape is the Base Class and Square , Rectangle amd Circle are the classes derived from Shape Class and inherits all the functionality of the Shape class the shows the specialisation of the Shape Class.

Inheritance
Inheritance in Action
—————————————————————
VB.NET
—————————————————————
Public Class BaseClass
End Class
Public Class DerivedClass
Inherits BaseClass
End Class
—————————————————————
—————————————————————
C#.NET
—————————————————————
public class BaseClass
{
}
public class DerivedClass : BaseClass
{
}
—————————————————————
Above DerivedClass Will contain all the inheritable funtionality of the BaseClass. Inheritane can be used in
VB.NET – Inherits
C#.NET – :
Access Specifires
| Functionality | VB.NET | C#.NET |
| Gives variable public access which means that there is no restriction on their accessibility | Public | public |
| Gives variable private access which means that they are accessible only within their declaration content | Private | private |
| Protected access gives a variable accessibility within their own class or a class derived from that class | Protected | protected |
| Gives variable friend access which means that they are accessible within the program that contains their declaration | Friend | internal |
| Gives a variable both protected and friend access | Protected Friend | protected internal |
| Makes a variable static which means that the variable will hold the value even the procedure in which they are declared ends | Static | static |
| Declares a variable that can be shared across many instances and which is not associated with a specific instance of a class or structure | Shared | static |
| Makes a variable only to be read and cannot be written | ReadOnly | - |
Keywords used in Inheritance in VB.NET/C#
1) MustInherit, MustOverride /abstract
2) Overridable/virtual
3) Overrides/override
4) NonInheritable/sealed
5) Shadows/New
Concepts Regarding Interitance
1) Abstraction
Abstraction is “the process of identifying common patterns that have systematic variations; an abstraction represents the common pattern and provides a means for specifying which variation to use” (Richard Gabriel).
In Abstraction we will look only on the keywords
a) MustInherit, MustOverride /abstract
Abstract Classes or MustInherit class can not me instantiated. The can only be inherited in the derived class.
For Example –
—————————————————————
VB.NET
—————————————————————
Public MustInherit Class Base
Public Sub NormalMethod()
End Sub
Public MustOverride Sub MustOverridableMethod()
End Class
Public Class Derived
Inherits Base
Public Overrides Sub MustOverridableMethod()
End Sub
End Class
—————————————————————
—————————————————————
C#.NET
—————————————————————
public abstract class Base
{
public void NormalMethod()
{
}
public abstract void MustOverridableMethod();
}
public class Derived : Base
{
public override void MustOverridableMethod()
{
throw new NotImplementedException();
}
}
—————————————————————
In the above example if you are declaring the method as MustOverride/ abstract then u have to give definition of that method in the derived class. But if you are defining the method in the MustInherit/Abstract class then you may or may not define this method in the derived class.
b) Overridable/virtual and Overrides/override
Overridable/virtual is used to polimorphically declare the base class method. A non overridable/not virtual method can not me polymorfically declared in the base class because it will hide the base class method in the derived class (Refer to Shadowing).
When we declare a Overridable/virtual method, it must contain a method body. Other wise the compiler will generate an error. Remember that, since Overridable/virtual methods are used for achieving polymorphism and since polymorphism works only with objects, it not possible to declare a static method as virtual in C#. Similarly the private methods are also not possible to declare virtual, since they can’t override inside a derived class.
For Example –
—————————————————————
VB.NET
—————————————————————
Public Class PolyBase
Public Overridable Function GetName() As String
Return “Base Polymorphic Class”
End Function
End Class
Public Class PolyDerived
Inherits PolyBase
Public Overrides Function GetName() As String
Return “Derived Polymorphic Class”
End Function
End Class
—————————————————————
—————————————————————
C#.NET
—————————————————————
public class PolyBase
{
public virtual string GetName()
{
return “Base Polymorphic Class”;
}
}
public class PolyDerived : PolyBase
{
public override string GetName()
{
return “Derived Polymorphic Class”;
}
}
—————————————————————
2) Sealed Classes –
Sealed Class can be instanciated but can not be inherited in another class .In VB.Net NotInheritable keyword is used to declare a class Seald and In C#.Net it is declared by sealed.
—————————————————————
VB.NET
—————————————————————
Public NotInheritable Class NotInheritableClass
Public Function Fun1() As String
Return “My class can not be inherited”
End Function
End Class
—————————————————————
—————————————————————
C#.NET
—————————————————————
sealed class NonInheritableClass
{
public string Fun1()
{
return “this class can not be inherited”;
}
}
—————————————————————
3) Shadowing
In .Net it is possible to declare the member of the base class with the same name in the derived class. In this class we are actully hiding the base class member in the derived class , if u do so then .Net compiler will show a warning.
Consider the following example-
—————————————————————
VB.NET
—————————————————————

—————————————————————
—————————————————————
C#.NET
—————————————————————

—————————————————————
See the compiler warning closely.
In VB.Net it is clearly advising to use the Shadows with the new Fun1() to hide the base class functionality. Here the correct code is -
—————————————————————
VB.NET
—————————————————————
Public Class Base
Private x As Integer
Private y As Integer
Public Function Fun1() As Integer
Return x + y
End Function
End Class
Public Class Derived
Inherits Base
Public Shadows Function Fun1() As Integer
Return 10
End Function
End Class
—————————————————————
Shadows keyword hides the base class functionality and warning too.
And in the C# it is advising to use the new keyword to hide the base class method. Here the correct code is-
—————————————————————
C#.NET
—————————————————————
class Base
{
private int x = 10;
private int y = 20;
public int Fun1()
{
return x + y;
}
}
class Derived : Base
{
public new int Fun1()
{
return 10;
}
}
—————————————————————
__________________________________________________________________________
April 17, 2009
New Features in Microsoft VS 2010
New Features in Microsoft VS 2010
Cloud Development
With Windows Azure Tools for Microsoft Visual Studio, developers can build, debug and deploy services and applications for Azure, the new cloud environment Microsoft announced in October 2008.
Web Development
In Visual Studio 2010, Microsoft is continuing their investment in great web development tools. Visual Studio 2010 enhancements for web developers include:
· A high-performance and standards-compliant JavaScript, IntelliSense® engine
· ‘One Click Deployment’ for quickly and easily publishing a website’s files and configuration settings from the development machines to the final deployed site
· Full support for Silverlight for developers wishing to build cutting-edge, rich internet applications.
Democratising Application Lifecycle Management
Microsoft Visual Studio Team System 2010 will deliver new capabilities that embrace the needs of the users in the lifecycle – from architects to developers, from project managers to testers. Among the great new functionality in Visual Studio Team System 2010:
· Discover and identify existing code assets and architecture with the new Architecture Explorer
· Design and share multiple diagram types, including use case, activity and sequence diagrams
· Improve testing efforts with tooling for better documentation of test scenarios and more thorough collection of test data
· Easily identify and run only the tests affected by a code change with the new Test Impact View
· Enhanced version control capabilities including gated check-in, branch visualisation and build workflow.
Inspiring Developer Delight
Since the first release of Visual Studio, Microsoft has made application development more productive, efficient, flexible and profitable to the developers and companies that use it. Visual Studio 2010 continues to deliver on the core developer experience by significantly improving the day-to-day process for development teams:
· Understand existing (and write new) code
· Intuitive web development from the back-end to the end result
· Wrangle disparate C++ code into one arena
· Build new Windows 7 applications or upgrade existing applications
· Enable Office tools to make your solutions more flexible and productive for specific needs.
Resource –
.Net Framework 4.0
.Net Framework 4.0
Every year the industry develops new technology and new trends. Now Microsoft is again come to provide next version of .net framework i.e. .Net Framework 4.0. As a result MS Visual Studio 2010 is just around the corner with the new innovation in application architecture, development, and deployment. So in this article I am describing some new features coming in the .Net Framework 4.0. Before describing new features of .Net Framework 4.0, I am giving a summary of some of the main functionality in each .net version.
|
.NET Framework 4.0 (The Future Release) |
PLINQ |
TPL |
||||
|
.NET Framework 3.5 |
LINQ |
ADO.NET Entity Framework |
||||
|
.NET Framework 3.0 |
WPF |
WCF |
WF |
Card Space |
||
|
.NET Framework 2.0 |
WinForms |
ASP.NET |
ADO.NET |
|||
|
Base Class Library |
||||||
|
CLR |
||||||
So you have just seen the major change in each version on .Net Framework. Above figure defines the feature stack of the .Net Framework.
Following are new features provided by .NET Framework 4.0 –
- New Languages
.NET 4.0 will include IronPython, IronRuby, and F#, among others. The three named languages have been available in some form for a few years now, but it appears that with .NET 4.0 they become “official” in the same way as C#, Visual Basic .NET. Both IronPython and IronRuby leverage the Dynamic Language Runtime (DLR), a subsystem that supports dynamic languages on .NET. The DLR has been around for a couple of years now, but with .NET 4.0 becomes an integral part of the .NET runtime.
In order to support the new languages, and to ensure language interoperability, the CLR team did make some changes. Two additions are particularly interesting to me: BigInteger and Tuple. Because these features are in the base class libraries, all .NET languages can use them
- Threading improvements
Framework 4.0 includes the Task Parallel Library (TPL), a library of objects that make it easier to write code that takes advantage of multiple cores. Not only do TPL functions relieve you of the tedium involved with starting and managing threads, they also help you to structure your code to make the most of the computing resources available.
During development and use of the TPL, the CLR team found a number of areas in which the .NET thread pool (the subsystem that the TPL depends on) was less than optimum. They have since improved the thread pool, giving a performance boost not only TPL programs, but to all programs that make use of .NET threading services.
- Garbage Collector Improvements
All in all, the .NET garbage collector is considered a good thing. However, it does have some drawbacks. In particular, it can severely impact performance in some cases.
The server garbage collector in .NET 3.51 and earlier versions is optimized for higher throughput, but has to pause all threads when it does a full collection. The result is that processing comes to a halt whenever a full collection occurs. This can be very annoying.
The pauses still occur in .NET 4.0, but the system will notify your program before a full collection starts, and notify it again when the garbage collector has finished with collection. In a multi-server environment, you can use this feature to direct traffic away from your server while it’s in the middle of a full collection. That helps with server farms, but doesn’t help with memory-intensive applications that are running on a single machine.
The workstation garbage collector in 4.0 gets a new background collection feature, which results in fewer pauses and doesn’t require any changes to your code. Only very unusual circumstances will result in the long latency that you might have seen in versions 3.51 or earlier
- PLINQ
.Net Framework 3.5 introduced new concept i.e. LINQ(Language Integrated Queries). Microsoft original motivation behind LINQ was to address the impedance mismatch between programming languages and database
Microsoft LINQ defines a set of proprietary query operators that can be used to query, project and filter data in arrays, enumerable classes, XML (XLINQ), relational database, and third party data sources. While it allows any data source to be queried, it requires that the data be encapsulated as objects. So, if the data source does not natively store data as objects, the data must be mapped to the object domain. Queries written using the query operators are executed either by the LINQ query processing engine or, via an extension mechanism, handed over to LINQ providers which either implement a separate query processing engine or translate to a different format to be executed on a separate data store (such as on a database server as SQL queries (DLINQ)). The results of a query are returned as a collection of in-memory objects that can be enumerated using a standard iterator function such as C#’s foreach.
Like all constructs in LINQ, PLINQ is based on extension methods, in this case the AsParallel method. Once you’ve built the expression tree representing the query, the AsParallel operation is added at the very end, which tells the “LINQ engine” to figure out parallel jobs and do all of the magic required to make the app benefit from multi-threaded execution. A conceptual example is shown below:
var result = (from p in db.Products join pd in xml.ProductDescriptions on p.ID equals pd.ID where p.Price > 100 select new { p.Name, p.Price, pd.Description }).AsParallel();
April 10, 2009
Windows Services
Windows Services
By: Vinay Hatwal
Dated: Apr 10, 2009
Level: Beginner
The idea of using Windows services came into my mind when I was working on Finger Print Attendance System for Bajaj Capital Ltd. This system was going to be used by all the branches of the company. So I wanted to synchronize the attendance of the employees of each branch with our company’s ERP system. So that, I decided to develop windows services for the same purpose. There was one issue in real time synchronization of attendance with the Head Office. The issue was slow internet connection and no internet connectivity available all the time. So the solution was to send the attendance when internet is connected not on the time of attendance punching. So the solution was WINDOWS SERVICES.
In this article I will explain how to make Windows Services by using c#.net.
Windows services are long running executable file developed for running in background as long a windows is running. These executables run in the background and there is no any requirement for the user interaction. They run in the background so that there is no need to take graphical interface in the Windows Services. You can think about UNIX Daemon if u r familiar with the UNIX environment. On the Windows the same concept is Windows Services. Windows Services can be configured to run automatically when Windows is booted. They can also be configured to run on Local machine, single user account, and also on Network.
You can find windows services in your local machine on
Start-> Control Panel -> Administrative Tools -> Services
These services looks like this—

Windows Service Browser
By using windows service you can use databases, text files, and all shareable resources with it etc.
To create Windows Services in .net (I am creating in .net 2.0)
Creating Windows Services
<!–[if !supportLists]–>1) <!–[endif]–>To create windows services, go to File menu and then select New Project, then select Windows Service. You will see the dialog box shown below. Name the project – MyWindowService.

2) After clicking on OK you will see the following. Change the name of the service from Service1.cs to MyService.cs.

3) Now go to in on the properties on the MyService and change the property Service Name to MyService.
4) Do right click on the MyService design view and select View Code option from the context menu. You can see two overrided methods in the window OnStart() and OnStop().
These are the members of the ServiceBase class and inheritted by the MyService Class. There are some more members also present in the ServiceBase class like OnContinue(), OnPause() etc. but I am just describing about these two only.
The idea of using windows service is only behind these to methods. Any work u want to perform on the sharable resources, you can write code for that in the OnStart() method. I have just put Beep () here. It will give the beep sound on starting the Window Service. And just 2 beep on Stoping it. You can see in the coding below.

<!–[if !supportLists]–>5) <!–[endif]–>to install this Windows Service on the local system you need to add installers in your Service. Just right click on the Service Design window and then select Add Installer.
<!–[if !supportLists]–>6) <!–[endif]–>Project Installer will automatically be added in your solution, name ProjectInstaller.sc. and you can also find two component in it
<!–[if !supportLists]–>a. <!–[endif]–>serviceProcessInstaller1
<!–[if !supportLists]–>b. <!–[endif]–>serviceInstaller1
<!–[if !supportLists]–>7) <!–[endif]–>You can now decide how your Windows Process will be display, you can set the account for your service on which it will be running, and you can give the Display Service Name, Description and the start type of the service like Automat, Manual, or Disabled. For doing all these you can follow these steps
<!–[if !supportLists]–>a. <!–[endif]–>Go to on the properties of serviceProcessInstaller1, and set Account property to Local System, so that it would be sharable to all users.
<!–[if !supportLists]–>b. <!–[endif]–>Now go to on the properties of serviceInstaller1, and ser Description as u like and set Display Name as u want to display in the Services Console, and now set StartType to Automatic so that the service can be run on the starting of the Windows operation system.
<!–[if !supportLists]–>
<!–[endif]–>After doing all the configuration just press F6 for building the solution. Now Your Window Service is ready to use.
<!–[if !supportLists]–>9) <!–[endif]–>Now for using it u have to install this service on your local machine. You can do this by using the instalUtill.exe utility provided by .net framework to install this service on your machine.
Now take the executable of this service and jus copy it into your system32 directory.
Go to your application path where your project is running, and go to the bin\debug directory then copy MyWindowServices.exe and paste it into syetem32.
Now go to on the Visual Studio 2005 Command Prompt and type the following for installing the newly developed Window Service–
C:\> installutil c:\windows\system32\ MyWindowServices.exe

To uninstall use –
C:\> installutil /u c:\windows\system32\ MyWindowServices.exe
You can see your service in the service console like

Now just do right click on it and the start. You will listen one beep on starting and two beep on stopping the Windows Service.
So friends. Enjoy the Window Services, hope your will learn by this article. Hope you will be enjoying after creation the windows service.
I am always waiting for your comments and suggestion so that I can improve my articles.
Again Coming Soon…………………….
Vinay Hatwal
October 26, 2008
NEW Features in Internet Explorer 8 beta
Ø New to Beta 2! InPrivate
Ø New to Beta 2!Delete Browsing History
Ø Search
Ø New to Beta 2!Search Suggestions
Ø New to Beta 2! UserPreference Protection
Ø New to Beta 2! CaretBrowsing
Ø Accelerators(previously known as Activities)
Ø Web Slices
Ø New to Beta 2!Suggested Sites
Ø Favorites Bar
Ø New to Beta 2! TabGrouping
Ø Automatic CrashRecovery
Ø SmartScreen Filter (previouslyknown as the Phishing Filter)
New to Beta 2! InPrivate
When using the Internet for such activities as checking e-mail on afriend’s computer or shopping for a gift on a family PC, some users prefer notto leave any traces of their session. The InPrivateBrowsing feature of Internet Explorer 8 prevents the browser from savingsession history, temporary Internet files, form data, cookies, and usernamesand passwords.
ctivate InPrivateBrowsing by selecting Start InPrivate Browsing either from a New Tab page or from the Safety menu—which is new in Internet Explorer 8. With the featureactivated, Internet Explorer 8 will launch a session that will retain noinformation and leave no trace of the user’s browsing activity. By default,activation of InPrivate Browsing also activates InPrivate Blocking (discussed in the next section). Simplyclosing the browser window will end the InPrivatesession.
DeleteBrowsing History
Introduced in Internet Explorer 7, the Delete BrowsingHistory feature enables a single-click deletion of the datasaved by Internet Explorer. Deleting records of web browsing activity has neverbeen easier!
Not all such records, however, need to be deleted. Forfrequently visited websites, the information stored in cookies is especiallyuseful. While many websites offer the so-called “Remember me” option,others (for example, financial websites) will store a cookie on every computerfrom which a user has accessed them; one use of this would be to eliminate therequirement for challenge questions (e.g. “What was your high schoolmascot?”)
Internet Explorer 8 addresses this issue by allowing users topreserve the cookies and temporary Internet files from the websites added tothe Favorites list
Thus, to stay registered with a specific website, a user wouldsimply add the website’s URL to Favorites, making sure that Preserve Favoriteswebsite data is selected; Internet Explorer will preserve all cookies and cachefiles for the website.
However, if a user wants to erase the browsing history completely,the Delete Browsing History on Exit feature will do the job!
Search
The search functionality of Internet Explorer 8 builds upon thework we started in Internet Explorer 7, which saw the introduction of a searchbox that supports the addition of search providers through OpenSearchdescription files. We have enhanced the search box in Internet Explorer 8,adding features that will help users initiate a better search query and easilyswitch to a secondary search provider.
The main modification we have made in search is an improvedsearch box drop-down which will help users execute better queries. The InternetExplorer 8 search box drop-down includes AutoComplete, Search suggestions andresults from local history. AutoComplete results, which were available inInternet Explorer 7, show users queries that they had previously typed in thesearch box. Search Suggestions allow your currently selected search provider tosuggest different queries to you as you are typing in the search box. (Theseare discussed in detail in the section below.) Finally history results show theuser pages they had previously browsed to which are related to what they arecurrently typing in the search box.
SearchSuggestions
Search suggestionsallow a search provider to suggest different queries while a user is typingtext into the search box. Search suggestions, as they are implemented incurrent toolbars and competing browsers, consist mainly of text suggestions forrelated terms that users might want to find; in some cases, specific links arealso suggested.
CaretBrowsing
Caret Browsing is anew Accessibility feature that allows users to navigate a webpage using amoveable cursor on the screen and the keyboard. Users can select and copy textdown to a single character using only the keyboard. Other content types, liketable or images, can also be selected and copied.
Moving the cursorwithin the text of a webpage is similar to moving the cursor within the text ofa Word document. Holding the shift key down and pressing the arrow keys selectstext. Pressing F7 turns Caret Browsing on or off. It can be enabled on a pertab basis or for all tabs and windows.
Accelerators
Accelerators are acontextual feature used to quickly access a service from any webpage. It iscommon for users to copy and paste content from one webpage to another, andaccelerators simplify this process.
Accelerators allowusers to find information without leaving the current webpage. For example, todetermine the location of a specific restaurant, a user will select therestaurant’s address, generating an in-place view of the map. Clicking the viewwill open a full webpage that includes additional information from the mappingservice.
WebSlices
Web Slices is a new featurethat allows users to connect to a website by subscribing to content directlywithin a webpage on that website. Web Slices behave just like feeds, whereusers can subscribe to get updates and notifications of changes.
Internet Explorer 8users discover Web Slices within a webpage and add them to the Favorites bar: arow located below the Address bar and dedicated to easy access of links. Once auser has subscribed to a webpage, the browser will detect changes in the WebSlice and get notified about updates. Users can preview these updates directlyfrom the Favorites bar, and click through to the website to get moreinformation.
SuggestedSites
Suggested Sites is anew feature which helps you find new websites that are interesting and relevantto you. With your permission, Internet Explorer will suggest new websites basedon sites you have visited in the past. You can see these suggestions by openingthe Suggested Sites Web Slice…
or by visiting theSuggested Sites page from the Internet Explorer Favorites Center.
FavoritesBar
In Internet Explorer7, the Links bar provided users with one-click access to their favorite sites.This bar has undergone a complete renovation for Internet Explorer 8.Specifically, it has been renamed Favorites, and it will allow users to accessnot only their favorite web content, such as links, feeds and Web Slices, butalso the documents created in Microsoft Word, Excel, and PowerPoint.
By using the new Addto Favorites Bar command, which is conveniently located on the Favorites baritself, a user can easily add a link to the Favorites bar
TabGrouping
This new feature ofInternet Explorer 8 Beta 2 allows users to put related tabs—the tabs thatoriginate from the same webpage—into groups. Users can form tab groups in one ofseveral ways, such as by opening a link from within a webpage in another tab,or by right-clicking a specific tab and clicking New Tab. If, for example, auser chooses to queue up several different search results, the related tabswill not only open next to the original search result page (as opposed to theend of the tab band) but will also be put all in one group represented by asolid color. Different colors for different browsing tasks—for example, aresearch project, an online shopping spree, or a set of news articles openedfrom the same newspaper website—allow users to quickly identify the tabs.
AutomaticCrash Recovery
The Automatic CrashRecovery (ACR) feature of Internet Explorer 8 helps to prevent the loss of workin the unlikely event of browser failure or nonresponse.ACR takes advantage of the Loosely Coupled feature of Internet Explorer toprovide new crash recovery capabilities, including tab recovery,that will minimize interruptions to a browsing session.
SmartScreen Filter
A phishingsite imitates a legitimate site to steal the user’s personal or financialinformation. In Internet Explorer 7, we introduced the PhishingFilter: a feature that warns users that they are about to visit a phishing site. For Internet Explorer 8, we have built uponthe success of the Phishing Filter—which blocks overa million phishing attacks weekly—to develop the SmartScreen Filter. The latter offers the followingenhancements:
· Improved userinterface
· Faster performance
· New heuristics andenhanced telemetry
· Anti-malware support for blocking unsafe downloads
· Improved group policysupport
References
August 25, 2008
PL/SQL Pragma
PL/SQL Pragma
Pragma –
Pragma is nothing but the compiler directive which simply conveys the information to the compiler. Because the Pragma is the complier directive so the processed at compile time not run time.
AUTONOMOUS_TRANSACTION Pragma
AUTONOMOUS_TRANSACTION Pragma instructs to the compiler to mark a transaction autonomous, or you can independent. An Autonomous transaction is the independent transactions which runs by the another transaction or main transaction. An autonomous transaction suspends the main transaction in which they are calling, do the SQL statements, commit or rollback then according to the user’s need then after completing resume the main transaction.
Commit or Rollback only works for the statements which are inside the calling transaction so that they are independent to the main transaction. It does not share any lock, resources and any commit or rollback dependence with the main transaction.
If you are using it with the triggers then unlike normal triggers these autonomous triggers can perform the DDL operation by using the native dynamic SQL. If you set the isolation level of the main transaction to SERIALIZABLE, as follows, changes made by its autonomous transactions are not visible to the main transaction hen it resumes:
See, if the main transaction perform the rollback at any save point after the autonomous block then it will not effect the changes made by the autonomous transaction because the autonomous transaction is fully independent from it’s main transaction.
Limitations –
You can not use the Pragma in the Subprogram that resides in the package. You can only user Pragma in the individual subprogram. You can use Pragma anywhere in the declarative part of the PL/SQL Block but always use it on the top position in the declarative part for readability.
Consider the following block of code –
– Main Procedure (Caller Procedure)
create or replace procedure MainProc as
begin
update myemployeemaster set employeename=‘vinny’ where employeename=‘Ashish’;
SimpleProc; – Calling an ordinary procedure
rollback;
exception
when others then null;
end;
– Procedure without Autonomous Transaction Block (Calee Procedure)
create or replace procedure SimpleProc as
begin
update myemployeemaster set employeename=‘Vikram’ where employeename=‘Pawan Kumar’;
commit;
exception
when others then null;
end;
Explanation-
In the above example the MainProc updates the MyEmployeeMaster table and update the name Ashish to Vinny. But After a SimpleProc call the procedure want to rollback his transaction. But when the SimpleProc procedure called the control of MaiProc goes into the SiimpleProc. In the SimpleProc MyEmployeeMaster is again updating the name Pawan Kumar with the name Vikram and then it commit its transactions. After the completing of SimpleProc the control again goes to the MainProc Procedure and then want to rollback all the changes done by it. But See, The SimpleProc Transaction has already committed the whole transactions. See the effect in the table MyEmployeeMaster, You will see that all the transactions are committed even of the MainProc Procedure.
It happened because the in the both procedure only single transaction is working, both are the part of a single transaction. So If you want to work on different Procedure for different transactions then you can use the Autonomous_Transaction Pragma. This Pragma will direct to the compiler for doing the different Transaction for the block where it defined.
Now the following Block of code is modified by using Autonomous_Transaction Pragma –
– Main Procedure (Caller Procedure)
create or replace procedure MainProc as
begin
update myemployeemaster set employeename=‘Vinay’ where employeename=‘Vikram’;
AutoProc; – Calling an ordinary procedure
rollback;
exception
when others then null;
end;
– Procedure without Autonomous Transaction Block (Calee Procedure)
create or replace procedure AutoProc as
pragma autonomous_transaction;
begin
update myemployeemaster set employeename=‘Pawan Kumar’ where employeename=‘vinny’;
commit;
exception
when others then null;
end;
Explanation-
Now consider the about block of code. In this code AutoProc Procedure difines the Pragma Autonomous_Transaction. So that it has a different transaction for this procedure . When a Commit operation is performed then it will only commit those transactions which are rekated to this procedure. And when the control goes back to the MainProc then it will rollback the transactions of the MainProc Procedure. So As a result name vinny in the MyEmployeeMaster is changed with the name Pawan Kumar. But Vikram has not changed with the Vinay.
August 19, 2008
Oracle Cursors
ORACLE CURSORS
Cursors are the work place user by the Oracle engine for its internal processing to save the data returned by the SQL statements. The type of a cursor depends upon the nature of its working. For Example if Oracle Engine open a cursor for its internal processing then it is known as Implicit Cursor and is a cursor defined by the user as a user defined cursor then it is called as Explicit Cursor.
Implicit Cursors
Implicit Cursors are automatically used by the Oracle Engine to store some information regarding the internal processing of the server. Implicit Cursors are automatically created, fetches records and closed by the oracle database server.
Basically Internal Cursors are used to table the information about last insert, update, delete or single row select statement.
Implicit Cursor Attributes
1) SQL%ISOPEN – If the cursor is open then this attribute returns TRUE otherwise returns FALSE. In the case of implicit cursors this attribute always return FALSE because Implicit Cursors are automatically open and the closed by the Oracle Engine.
2) SQL%FOUND – If cursor affects one or more then one row by the SQL statement then this attribute will return TRUE otherwise it will return FALSE.
3) SQL%NOTFOUND – This is opposite to the SQL%FOUND attribute. If the statement will not return any of the value then this attribute will be TRUE otherwise it will by FALSE.
4) SQL%ROWCOUNT – You can count number of affected rows by the last SQL statement by using this attribute.
Consider the following block of code-
Take the table used in the tutorial Native Dynamic SQL (MyEmployeeMaster).
CREATE OR REPLACE PROCEDURE demo_imp IS
row_deleted VARCHAR2(30);
BEGIN
update MYEMPLOYEEMASTER set EMPLOYEENAME=‘Ashish’ where upper(EMPLOYEENAME) like ‘%V%’;
IF SQL%ISOPEN THEN
dbms_output.put_line(‘SQL%FOUND – True’);
else
dbms_output.put_line(‘SQL%FOUND – False’);
END IF;
IF SQL%FOUND THEN
dbms_output.put_line(‘SQL%FOUND – True’);
else
dbms_output.put_line(‘SQL%FOUND – False’);
END IF;
IF SQL%NOTFOUND THEN
dbms_output.put_line(‘SQL%NOTFOUND – True’);
else
dbms_output.put_line(‘SQL%NOTFOUND – False’);
END IF;
dbms_output.put_line(‘SQL%ROWCOUNT – ‘ || SQL%ROWCOUNT || ‘ NO OF ROWS AFFACTED’);
END demo_imp;
Resule of above procedure –
SQL> set serverout on;
SQL> exec demo_imp;
SQL%FOUND – False
SQL%FOUND – True
SQL%NOTFOUND – False
SQL%ROWCOUNT – 3 NO OF ROWS AFFACTED
Explicit Cursors –
Explicit Cursors are explicitly used by the user for the data processing. Explicit Cursors are not automatically opens and close by like an Implicit Cursor. It is declare, open and close by the user in the PL/SQL block. Following are the steps to take by the user for using the Explicit Cursors in their PL/SQL block.
1) Declare the cursor in the declaration section with CURSOR keyword.
2) Open the declared Cursor by using the OPEN keyword.
3) Fetch the Record from the opened cursor by the FETCH … INTO keywords.
4) Process the data in the cursor by using the loop by using the LOOP…. END LOOP block.
5) Fetch the next record and point out the pointer to the next record by using the FETCH…. INTO.
6)
Explicit Cursor Attributes-
1) SQL%ISOPEN – If the cursor is open then this attribute returns TRUE otherwise returns FALSE.
2) SQL%FOUND – If cursor affects one or more then one row by the SQL statement then this attribute will return TRUE otherwise it will return FALSE.
3) SQL%NOTFOUND – This is opposite to the SQL%FOUND attribute. If the statement will not return any of the value then this attribute will be TRUE otherwise it will by FALSE.
4) SQL%ROWCOUNT – You can count number of affected rows by the last SQL statement by using this attribute.
Consider the following block of code
CREATE OR REPLACE PROCEDURE demo_exp IS
cur sys_refcursor;
employeeidx number;
eployeenamex varchar2(20);
BEGIN
open cur for select employeeid, employeename from myemployeemaster;
fetch cur into employeeidx,eployeenamex ;
while cur%found
loop
dbms_output.put_line(‘employeeid: ‘ || employeeidx || ‘—-’ || ‘eployeename: ‘ || eployeenamex );
fetch cur into employeeidx,eployeenamex ;
commit;
end loop;
END demo_imp;
<p class=”MsoNormal” style=”text-align:justify;margin:0;”


