Monthly Archives: April 2010

Difference between ASP.NET and PHP


The first and foremost diffrence between these two great dynamic language is: simplicity.
To start working in PHP takes less than five minutes!
Yes, if you use Windows, just download WAMP and go to the www folder, create your own folder and save a php file (as you wish name it index.php) and starting WAMP server you can see the output.
The whole process will take less than 5 minutes.
If you are in LINUX/UBUNTU, then I’ll suggest to download XAMP for LINUX and running it there also will not take more than 5 minutes and less than 10 minutes 🙂
But in case of ASP.NET, to install VS it might take an hour or more!
Getting VS(you can download it from Microsoft directly, obviously not the enterprise one but the student edition), but again then it’ll take a fair amount of time.
So, if you consider the simplicity, PHP puts ASP.NET much behind.
Now, when the working environment is concerned, getting PHP codes is also much easier. Though, .NET community is also very strong and there are few good forums all around, but working in ASP.NET takes much more time than PHP.
In one aspect, I think ASP.NET puts PHP behind, is its user friendliness. In VS you can drag and drop great web controls that are ready to serve your order. You don’t have to write much code.
In PHP, there are thousands of functions but all you have to write single-handedly.
I don’t know much about the ZEND framework. Is it like VS where you can get the help of in-built functionality?
If anyone knows about it, please let me know.



I was attracted to dynamic web language like PHP and later on ASP.NET for the sake of its interactivity.

To do that user input is extremely important. Basically it’s done by taking data from the client side. But it has to be worked out on the server side to do anything on the fly.
I recently work on a simple Q and A project in ASP.NET, where every user can log in to the member’s page and answer questions posted by another client.
.NET class library has made the whole affair so user friendly that I don’t have to write lengthy codes to do the whole thing.
In PHP, it might be more simpler, I frankly don’t know. My PHP knowledge is still to that exxtent limited.
Hope one day I can do the same thing in PHP also!

Difference between function and method


In PHP I took reference from Beginning PHP 5 and MySql 5 By W Jason Gilmore, Appress book.
A method is quite similar to a function, except that it is intended to define the behavior of a particular class. Like a function, a method can accept arguments as input and can return a value to the caller. Methods are also invoked like functions, except that the method is prefaced with the name of the object invoking the method, like this:

Methods are created in exactly the same fashion as functions, using identical syntax. The only
difference between methods and normal functions is that the method declaration is typically
prefaced with a scope descriptor. The generalized syntax follows:
scope function functionName()
/* Function body goes here */
For example, a public method titled calculateSalary() might look like this:
public function calculateSalary()
return $this->wage * $this->hours;
In this example, the method is directly invoking two class fields, wage and hours, using the $this keyword. It calculates a salary by multiplying the two field values together, and returns the result just like a function might. Note, however, that a method isn’t confined to working solely with class fields; it’s perfectly valid to pass in arguments in the same way you can with a function.
Methods are invoked in almost exactly the same fashion as functions. Continuing with the previous example, the calculateSalary() method might be invoked like so:
$employee = new staff(“Janie”);
PHP supports six method scopes: public, private, protected, abstract, final, and static. The first five scopes are introduced in this section. The sixth, is static.
$salary = $employee->calculateSalary();
Public methods can be accessed from anywhere, at any time. You declare a public method by
prefacing it with the keyword public, or by foregoing any prefacing whatsoever. The following
example demonstrates both declaration practices, in addition to demonstrating how public
methods can be called from outside the class:

class Visitors
public function greetVisitor()
echo "Hello
function sayGoodbye()
echo "Goodbye
$visitor = new Visitors();

Now let’s see what happens in ASP.NET, or to be precise in C# :
I got a good answer from EggHeadCaffe
The major difference between methods and functions is that methods called by the reference variables called objects where as the functions do not having any reference variables.methods are invoked using objects.wheres as in case of functions here is no quesion of objects.we call it directly.
And yet another good answer from StackOverflow
A function is a piece of code that is called by name. It can be passed data to operate on (ie. the parameters) and can optionally return data (the return value).

All data that is passed to a function is explicitly passed.

A method is a piece of code that is called by name that is associated with an object. In most respects it is identical to a function except for two key differences.

It is implicitly passed the object for which it was called
It is able to operate on data that is contained within the class (remembering that an object is an instance of a class – the class is the definition, the object is an instance of that data)
(this is a simplified explanation, ignoring issues of scope etc.)

Resolution Midway….


Ususally people make resolutions before a year starts.
I’m slightly different. So I start it midway, almost, as May is knocking the door yelling with temperature around 40 degree at noon though in the ‘midnight summer’ I find it cool.
So what is my new resolution that I’ll (any one bets on that) break, that is also midway :).
The resolution is I’ll try to write something, some words, oh, every word has its own universe, so you can imagine how heavy it can be to bear it in mind without putting it on digital paper.
So I’ll be a compulsive blogger. I don’t tweet. In fact, twitter attracts too many crowd, and I don’t like to stand in the crowd, I don’t like to follow other people, don’t like to be followed, so no tweeting at all, I’m happy with my big fat blogs.
And hopefully I’ll try to write it regularly!

Red Letter Day


As Bhibhutibhushan wrote in his modern epic Arannayak, people often make things glorified in his/her mind. Otherwise, everything is so tiny compared to the Great Nature/Life.
Anyway I make this day glorified by naming it “Red Letter Day”. Why? Just now I have beaten computer chess software in a match!
After installing Ubuntu I often play with the computer though I still don’t know the basic grammers, still it’s enjoyable experience indeed.

My GrandPa


I lost my both Granpas very early. I did not see them. Not my paternal, nor my maternal.

My old computer, the desktop one, has been with me since last six or seven years. I name it GrandPa.

It’s quite funny, a very heavy software like VS 2008 runs fine. No complain. But not for same in my two users!

In the first user ‘hagudu’ if it gives trouble then for sure I know that it’ll run okay in the next user ‘mutudu’.

How funny is the machine, sometimes it seems they are alive and kicking!

Understanding DataSet and DataTable


I’d like to find out the best way to handle data query. In ASP.NET, SQL query plays vital roles. But to work with Data Table, which one is better? Dataset or Datareader?
Actually the choice is yours.
According to the situation it changes. Sometimes you may find the first one better, but for a bigger application involving many DataTables, Dataset is a better choice, I think.
You are the best judge, still I’ll quote from a great book
ASP.NET 3.5 SP1 Edition
In C# and VB
Bill Evjen
Scott Hanselman
Devin Rader
Now read what they have to say on this great debate:
Deciding When to Use a DataSet

As revolutionary as a DataSet might be, it is not the best choice in every situation. Often, it may not be
appropriate to use a DataSet; instead it might be better to use a DataReader.
With ADO 2.6, it was possible to perform a command upon a data store and get back a single
collection of data made up of any number of rows. You could then iterate through this collection of
data and use it in some fashion. Now ADO.NET can use the DataSet to return a collection of data
that actually keeps its structure when removed from the data store. In some situations, you benefit
greatly from keeping this copy in its original format. By doing so, you can keep the data disconnected in
an in-memory cache in its separate tables and work with the tables individually or apply relationships
between the tables. You can work with the tables in much the same manner as you do with other relational
data sources — using a parent/child relationship. If it is to your advantage to work with certain
data with all its relationships in place (in order to enforce a parent/child relationship upon the data); in
this case, of course, it is better to use a DataSet as opposed to a DataReader.
Because the DataSet is a disconnected copy of the data, you can work with the same records repeatedly
without having to go back to the data store. This capability can greatly increase performance and lessen
the load upon the server. Having a copy of the data separate from the data store also enables you to
continuously handle and shape the data locally. For instance, you might need to repeatedly filter or sort
through a collection of data. In this case, it would be of great advantage to work with a DataSet rather
than going back and forth to the data store itself.
Probably one of the greatest uses of the DataSet is to work with multiple data stores and come away with
a single collection of data. So for instance, if you have your Customers table within SQL and the orders
information for those particular customers within an Oracle database, you can very easily query each
data store and create a single DataSet with a Customers and an Orders table in place that you can use in
any fashion you choose. The DataSet is just a means of storage for data and doesn’t concern itself with
where the data came from. So, if you are working with data that is coming from multiple data stores, it
is to your benefit to use the DataSet.
Because the DataSet is based upon XML and XML Schemas, it is quite easy to move the DataSet
around — whether you are transporting it across tiers, processes or between disparate systems or
applications. If the application or system to which you are transferring the DataSet doesn’t understand
DataSets, the DataSet represents itself as an XML file. So basically, any system or application that can
interpret and understand XML can work with the DataSet. This makes it a very popular transport
vehicle, and you see an example of it when you transport the DataSet from an XML Web service.
Last but not least, the DataSet enables you to program data with ease. It is much simpler than anything
that has been provided before the .NET Framework came to the scene. Putting the data within a class
object allows you to programmatically access the DataSet. The code example in Listing 8-12 shows you
just how easy it can be.

SqlConnection conn = new SqlConnection
SqlDataAdapter da = new SqlDataAdapter("Select * from Customers", conn);
DataSet ds = new DataSet();
da.Fill(ds, "CustomersTable");

Basically, when you work with data, you have to weigh when to use the DataSet. In some cases, you
get extreme benefits from using this piece of technology that is provided with ADO.NET. Sometimes,
however, you may find it is not in your best interests to use the DataSet. Instead, it is best to use the
The DataSet can be used whenever you choose, but sometimes you would rather use the DataReader
and work directly against the data store. By using the command objects, such as the SqlCommand and the
OleDbCommand objects, you have a little more direct control over what is executed and what you get back
as a result set. In situations where this is vital, it is to your advantage not to use the DataSet.
When you don’t use the DataSet, you don’t incur the cost of extra overhead because you are reading
and writing directly to the data source. Performing operations in this manner means you don’t have to
instantiate any additional objects — avoiding unnecessary steps.
This is especially true in a situation when you work with Web Forms in ASP.NET. If you are
dealing with Web Forms, the Web pages are re-created each and every time. When this happens, not
only is the page re-created by the call to the data source, the DataSet is also re-created unless you are
caching the DataSet in some fashion. This can be an expensive process; so, in situations such as this, you
might find it to your benefit to work directly off the data source using the DataReader. In most situations
when you are working with Web Forms, you want to work with the DataReader instead of creating
a DataSet.