Archive for June, 2008

C# Inheritance Tutorial

C# inheritance model is quite simple to understand. Typical example would be a “Person” class that gets extended by “Employee” and “Customer” classes etc. I have defined two classes below to show the concept.

public class Person

{

public String Name;

public int ID;

public int Age;

public Person()

{

}

// Defined a virtual PersonType method

public virtual string PersonType()

{

return “Person”;

}

}

public class Employee : Person

{

// When employee constructor gets called, it also calls the constructor defined on the parent class automatically.

public Employee() : base()

{

}

public DateTime DateHired;

public overrides string PersonType()

{

return “Employee”;

}

}

Now the Employee class has all the fields defined in “Person” class available and in addition there is a DateHired field.

To use your classes:

Person person = new Employee();

This creates a new instance of an Employee class and puts the reference into the person variable. This is possible since the Employee class inherits from the Person class. If you call the PersonType method on “person” object instance what do you think will be the result?

“Person” or “Employee”?

The beauty is that the overridden method gets called even though the variable instance is of type “Person” and PersonType method returns “Employee”.

I’ll be posting more tutorials soon that build up on this one.

Advertisements

Leave a Comment

Looking at MySQL

I must admit that I have mostly worked with SQL Server and a little bit with Oracle. I am now getting ready to start a project that will work with MySQL. I was looking at few samples to see how to do different things. One of the coolest things I found in MySQL is the ability to do paging is very simple. Unlike Oracle or SQL 2005 which require complex SQL constructs to build a query that returns a subset of rows at a time, MySQL uses a very simple approach. MySQL uses a keyword called LIMIT and you can specify two values after LIMIT and they are used as the starting point and the ending point of number of rows.

So if you want to create a paged query in MySQL all you have to do is add LIMIT keyword at the end.

select * from `products` LIMIT 10, 5

This query above would return rows that are on positions 11, 12, 13, 14, and 15.

Simple isn’t it? Now match that SQL Server or Oracle!!

I actually never really had to write paged queries by hand as my favorite ORM product Quick Objects always took care of that for me. All I had to do was set two properties even with most complex joins/criteria based queries. Quick Objects guys are saying they will start supporting MySQL in the next release which should be due about now so lets see how that goes.

Another thing I found is the ability to do replication in MySQL. I haven’t fully gone through the docs but thats next.

Leave a Comment

A cool article that shows how to implement MetaWebLog API in .NET

I have been researching various blogging software and tools for last few days. Mostly out of curiosity I started looking at various published APIs that allow client side tools to interact with blogs. My curiosity led me to this cool article that shows how to implement MetaWebLog API in .NET. There are three main API sets that I came across and those are Blogger, MetaWebLog and LiveJournal. MetaWebLog from what appears to be is a superset to Blogger API, but LiveJournal is different.

The article goes into details on how to create an HttpHandler and then also define the MetaWebLog data structures. Checkout the article here.

Leave a Comment

Drawing in plain old javascript

I just found this really cool article that shows how to draw lines in javascript and then I found this tool called EasyDiagram.net it is a diagramming tool built in ASP.NET and AJAX.

Amazing!

Comments (1)

Is Astoria (ADO.NET Data Services) going to be the answer to cloud computer?

I think there is a lot of confusion in developer community as to where is Microsoft going with Astoria, Silverlight, SQL Server Data Services and Entity Framework.  I just read an article on VS Magazine titled Manipulate Data in the Cloud with ADO.NET. After reading I realized that article simply covers Data Services and REST implementation etc but doesn’t really show anything remotely related to cloud. I guess the author forgot the cloud in a cloud 🙂

Don’t get me wrong I liked the article but don’t agree with the title.  Sometimes I feel I am the only one pulling my hair looking at some of the new stuff being thrown in by Microsoft.  I think my dream of being able to create applications by just thinking about them isn’t going to be a reality anytime soon.

Comments (1)