Working With Class Library in Asp.net C# : Part 1

Here I will explain you how to use Class Library in ASP.NET.
 
Before creating a form let us start with some basic information about class library.
 
 
 
What is  Class Library ?
A class library is a pre-coded object-oriented programming (OOP) template collection. Both web and desktop applications use class libraries. Class libraries contain code for graphical user interface (GUI) elements such as buttons, icons, scroll bars and windows as well as other non-GUI components.
 
In one line:
A library of reusable classes for use with an object-oriented programming system.
So the whole point of creating a class library project is reusability. Now we want this reusability not only within a .NET application, not across .NET applications, but across different types of .NET applications. Class libraries enhance code reuse by providing implementations of repetitive jobs. Writing program applications from scratch can be an extremely detailed and expensive process. Class libraries include all essential classes in a previously written coded format, which not only simplifies programming but also increases code quality. Class template customization is implemented according to specific programming requirements.
 
Believe it, majority of the programmers write 'working code', but not ‘good code'. Writing 'good code' is an art and you must learn and practice it. Everyone may have different definitions for the term ‘good code’. In my definition, the following are the characteristics of good code.
  1. Reliable
  2. Maintainable
  3. Efficient
 So class library do it for you.
 
Advantage : 
 
If u deploy your dll in various servers (web farm), then performance will be automatically increased. If u deploy your BL dll into MTS Server, then object pooling, automatic transaction management will automatically happen. Apart from that, if u write your every layer as a component (dll), then it will very easy to maintain the whole project.
 
Disadvantage :
 
Disadvantage could be that, if you need to send the data across the layer, you need to rethink of this option as class library are used to code reuse or provide block for a particular code of block. 
 
Develop your own class libraries
 
In addition to the vast number of class libraries included with the .NET Framework, you can create your own. This allows you to create a collection of classes that you may use in multiple applications, and easily make them available to other developers. Additionally, it provides a central location for class maintenance. It reduces the need to include code in multiple projects with multiple maintenance access points. 
 
 
  
The following code listing shows the default class added to a C# class library project.
  1. using System;  
  2. namespace ClassLibrary {  
  3. public class Class1 {  
  4. public Class1() {  
  5. } } }   


Similar Articles