Monday, January 31, 2005

Started lecturing again...

Started doing lectures again after a break for around 2 years. Lecturing is something i always liked to do and finally got a bit of time to start on it. Currently I am conducting lectures on Visual Basic.NET at Gateway. Have to wait and see how it goes.
It also gives me a reason to get my MCT soon since i was postponing it for a long time now.
PS :Thx Merill for getting me started on this

Friday, January 28, 2005

Peek .NET 2005: The IsNot operator

When you think about the things that makes VB so applealing for a lot of programmers, one of the first things to come into your mind is the simplicity of it. So readability of your program is always an important factor when programming.
If i want to make sure a reference variable does not have a null reference the general syntax in VB.NET is to use the keyword 'Is' and 'Not' as in:
If Not x is Nothing Then

With the new IsNot keyword this becomes:
If x IsNot Nothing Then

So what are the advantages of the latter over the former? As far as i know nothing much except it looks more readable and more simple and keeps to the spirit of the VB language.

Wednesday, January 26, 2005

Imagine cup: Kelaniya uni

We had another imagine cup intro at kelaniya university. Jinashri from Microsoft did a introduction among the students on the imagine cup competition. Following that i did an introduction on web services and mobile computing and some general topics on web site and blogging.
There were a few students very interested about the competition but were a bit reluctant since they were new to web services and mobile applications using the Microsoft.NET platform.
We planned to have a small workshop organized to give the students an idea on how easy it is to get started on using VS.NET to create web services and mobile applications.

Tuesday, January 25, 2005

MVP global summit for 2005 announced

This is exciting since this is my first year as a MVP. The MVP global summit is going to be held on Sept. 28 - Oct. 1 in Redmond, Washington. It would be a very exciting event and i look forward to be a part of it. I hope i can save enough cash by september to participate in it...
With Srilanka currently having 7 MVPs and with most of us being veterans it will be an exciting opportunity to learn more about the MVP program as well.
There is also news about an asian summit to be held in april, but no concrete news on it yet.

Thursday, January 20, 2005

Peek .NET 2005:Gotcha in generics

Connected to my previous blog on generics:
Assume that the Manager class inherits from the Employee class. So the following code is perfectly fine:
Dim mngr as new Manager
Dim emp as Employee=mngr
I can assign a Manager object to the Employee variable since all Managers are Employees.So let's apply a bit of Generics:
dim colMngr as new Collection(Of Manager)
dim colEmp as Collection(Of Employee)=mngr
I am just storing a collection of Managers in a collection of Employees variable. Looks fine? Well it's not...Generics does not work that way.
If the above code is fine then if i have an Executive class inheriting from Employee then colEmp.add(new Executive())
will be legal. But then what if i want to access the collection through the colMngr variable which is supposed to hold only a Collection of Manager objects...but now i have an Executive object inside it.
So the compiler will prevent this from happening. But remember this, as it may seem strange when doing Generics initially

Tuesday, January 18, 2005

Peek .NET 2005: Generics

Before .NET 2005(This is still supported in .NET 2005 as well) when we define a collection we use the syntax:
private col as new Collection
So if i am going to use this collection to add and retrieve Customers i have to use the syntax:
col.Add(New Customer())
Dim cust As Customer = CType(col.Item(0), Customer)
But if i already know i am going to use this collection only for to store Customers this casting is a real pain. And the compiler will do nothing to prevent me from storing a String or some other object type in this collection(A run time error will be throw when i try to cast it to Customer)

With .NET 2005 you have a special set of collection classes under the Collections.Generic namespace. With this i can define a collection as:
private col as new Collection(Of Customer)
Notice the new keyword 'Of', this indicates this collection will be used to store only Customer objects.
col.Add(New Customer())
Dim cust As Customer = col.Item(0)
No more unnecessary casting since the return types are of the Customer type and not the Object type. The compiler will detect if you are trying to store some other types other than what is defined. And what more you can also define and use Generics in your own classes and constructs but i'll save that for another blog

Monday, January 17, 2005

Nothing too Generic about it

Generics are a great addition to any programming language and it's the sort of feature that reduces a lot of coding and unnecessary type castings.
For example a lot of constructs in object oriented programming languages use the object type when the data type a programmer will use is not known. If i am defining my own version of a queue as a library, i will not know the data type of the objects the end user of my queue will store. So when adding and retrieving elements i'll be resorted to using the object type since it can store any type of objects. The real problem here is typically the user of my queue will already know what type of objects he is going to store. But still since i am using the object type each time an element is retrieved it has to be type casted into the proper data type. This is very time consuming and a real pain. And if an invalid type is added to the queue a run time exception will be thrown...
So what is the solution? Ideally when i define the queue i should be able to use a placeholder for the type without specifying a concrete type. The user of my queue should be able to replace the placeholder with a specific type when creating an instance of my queue. So since the specific data type the queue is going to use is defined, the compiler can take care of not allowing objects of other data types to be added. This is exactly what generics are.I'll post a few samples on this for the new VS.NET 2005(alias Whidbey) as well as the new Java 5.0(alias Tiger) in my upcoming blogs...

Thursday, January 06, 2005

January .NET User group meeting

We had the .NET January user group meeting yesterday. It was not very crowded with the Tsunami disaster but it was nice to see some new faces in the forum meetings. I gave an introduction along with Wela on Mobile application development and then we spent some time answering questions and problems from the forum members.
It was also great to know a few more additions to the MVPs in Srilanka with the inclusion of Jinath, Wela and Manzi. Congrats guys...

Monday, January 03, 2005

Predictions for the IT industry in 2005

This is funny. Especially the one about the war between C# and VB.NET. Check the link at: