Tuesday, October 31, 2006

We're All Cracked Pots

A water bearer had two large pots, each hung on the ends of a pole which he carried across his neck. One of the pots had a crack in it, while the other pot was perfect and always delivered a full portion of water.

At the end of the long walk from the stream to the house, the cracked pot arrived only half full.

For a full two years this went on daily, with the bearer delivering only one and a half pots full of water to his house. Of course, the perfect pot was proud of its accomplishments, perfect for which it was made. But the poor cracked pot was ashamed of its own imperfection, and miserable that it was able to accomplish only half of what it had been made to do.

After 2 years of what it perceived to be a bitter failure, it spoke to the water bearer one day by the stream. I am ashamed of myself, and because this crack in my side causes water to leak out all the way back to your house.

The bearer said to the pot, Did you notice that there were flowers only on your side of the path, but not on the other pot's side that's because I have always known about your flaw, and I planted flower seeds on your side of the path, and every day while we walk back, you've watered them.

For two years I have been able to pick these beautiful flowers to decorate the table. Without you being just the way you are, there would not be this beauty to grace the house.

Each of us has our own unique flaws. We're all cracked pots. But it's the cracks and flaws we each have that make our lives together so very interesting and rewarding. Don't be afraid of your flaws. Acknowledge them, and you too can be the cause of beauty. Know that in our weakness we find our strength.

Source : Sent by a friend

Saturday, October 28, 2006

The Word Hindu and India

The word 'Hindu' is NOT a Sanskrit word. Numerous scholars say it is not found in any of the Vedic literature. So it is important to know how such a name can truly represent the Vedic culture. And without the Vedic literature, there is no basis for “Hinduism.” Similarly, the name ‘India’ did not come from any Indian language or culture. So let’s find out their origin.

Origin of the word Hindu

Most scholars feel that the word “Hindu” was developed by outsiders, invaders who could not pronounce the name of the Sindhu River properly. Sindhu was the original name for a great river in north-west India. When invaders from Persia came across this river, they pronounced it ‘Hindu’. Because in Persian, the ‘S’ is pronounced as ‘H’. Eventually from ‘Hindu’, the second ‘h’ disappeared. So from ‘Sindhu’ the word ‘Hindu’ evolved. It described a geographical area. Today the word ‘Hindu’ represents people who follow Sanatan Dharma (Eternal religion based on Vedic knowledge). However later, it became to represent the people of ‘Hindu’ – Sthan. ‘Sthan’ means land. From this evolved the word ‘Hindustan’. It is very important to mention that word Hindustan does not mean only the land of Hindus but all the people of India who live east of the Sindhu River, which is called Hindustan or Bharat.

Origin of the word India

Some sources report that it was Alexander the Great who first renamed the River Sindhu as the Indu, dropping the beginning “S”, thus making it easier for the Greeks to pronounce. This became known as the Indus. This was when Alexander invaded India around 325 B.C. His Macedonian forces thereafter called the land east of the Indus as India, a name more frequently used especially during the British regime.

Thereafter, even the Indians conformed to these standards as set by those in power and used the names Hindu, Hindustan and India. Otherwise, the word has no meaning except for those who place value on it or now use it out of convenience.

Some other names of India

Aryavrata - Land of Aryans
Ajnabh khand - Named on the king Aj - Grandfather of Lord Ram
Hindustan – As discussed above from the word Sindhu
Hind - Short form of Hindustan - First used by Netajee
Bharat – Named on the king Bharat – Official Hindi name
India – Name mostly used by British - Official English name

Friday, October 27, 2006

Types of Karma

The word Karma came from Sanskrit word “Kri”, it means “to do”. Karma means not only action, but also the result of an action. The consequence of an action is a part of the action, and cannot be divided from it. Karma is a neutral, self-perpetuating law of the inner cosmos.

Thus, Karma refers to
  •  Any act or deed
  •  The principle of cause and effect
  •  A consequence or "fruit of action” or "after effect" which sooner or later returns upon the doer. What we sow, we shall reap in this or future lives
According to Vedas - "Here they say that a person consists of desires. And as is his desire, so is his will. As is his will, so is his deed. Whatever deed he does, that he will reap."

The concept of Karma is central in Hinduism, Sikhism, Buddhism and Jainism. Breathing, thinking, talking, seeing, hearing, eating, etc., are Karmas. Thinking is mental Karma. Karma is the sum total of our acts both in the present life and in the preceding lives.
  
The innumerable Karmic Seeds we produce by our various actions - desire, aversion, love, hatred, happiness, etc. will undoubtedly produce, sooner or later, a positive or negative result according to the nature of the seed, if not in this life, then in some future one.

All living creatures are bound to perform some act or Karma. Even if someone decides not to do anything, in reality an act is being performed in form of doing nothing and hence its result will be accordingly.
   
Types of Karma?
 Karma can be divided in three parts:

1. Sanchita Karma (Acquired Karma): In Sanskrit it means – “The accumulated consequence of an individual’s actions in present and past lives.” This is the storage of all karma or sum of all karmas which can be referred as total cosmic debt, in which every moment either an individual is adding or reducing Karma.

 Following five aspects of our life are governed by Sanchita Karma :
1. Birth, place of birth and our parents
2. Education and line of education
3. Wealth and source of wealth
4. Longevity and illnesses
5. Death, place of death and mode of death

This karma also refers to the psychological, mental subconscious tendency which determines the propensities for psychological and physical illnesses, particular kinds of obstacles, and a natural habit or tendency to behave in particular way. For example, you have no control over your birth or death but it happens based on your Karma. As time passes Sanchita Karma takes the form of Prarabhada Karma and yields its results. It is very complex to predict that which Karma will yield exactly what result but as a general rule of thumb “As you sow so shall you reap.”

2. Prarabdha Karma (Present Karma) – In Sanskrit it means – “Action that has been unleashed or aroused.” It also refers to the action which manifests now. This is the portion of Sanchita Karma which was earned in the past and it is already in action now. This Karma you can not erase, you have to go through it, because it is already in process. You have no freedom to make any changes to it. This is already yielding the result and thus we have no control to make any changes.

3. Agami Karma (Approaching Karma): In Sanskrit it means –“Actions that has to come.” The Karma or the actions that are now going to be done which will give their results later in future. Some of Agami Karmas bear fruit in the current life; others are stored for future births in form of Sanchita Karma.
 
There is a freedom in choosing an action here but Agami Karma is influenced by our old tendencies and habits from Sanchita Karma and Prarabdha Karma. If an indivisual is fully aware of his actions he can choose the good Karma which will yield the good result in future.

Some of the following aspects of our life are governed by Agami Karma :
1. Growth of Wealth
2. Growth of Knowledge
3. Social life
4. Marriage
5. Children

Mode of Karma
There are mainly three ways an indivisual performs Karma. You perform your acts or deeds every moment in your life through following ways
1.  Manasa - Mind
2. Vaachaa - Speech
3. Karmana - Actions
 
Can we erase our Karma?
Karma is infinite. Every habit is sort of Karma. Each Karma has a limited time bound affect. The result can be good or bad based on an individual's perception. Being aware of the tendencies may help to overcome the tendencies. But, Karma which has already yielded the result or in process of yielding the result can not be changed or erased. It means Prarabdha Karma is inevitable and should be suffered and endured.

Spiritual Masters say, you can erase your Sanchita Karma through spiritual practices - prayer, meditation and selfless service. And, Agami Karma can be erased through awareness. Only a meditative state of mind does not incur any Karma; and it becomes a witness of every act without any entanglement.

Thus, Karma can be erased only by knowledge (not the information) in form of awareness and spiritual practices, which helps us to make right choices when we act.
 
What if we do not erase?
As most of us do. Either we do not care what we do or due to lack of awareness or ego stay in the trap of the vicious cycle of Karma. Some part of Agami Karma becomes Sanchitra Karma for future. Then, portion of Sanchita Karma becomes Prarabdha Karma and starts yielding the result and at the same time we perform new actions towards Agami Karma and thus we are forced into the cycle of birth and death till we pay all the dues of our total cosmic debt.

Why some good people face bad things in their life?
A person may be very good from all his acts in present life, but you never know what he did in his previous life (lives).

Saturday, October 21, 2006

Understanding 3-Tier vs. 3-Layer Architecture

The terms tier and layer are frequently used interchangeably, but actually there is a difference between them: Tiers indicate a physical separation of components, which may mean different assemblies such as DLL, EXE etc on the same server or multiple servers; but layers refers to a logical separation of components, such as having distinct namespaces and classes for the Database Access Layer (DAL), Business Logic Layer (BLL) and User Interface Layer (UIL). Therefore, tier is about physical separation and units of deployment, and layers are about logical separation and units of design.

Creating a multi tier project design is more suitable and advisable to mid to large-size projects, whereas a good multi-layered design is suitable for small to mid-size projects.

Let’s understand this difference more closely with my earlier posts on “Developing 3 Tier Application in .NET 2.0”. In reality this example is 3-layer architecture because all the layers are logically separated but stay in one code. Following are the namespaces of each layer

1. Vishwa.Example.Data
2. Vishwa.Example.Business
3. Vishwa.Example.WebSite1


The final DLL contains all the above layers: Vishwa.Example.WebSite1

Now, let’s think how to build the same project in true 3-tier architecture. For simple understanding, each layer will be moved to a separate project and thus creating following three dlls. These dlls can stay on the same machine or different servers.

1. Vishwa.Example.Data.dll     --- see  Data Transfer Objects (DTO) - Data Access Layer
2. Vishwa.Example.Business.dll --- see Data Transfer Objects (DTO) - Business Layer
3. Vishwa.Example.WebSite1.dll  -- Now you can refer the above new dlls to perform the same operation


But, by just moving the code of each layer into a separate project will not work, because first and foremost issue is: each layer depends on other layer, so you can not compile one project without other one and here you are in catch 22 situation.

So you will require changes into current design. Also, if you are not planning to keep all the layers in the same folder of your application, then another big issue- how to refer and communicate with each layer’s object. Here is some approach you can take for each layer to convert into a tier model.

  • Literally, create a separate project for each layer.
  • For Database Access Layer and Business Logic Layer ASP.NET Web Services or .NET Remoting can be used. If you can use .NET 3.0 Windows Communication Foundation (WCF) Services, that will be great, they seem to me like Web Services but more powerful, secure and flexible than Web Services.
  • User Interface Layer will stay as ASP.NET Web Site but some changes will be required for invoking or calling Business Objects. However, existing BLL and DAL layers will be removed from current project.
  • Additionally, I will recommend using Microsoft Enterprise Library - Application Blocks for .NET 2.0. This library can help you to build a robust application, it provides solutions to common development challenges such as data access, logging and user interface etc. You can find more information at http://msdn.microsoft.com/practices
  • By using (Web) Services, you will move one step towards Service Oriented Architecture (SOA), which is becoming more popular now in enterprise application development.
You must be wondering why did I use the word 3-Tier instead of 3-layer?

First of all most of the time people are searching on key words like 3-Tier rather 3-Layer. Word 3-tier architecture is most frequently used but heavily misused in IT industry. So it is easier to bring people to the information they are looking for and then educate them as what exactly it means.

Needless to say that it was easier for me to take a simple example for 3- layer architecture design and explain each layer step by step. Developing a true multi tier approach may look like over killing of the sample project. I may write one sometime in future:).

Wednesday, October 18, 2006

Developing 3-Tier Application in .NET 2.0 – Part 3

In this section, I will connect Business Logic Layer (BLL) to Data Access Layer and then User Interface Layer (UIL) to Business Logic Layer (BLL).

Note: If you are developing an enterprise application please see my next article on “Understanding 3-Tier vs. 3-Layer Architecture”.

Business Logic Layer Code
Namespace:
Vishwa.Example.Business

Customer.vb : This class will communicate with previously designed Data Access Layer (DAL) in Part -2.

 
' Author : Vishwa
 
' Date : 10/15/2006
 
' Class : Customer Business Object
 
' Design Pattern: Domain Model and Identity Field
 
' Purpose: This class will act as Business Object and Business Logic Layer
 
 
Imports Vishwa.Example.Data
 
 
 
Namespace Vishwa.Example.Business
 
    Public Class Customer
 
 
 
        Private _custID As Integer = 0
 
        Private _custName As String = String.Empty
 
        Private _custDOB As DateTime = DateTime.MinValue
 
        Private _custAddress As String = String.Empty
 
        Private _dateCreated As DateTime = DateTime.Now
 
        Private _dateModified As DateTime = DateTime.Now
 
 
 
#Region "Constructor"
 
        Public Sub New()
 
 
 
        End Sub
 
#End Region
 
 
 
#Region "Properties"
 
 
 
        Public Property CustID() As Integer
 
            Get
 
                Return _custID
 
            End Get
 
 
 
            Set(ByVal value As Int32)
 
                _custID = value
 
            End Set
 
        End Property
 
 
 
        Public Property CustName() As String
 
            Get
 
                Return _custName
 
            End Get
 
            Set(ByVal value As String)
 
                _custName = value
 
            End Set
 
        End Property
 
 
 
        Public Property CustDOB() As DateTime
 
            Get
 
                Return _custDOB
 
            End Get
 
            Set(ByVal value As DateTime)
 
                _custDOB = value
 
            End Set
 
        End Property
 
 
 
        Public Property CustAddress() As String
 
            Get
 
                Return _custAddress
 
            End Get
 
            Set(ByVal value As String)
 
                _custAddress = value
 
            End Set
 
        End Property
 
 
 
        Public Property DateCreated() As DateTime
 
            Get
 
                Return _dateCreated
 
            End Get
 
            Set(ByVal value As DateTime)
 
                _dateCreated = value
 
            End Set
 
        End Property
 
 
 
        Public Property DateModified() As DateTime
 
            Get
 
                Return _dateModified
 
            End Get
 
            Set(ByVal value As DateTime)
 
                _dateModified = value
 
            End Set
 
        End Property
 
 
 
#End Region
 
 
 
#Region "--Customer Object Functions--- "
 
 
 
        Public Shared Function GetCustomer(ByVal custID As Integer) As Customer
 
            Return DataAccess.GetCustomers(custID)
 
        End Function
 
 
 
        Public Shared Function GetAllCustomer() As Generic.List(Of Customer)
 
            Return DataAccess.GetAllCustomers()
 
        End Function
 
 
 
        Public Shared Function AddCustomer() As Integer
 
            Dim custInfo As New Customer
 
            custInfo.CustID = 0
 
            custInfo.CustName = "unknown"
 
            custInfo.CustDOB = #1/1/1900#
 
            custInfo.CustAddress = "unknown"
 
            Return DataAccess.InsertCustomer(custInfo)
 
        End Function
 
 
 
        Public Shared Function AddCustomer(ByVal custInfo As Customer) As Integer
 
            Return DataAccess.InsertCustomer(custInfo)
 
        End Function
 
 
 
        Public Shared Function UpdateCustomer(ByVal custInfo As Customer) As Integer
 
            Return DataAccess.UpdateCustomer(custInfo)
 
        End Function
 
        Public Shared Function DeleteCustomer(ByVal custInfo As Customer) As Integer
 
            Return DataAccess.DeleteCustomer(custInfo)
 
        End Function
 
#End Region
 
 
 
    End Class
 
End Namespace
 
 
Now, we have Database, Data Access Layer(DAL) and Business Logic Layer (BLL) ready for last step - User Interface Layer (UIL).

User Interface Layer (UIL)
Namespace: Vishwa.Example.WebSite1

Let's add a Web Form in the Project and drop a GridView Control and Object Data Source Control on this page and make sure that you have following code in the Source.
Customer.Aspx
-----------------------------------------------------------------
Code Snippet
  1. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Customer.aspx.vb" Inherits="Vishwa.Example.WebSite1.Customer" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" >
  4. <head id="Head1" runat="server" >
  5. <title>Customer</title>
  6. </head>
  7. <body>
  8. <form id="frmCustomer" runat="server">
  9. <div style="text-align:center">
  10. <h2 >Customer Maintenance</h2>
  11. <asp:LinkButton ID="lnkAddNew" runat="server" Text="Add New" OnClick="InsertBlankRecord" EnableViewState="false" />
  12. <asp:GridView ID="gdvCustomer" DataKeyNames="CustID" runat="server" AllowPaging="True" DataSourceID="odsCustomer" >
  13. <Columns>
  14. <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
  15. </Columns>
  16. <EmptyDataTemplate>
  17. No Customer Record Found.
  18. </EmptyDataTemplate>
  19. </asp:GridView>
  20. </div>
  21. <asp:ObjectDataSource ID="odsCustomer" runat="server" DataObjectTypeName="Vishwa.Example.Business.Customer"
  22. DeleteMethod="DeleteCustomer" SelectMethod="GetAllCustomer"
  23. TypeName="Vishwa.Example.Business.Customer" UpdateMethod="UpdateCustomer">
  24. </asp:ObjectDataSource>
  25. </form>
  26. </body>
  27. </html>


--------------------------------------------------------------------------
Code File: Customer.Aspx.vb
--------------------------------------------------------------------------
Option Explicit On
Option Strict On
 
 
' Author : Vishwa@VishwaMohan.Com
' Date : 10/15/2006
' Class : Customer
' Purpose: To Get,Insert, Update and Delete Customer Record
 
Namespace Vishwa.Example.WebSite1
    Partial Class Customer
        Inherits System.Web.UI.Page
        Public Sub InsertBlankRecord(ByVal sender As Object, ByVal e As System.EventArgs)
            Vishwa.Example.Business.Customer.AddCustomer()
            gdvCustomer.DataBind()
        End Sub
    End Class
End Namespace
 
Code is complete now. Select Customer.aspx page in Project and Press F5 button (run). You will see the customer page as :

Case 1 : No Record.

 

Case 2: Click on Add New Link and a Blank new record with default value will be added
 
Case 3: Click on Edit link and enter a desired value for customer name and address and then click on Update link to update the record.
 
Case 4: Updated record is shown below. You can delete this record by clicking on Delete link. The record will be deleted and you will see the same screen presented in Case 1.

 

I hope this simple example helped you to understand and implement a 3 tier architecture using Visual Studio.NET 2005. If you have any questions or comments, please feel free to post and I will try to answer them.

Once you are able to understand these layer now, let's review the real information in next post.