Tuesday, August 5, 2008

Abstract Class vs. Interface

An abstract class may contain complete or incomplete methods. Interfaces can contain only the signature of a method but no body. Thus an abstract class can implement methods but an interface can not implement methods.

· An abstract class can contain fields, constructors, or destructors and implement properties. An interface can not contain fields, constructors, or destructors and it has only the property's signature but no implementation.

· An abstract class cannot support multiple inheritance, but an interface can support multiple inheritance. Thus a class may inherit several interfaces but only one abstract class.

· A class implementing an interface has to implement all the methods of the interface, but the same is not required in the case of an abstract Class.

· Various access modifiers such as abstract, protected, internal, public, virtual, etc. are useful in abstract Classes but not in interfaces.

· Abstract classes are faster than interfaces.


Recommendations for Abstract Classes vs. Interfaces


  • If you anticipate creating multiple versions of your component, create an abstract class. Abstract classes provide a simple and easy way to version your components. By updating the base class, all inheriting classes are automatically updated with the change. Interfaces, on the other hand, cannot be changed once created. If a new version of an interface is required, you must create a whole new interface.
  • If the functionality you are creating will be useful across a wide range of disparate objects, use an interface. Abstract classes should be used primarily for objects that are closely related, whereas interfaces are best suited for providing common functionality to unrelated classes.
  • If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class.
  • If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members







So Which One Should I Use?

Abstract classes can add more functionality without destroying the child classes that were using the old version. Abstract classes provide a simple and easy way to version our components. By updating the base class, all inheriting classes are automatically updated with the change. In an interface, creation of additional functions will have an effect on its child classes due to the necessary implementation of interface Methods in classes. Abstract classes should be used primarily for objects that are closely related, whereas interfaces are best suited for providing common functionality to unrelated classes. Say there are two classes, bird and airplane, and both of them have methods called fly. It would be ridiculous for an airplane to inherit from the bird class just because it has the fly() method. Rather, the fly() method should be defined as an interface and both bird and airplane should implement that interface. If we want to provide common, implemented functionality among all implementations of component, we should use an abstract class. Abstract classes allow us to partially implement classes, whereas interfaces contain no implementation for any members. So the selection of interface or abstract classes depends on the needs and design of our project. We can make an abstract class, interface, or combination of both depending on our needs.

The most likely situation in which we make a class or method sealed will be if the class or method is internal to the operation of the library, class, or other classes that we are writing. Because any attempt to override some of its functionality will cause problems. We can mark a class or method as sealed for commercial reasons, in order to prevent a third party from extending our classes. For example, in the .NET base class library string is a sealed class.

We should not use the sealed key word on a method unless that method is itself an override of another method in some base class. If we are defining a new method and we don’t want anyone else to override it, we should not declare it as virtual in the first place. If however, we have overridden a base class method, the sealed keyword provides a way of ensuring that the override supplied to a method is a “final” override that means no one else can override it again.

20 Tips to Improve ASP.net Application Performance

here are certain things you should take into account when you are developing your applications. Over the last 12 years or so of working with asp and asp.net, I have learned to avoid and do certain things that increase your application performance by a massive amount! Below are my top 20 tips to improving ASP.net application Performance.
  1. Disable Session State
    Disable Session State if you're not going to use it. By default it's on. You can actually turn this off for specific pages, instead of for every page:
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
    
    AutoEventWireup="false" Inherits="WebApplication1.WebForm1"
    EnableSessionState="false" %>

    You can also disable it across the application in the web.config by setting the mode value to Off.
  2. Output Buffering
    Take advantage of this great feature. Basically batch all of your work on the server, and then run a Response.Flush method to output the data. This avoids chatty back and forth with the server.
    <%response.buffer=true%> 
    Then use:
    <%response.flush=true%> 
  3. Avoid Server-Side Validation
    Try to avoid server-side validation, use client-side instead. Server-Side will just consume valuable resources on your servers, and cause more chat back and forth.
  4. Repeater Control Good, DataList, DataGrid, and DataView controls Bad
    Asp.net is a great platform, unfortunately a lot of the controls that were developed are heavy in html, and create not the greatest scaleable html from a performance standpoint. ASP.net repeater control is awesome! Use it! You might write more code, but you will thank me in the long run!
  5. Take advantage of HttpResponse.IsClientConnected before performing a large operation:
    if (Response.IsClientConnected)
    
    {
    // If still connected, redirect
    // to another page.
    Response.Redirect("Page2CS.aspx", false);
    }
    What is wrong with Response.Redirect? Read on...
  6. Use HTTPServerUtility.Transfer instead of Response.Redirect
    Redirect's are also very chatty. They should only be used when you are transferring people to another physical web server. For any transfers within your server, use .transfer! You will save a lot of needless HTTP requests.
  7. Always check Page.IsValid when using Validator Controls
    So you've dropped on some validator controls, and you think your good to go because ASP.net does everything for you! Right? Wrong! All that happens if bad data is received is the IsValid flag is set to false. So make sure you check Page.IsValid before processing your forms!
  8. Deploy with Release Build
    Make sure you use Release Build mode and not Debug Build when you deploy your site to production. If you think this doesn't matter, think again. By running in debug mode, you are creating PDB's and cranking up the timeout. Deploy Release mode and you will see the speed improvements.
  9. Turn off Tracing
    Tracing is awesome, however have you remembered to turn it off? If not, make sure you edit your web.config and turn it off! It will add a lot of overhead to your application that is not needed in a production environment.
    
    

    "false" pageOutput="false" />
    "false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/>
    "false" />


  10. Page.IsPostBack is your friend
    Make sure you don't execute code needlessly. I don't know how many web developers forget about checking IsPostBack! It seems like such a basic thing to me! Needless processing!
  11. Avoid Exceptions
    Avoid throwing exceptions, and handling useless exceptions. Exceptions are probably one of the heaviest resource hogs and causes of slowdowns you will ever see in web applications, as well as windows applications. Write your code so they don't happen! Don't code by exception!
  12. Caching is Possibly the number one tip!
    Use Quick Page Caching and the ASP.net Cache API! Lots to learn, its not as simple as you might think. There is a lot of strategy involved here. When do you cache? what do you cache?
  13. Create Per-Request Cache
    Use HTTPContect.Items to add single page load to create a per-request cache.
  14. StringBuilder
    StringBuilder.Append is faster than String + String. However in order to use StringBuilder, you must
    new StringBuilder()
    
    Therefore it is not something you want to use if you don't have large strings. If you are concatenating less than 3 times, then stick with String + String. You can also try String.Concat
  15. Turn Off ViewState
    If you are not using form postback, turn off viewsate, by default, controls will turn on viewsate and slow your site.
    public ShowOrdersTablePage()
    
    {
    this.Init += new EventHandler(Page_Init);
    }

    private void Page_Init(object sender, System.EventArgs e)
    {
    this.EnableViewState = false;
    }
  16. Use Paging
    Take advantage of paging's simplicity in .net. Only show small subsets of data at a time, allowing the page to load faster. Just be careful when you mix in caching. How many times do you hit the page 2, or page 3 button? Hardly ever right! So don't cache all the data in the grid! Think of it this way: How big would the first search result page be for "music" on Google if they cached all the pages from 1 to goggle ;)
  17. Use the AppOffline.htm when updating binaries
    I hate the generic asp.net error messages! If I never had to see them again I would be so happy. Make sure your users never see them! Use the AppOffline.htm file!
  18. Use ControlState and not ViewState for Controls
    If you followed the last tip, you are probably freaking out at the though of your controls not working. Simply use Control State. Microsoft has an excellent example of using ControlState here, as I will not be able to get into all the detail in this short article.
  19. Use the Finally Method
    If you have opened any connections to the database, or files, etc, make sure that you close them at the end! The Finally block is really the best place to do so, as it is the only block of code that will surely execute.
  20. Option Strict and Option Explicit
    This is an oldy, and not so much a strictly ASP.net tip, but a .net tip in general. Make sure you turn BOTH on. you should never trust .net or any compiler to perform conversions for you. That's just shady programming, and low quality code anyway. If you have never turned both on, go turn them on right now and try and compile. Fix all your errors.

There are hundreds more where these came from, however I really feel that these are the most critical of the speed improvements you can make in ASP.net that will have a dramatic impact on the user experience of your application. As always if you have any suggestions or tips to add, please let us know! We would love to hear them!

Have web development!

The Dwadasa Jyotirlinga Stotra

Saurashtre Somanaatham Cha

Sree Shaile Mallikarjunam
Ujjayinyaam
Mahaakaalam

Omkaare Mamaleswaram
Himalaye to
Kedaram

Daakinyaam Bhimashankaram
Vaaranaasyaam cha
Viswesam

Trayambakam Gowtameethate
Paralyaam
Vaidyanaatham cha

Naagesam Daarukaavane
Setubandhe
Ramesham

Grushnesam cha Shivaalaye

Different Forms of Durga

As the ten-armed Goddess, Goddess Durga presents a radiantly beautiful form that is bewitching to behold. That special form is somehow simultaneously wrathful and benign and transmits profound spiritual teachings in an exacting manner. The nine-day period from the new moon day to the ninth day of Ashvina is considered the most auspicious time of the Hindu Calendar and is hence the most celebrated time of the year as Durga Puja. The nine different forms of Devi are worshiped over the nine days. These are the most popular forms under which she is worshiped:

Durga Shailputri (Daughter of Mountain)
She is a daughter of Himalaya and first among nine Durgas. In previous birth she was the daughter of Daksha. Her name was Sati - Bhavani. i.e. the wife of Lord Shiva. Once Daksha had organized a big Yagna and did not invite Shiva. But Sati being obstinate, reached there. Thereupon Daksha insulted Shiva. Sati could not tolerate the insult of husband and burnt herself in the fire of Yagna. In other birth she became the daughter of Himalaya in the name of Parvati - Hemvati and got married with Shiva. As per Upnishad she had torn and the egotism of Indra, etc. Devtas. Being ashamed they bowed and prayed that, "In fact, thou are Shakti, we all - Brahma, Vishnu and Shiv are capable by getting Shakti from you."

Brahmacharini
The second Durga Shakti is Brahamcharini. Brahma that is who observes penance(tapa) and good conduct. Here "Brahma" means "Tapa". The idol of this Goddess is very gorgeous. There is rosary in her right hand and Kamandal in left hand. She is full with merriment. One story is famous about her. In previous birth she was Parvati Hemavati the daughter of Himvan. Once when she was busy in games with her friends. Naradaji came to her and predicted seeing her Palm-lines that, "You will get married with a naked-terrible 'Bhole baba' who was with you in the form of Sati, the daughter of Daksh in previous birth. But now you have to perform penance for him." There upon Parvati told her mother Menaka that she would marry none except Shambhu, otherwise she would remain unmarried. Saying this she went to observe penance. That is why her name is famous as tapacharini - Brahmacharini. From that time her name Uma became familiar.

Chandraghanta
The name of third Shakti is Chandraghanta. There is a half-circular moon in her forehead. She is charmful and bright. She is Golden color. She has three eyes and ten hands holding with ten types of swords - etc. weapons and arrows etc. She is seated on Lion and ready for going in war to fight. She is unprecedented image of bravery. The frightful sound of her bell terrifies all the villains, demons and danavas.

Kushmanda
Name of fourth Durga is Kushmanda. The Shakti creates egg, ie. Universe by mere laughing .She resides in solar systems. She shines brightly in all the ten directions like Sun. She has eight hands. Seven types of weapons are shining in her seven hands. Rosary is in her right hand. She seems brilliant riding on Lion. She likes the offerings of "Kumhde." Therefore her name "Kushmanda" has become famous.

Skanda Mata
Fifth name of Durga is "Skanda Mata". The daughter of Himalaya, after observing penance got married with Shiva. She had a son named "Skanda." Skanda is a leader of the army of Gods. Skanda Mata is a deity of fire. Skanda is seated in her lap. She has three eyes and four hands. She is white and seated on a lotus.

Katyayani
Sixth Durga is Katyayani. The son of "Kat" as "Katya". Rishi Katyayan born in this "Katya" lineage. Katyayan had observed penance with a desire to get paramba as his daughter. As a result she took birth as a daughter of Katyayan. Therefore her name is "Katyayani" . She has three eyes and eight hands. These are eight types of weapons missiles in her seven hands. Her vehicle is Lion.

Kalratri
Seventh Durga is Kalratri. She is black like night. Durga hairs are unlocked. She has put on necklaces shining like lightening. She has three eyes which are round like universe. Her eyes are bright. Thousands of flames of fire come out while respiring from nose. She rides on Shava (dead body). There is sharp sword in her right hand. Her lower hand is in blessing mood. The burning torch (mashal) is in her left hand and her lower left hand is in fearless style, by which she makes her devotees fearless. Being auspicious she is called "Shubhamkari."

Maha Gauri
The Eighth Durga is "Maha Gauri." She is as white as a conch, moon and Jasmine. She is of eight years old. Her clothes and ornaments are white and clean. She has three eyes. She rides on bull She has four hands. The above left hand is in "Fearless - Mudra" and lower left hand holds "Trishul." The above right hand has tambourine and lower right hand is in blessing style. She is calm and peaceful and exists in peaceful style. It is said that when the body of Gauri became dirty due to dust and earth while observing penance, Shiva makes it clean with the waters of Gangas. Then her body became bright like lightening. There fore, she is known as "Maha Gauri" .

Siddhidatri
Ninth Durga us Siddhidatri. There are eight Siddhis , they are- Anima, Mahima, Garima, Laghima, Prapti, Prakamya, Iishitva & Vashitva. Maha Shakti gives all these Siddhies. It is said in "Devipuran" that the Supreme God Shiv got all these Siddhies by worshipping Maha Shakti. With her gratitude the half body of Shiv has became of Goddess and there fore his name "Ardhanarishvar" has became famous. The Goddess drives on Lion. She has four hands and looks pleased. This form of Durga is worshiped by all Gods, Rishis-Munis, Siddhas, Yogis, Sadhakas and devotees for attaining the best religious asset.

The 16 Sacraments of Life

n the Vedic Tradition, there are sixteen religious ceremonies known as Sanskars or the Sacraments of Life. The Sanskars are performed for the physical, social, and spiritual development of the individual. These are:

1. Garbhadhana: Performed shortly after the conception of a child, to ensure a healthy beginning for the new life.

2. Punsavana: Performed during the second or third month of pregnancy, to ensure the healthy development of all the extremities and vital organs of the fetus.

3. Simantonnayana: Performed during the last phases of pregnancy, to ensure the correct functioning of all the sensory organs and to bring the development of the fetus to a successful close.

4. Jatakarma: Performed after the birth of the child, to welcome the newborn as a new member of society.

5. Namakarana: Performed on the 11th or 12th day after birth, to give the child the name he or she will forthwith be known by.

6. Niskramana: Performed when the child is 2 to 4 months old, to invoke God's protection and blessings as the child leaves the home for the first time.

7. Annaprasana: Performed when the child is 4 to 6 months old, to celebrate the child's first consumption of solid food.

8. Chudakarma: Performed when the child is 1 year old, to support the development of self-awareness and autonomy in the child.

9. Karnavedha: Performed when the child is 3 to 5 years old, to support the development of self-esteem and self-respect.

10. Upanayana: Performed when the child is 5 to 7 years old, to celebrate the entrance of the child into the institution of formal education and the investment with the sacred thread, signalling the beginning of Brahmacharya or Student Life. Also known as Yajnopaveet.

11. Vedarambha: Performed when the child is 5 to 7 years old, to solidify the commitment of the child to receiving a good education.

12. Samavartana: Performed upon the completion of studies, to welcome the young adult as a valued member of society, ready to embark on the next stage of life, known as Grihastha or Household Life.

13. Vivaha: The marriage ceremony (usually undertaken around 25 years of age), to celebrate the happy union of the individual with a spouse of their choice who is suited to their nature and ready to embark upon Household Life.

14. Vaanaprastha Ashram: Undertaken upon retiring from one's chosen profession (usually between 50 and 75 years of age), to celebrate the completion of the duties of Household Life and the entrance into the phase of reflection and meditation known as Vaanaprastha Ashram.

15. Sanyaasa Ashram: Undertaken either after the completion of Brahmacharya (Student Life) or Vaanaprastha (Retired Life), to celebrate the renunciation of all worldly desires and absolute dedication to the service of mankind through spreading Vedic Wisdom.

16. Antyesti: Performed upon the death of the individual, when the body is consumed by fire and it's constituent elements are returned to Nature. This is the last ceremony. Also known as Antyesti, Naramedha and Purusmedha.