Sunday, April 16, 2006

Query Notifications in ADO.NET 2.0

Query Notifications are a new feature part of ADO.NET 2.0. I gotta admit that the rationale behind it is really valuable - getting notifications back from the database server, when a given dataset of interest is changed. I've implemented the same functionality with MSSQL 2000 requiring periodical server polls, but this is really not very performant solution. With ADO.NET 2.0 and its Service Broker, you can have quick and elegant solution.

While the idea behind QN is really easy to understand, the documentation and examples are still kinda scarce. Not only this, but there turned out to be very small details, which may give you couple of hours in debugging in order to detect them.

To start with, here is a list of articles about Query Notifications in ADO.NET 2.0:

1. Query Notifications in ADO.NET 2.0 [link]
2. Using Query Notifications [link]
3. Enabling Query Notifications [link]
4. Using a Dependency to Detect Changes in the Server [link]

All of these will give you some very good understanding of what QN is all about. However, I found some problems with the examples in them, so don't be confused if you try them and they are not working - it is not you :)

Speaking of problems, one of the subtle things you should have in mind is that the query assigned to the SqlCommand object must be fully qualified (that is the table name should include the table owner, you should enumerate all interested columns in the SELECT clause rather than putting a simple * for ALL columns). Actually if you take a look at the following article:

5. Using SqlDependency for data change events [link]

you will see a bunch of things which the author has experienced (the same as me) while dealing with QN.

Another problem that I got was with my OnChangeEventHandler event handler. I initially received OnChange notifications although there were no DML operations on the monitored dataset. The info that I got from the SqlNotificationEventArgs parameter for this event was the following:

e.Source = Statement
e. Type = Subscribe
e.Info = Invalid

The reason for this was that my SELECT statement was using * for all the column names instead of fully qualifying the columns put in interest. I bet that if this is a problem, then the description of it should be somehow more descriptive and showing more symptoms of what actually caused the specific problem.

Another problem that I got was with the QN registration for the specific database you want to enable it. For this, you should check out the following article:

6. Using Query Notifications in .NET 2.0 to handle ad-hoc data refreshes [link]

SqlDependency is one way to use Query notifications in your application. What is worth noting about it, is that one SqlDependency is good only for a single notification. That said, after one notification has been generated through your SqlDepedency, you should re-create it if you want further changes to be captured. Another cool thing with SqlDependency, is that it can easily applied to ASP.NET cache object (check out article 1 for more information).

Thursday, April 06, 2006

SqlDateTime overflow problem and DATETIME columns allowing NULLs

Couple of hours spent in debugging and finally you see the problem is cased by a completely different reason. This was my today's experience.

So you have T-SQL insert statement for a table which has one of its columns defined as DATETIME which allows NULLs. You are passing an uninitialized variable for exactly this column in your INSERT (not purposely of course :) ), and the error you get is:

System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between
1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.


What do you do? Well, I was very confused seeing this message. I hit the Internet for a similar problem but I was totally deluded in stories that SqlDataType is not compatible with .NET DataTime type. Obviously I was on a wrong direction. Thus, after I reviewed my code, I saw that the value of the DateTime column, which allows NULLs is not actually NULL but rather DateTime.MinValue - indeed, and this is normal because each .NET variable once defined it is initialized with some default value (which in the DateTime case is DateTime.MinValue). Unfortunately, DateTime.MinValue doesn't really fit into the range of possible values for SqlDataTime.

What is the resolution? Well, I am using .NET 2.0, where there is a very neat generic type named Nullable. Check out this article for more info about it. Put shortly, using this type I am able to pass NULL values for the DATETIME column allowing nulls without getting the extremely confusing exception shown above.

Wednesday, April 05, 2006

LoginStatus control does the work

Today I was fighting with the well-known problem with Back button in Internet browsers for a session agnostic Web applications. Simply put, you have a Web app and at some point of time you want to sign out. Then you normally destroy the user's server side session, but the problem is that the user still can hit his Back button on the Internet browser and see a the cached content from the pages he/she has visited.

Well, this problem has been resolved long time ago - I remember it since the early ASP days. So normally what is done is to set the content expiration to immediate to *all* pages within your Web application. Of course, sometimes, this may be not desirable, but still in my cases it was essential not to give the user the possibility to go back. So the solution is to set 3 HTTP headers to all HTTP responses - Pragma, CacheControl and Expires.

Today, I had the same problem while implementing the logout functionality of our ASP.NET 2.0 based Web application (just to mention we are using very cool stuff like Microsoft Atlas, SQL 2005, Virtual Earth API - fascinating, isn't it?). Again, the old solution seems to be working (setting the aforementioned HTTP headers), but I somehow decided to try out the LogingStatus control. This control changes its state based on the current user status - if he is logged in it is a link which will allow him to Logout and if he is not authenticated - it will be "Login" link. And here are the good news - if you use this control, there is no need to set these headers to your whole application - it is done automatically to you when you use this control. Pretty sweet! :)

Monday, April 03, 2006

Cycle Clipboard Ring command

Visual Studio 2005 rules! Today I found the command named "Cycle Clipboard Ring" (on the Edit menu in VS2005 or using the default keyboard shortcut CTRL + SHIFT + V). While ago while I was so deep into the Visual Studio 6 development, I used a very popular tool named Visual Assist which was really like the paradise for all Visual C++ developers using VS6. So this tool had the same feature like "Cycle Clipboard Ring" I am referring now. I personally find it very useful to see a quick menu of all of your previously copied code blocks so that you can easily paste them. Love it!

Talking about "hidden" commands, there is one more I discovered today being very popular in Java IDEs in particular. This time this feature is part of ReSharper for Visual Studio 2005 (still a beta and not very stable thus, but still has very useful features without which I feel like I will get back in 1st grade :) ). Well this feature is named "GotoRecentFiles" and on the default keyboard scheme is accessed thru CTRL + E. This gives you a popup window with all of your recently accessed files. Sweet!

To some of you these features may not be very significant, but still when you deal with huge code bases, you want to minimize your time to switch between files and to somehow boost your productivity without dealing with routine things. I hope that this post will give some delight to those of you who are used to such kind of "widgets".

Friday, March 17, 2006

Team Foundation Server Released

Microsoft decided to split the VSTS product and to ship Team Foundation Server alone. The official release should be available within 3-5 days, as can be seen from this article. I am currently working on a project which uses VSTS for team collaboration and development, but still this platform seems to have some issues. I hope that this new release will be better one.

ASP.NET 2.0 quickstart videos

Today I found this very very valuable resource, where you can find useful videos covering HOWTOs for different features from ASP.NET 2.0 and the new Microsoft .NET 2.0 framework. I am sure that you will like this site - just don't miss it! :)

Enjoy!

Monday, March 13, 2006

Origami project

I don't know have you heard of it, but this is the latest craze in gadget world - Microsoft's Origami project. This device (said Microsoft) will be the next generation gadget, which will combine all the strengths of Tablet PC and Pocket PC. The official date when Microsoft announced this project was on 3rd March and I can tell you that this date had been the "most awaited day" for many people. However, it is too early to say when it will be made to the public (at least I haven't found such information yet), but still knowing what's coming up is valuable.

The official site of the project is this - check it out. I was personally amazed by the way the whole page is designed and the overall presentation to the viewer - it makes you somehow believe that this product will really change you life :-) .

Origami project will actually develop a ultra-mobile PC, which will be far away more than any personal assistant you have ever had, giving you versatile online connectivity thru Bluetooth, full fledged Microsoft office installed, exciting features like mapping, geocoding and GPS location tracking. The official OS which run on this device will be genuine Windows XP. The premium touch screen (which is really very very fancy, especially the keyboard!) and the whole user interface somehow resembles Tablet PC, but still if you compare the sizes the Origami device is far away smaller. If you want to know more technical details about this device, please go to the official Microsoft site, where you will find bunch of information about this topic - here.

Actually, there is a post on Channel9 about it, which I really recommend if you want to get some "hands-on" experience about what is it all about (see it here).

Free Microsoft beta exams

Folks,

There are 3 beta exams currently being free for a limited time:

71-547 PRO: Designing and Developing Web-based Applications by Using the Microsoft .NET Framework. Promo Code: PRO547
71-548 PRO: Designing and Developing Windows-based Applications by Using the Microsoft .NET Framework. Promo Code: BTA548
71-549 PRO: Designing and Developing Enterprise Applications by Using the Microsoft .NET Framework. Promo Code: 549BTA
(more information find here: http://www.microsoft.com/learning/offers/beta/)

Pay attention to the fact that if you take one of these, you will enter the lottary to win a smartphone! :-)

Monday, February 27, 2006

Code Analysis for Managed Code feature in Visual Studio Team System

As I already mentioned in one of my previous posts, I am starting a new project based on ASP.NET 2.0 and Microsoft SQL Server 2005. I had the chance to acquaint with these two and I can't hinder my astonishment and gratitude - really Microsoft has done great job with these. And to continue the conversion in the same direction, we are going to use Visual Studio Team System (VSTS) as our primary IDE along with its abundant features for project collaboration and control. Now I am going to give you a short overview of one the greatest features that VSTS has, and in my future posts I hope that I will give you more food for you soul :-)

Well, the feature I want to discuss now, is Code Analysis. Here is a short overview of what it actually is all about:

"Code analysis for managed code tool analyzes managed assemblies and reports information about the assemblies, such as violations of the programming and design rules set forth in the Microsoft .NET Framework Design Guidelines. "

Simple as that! Now, what it has to do with VSTS is that it is fully integrated into it and can be part of the build process, code check-in process and/or Team System build process.

The best way to understand this feature and see how powerful it is, I suggest playing with it. In order to enable Compile time Code analysis feature, just go your solution properties in VSTS, choose "Build" section and there select "Enable Code Analysis" checkbox. Then rebuild it and in the Output window you will see the results from the additional build step performed regarding code analysis.

What I personally found as very neat feature is the code analysis check-in feature - that is whenever you try to checkin source code in the team repository, your code will be verified whether it conforms to Microsoft guidelines for quality code. Here is a link, where you can find additional information about this feature (link).

I still don't know whether the set of rules for code analysis is extensible - if it is using FxCop underneath, I guess that will be as easy as a breeze.

Friday, February 10, 2006

Compiz Window Manager

Now I am really amazed! Just see the preview of Compiz Window Manager from here! Besides the screenshots, I highly recommend watching the movie (~50 MBs).

Thursday, February 09, 2006

Microsoft E-Learning courses for ASP.NET 2.0 and SQL Server 2005

We are about to start a new project which will levarage ASP.NET 2.0 with Microsoft SQL Server 2005 - ahhh, I am so thrilled! We all know that in terms of technologies, the aforementioned two can be classified as babies - hey the official release of Visual Studio 2005 was like 3 months ago.

My role within this team will be project manager - quite challenging becuase I have to find the optimum between the skills of the team members and the project specific goals and domain. In regards with technology, I am now at the phase where I am gathering different sources for education about ASP.NET 2.0 and Microsoft SQL Server 2005.

One very valuable resource, especially for those who have solid background with Microsoft .NET framework 1.0/1.1, is the online courses at Microsfot E-Learning (link). The courses there are separated into different sections, based on the different Microsoft products and the targeted audience (IT administrators, Software Developres, Advanced Developers, etc.). Here are the two sections that we will need:

  • Visual Studio 2005 courses (link) - includes coures for Microsoft .NET 2.0, ASP.NET 2.0, Windows Forms
  • Microsoft SQL Server 2005 courses (link) - these courses are free until November 2006!!!!
I personally like the format that these courses are presented. There is an offline browser, where you can download a specific course and go throught it whenever you want - just awesome!

What I don't like with this really very helpful service is that the courses which are not free, are available only for North America. See the excerpt below from here:

"Microsoft E-Learning products are currently available for purchase only within North America at this time. However, any content that is offered for free, or users who are redeeming a voucher or activation code, can access e-learning courses worldwide."

I am wondering - is it only a matter of billing control? If I am able to view the free content, then obviously there will be no problem to see the paid one. However, I guess that the billing system is not integrated with European's one, which may be the bottleneck with this. Or I could be wrong ...

Friday, February 03, 2006

Internet Explorer 7 Beta 2 Preview

The new and glamorous IE7 (beta 2) has been installed on my laptop successfully! I've heard a lot about it, but because it is a beta I thought that I didn't want to run into trouble. But, today I found lots of reviews of other peers who have already installed it and used for more than 30 days, and no one seems to have any major complains. Well, I said, why shouldn't I try it out?

To begin, you can download it from here. From there, you will prompted to download an installation, which is not that big - approx 11 MBs.

OK, and here are my first impressions. It is obvious that Microsoft is trying to get back into the Internet browsers space. Personally, I am using, IE6 but I am really not very delighted with it. I am "obliged" to use it, because I am used to store links from my local MSDN library, and in order to open them, I actually need IE. And honestly, this is the only reason not to forget about it. During my "free" surfing time (when I am not using MSDN library), I prefer Opera because of so many reasons like:
1. Has tab display
2. Has awesome bookmark features in terms of searching and maintenance.
3. Has the concept of sessions - thus you are able to store a given set of links under a given label, so that you can get back to this "topic" whenever you want.
4. Has integrated support for RSS
5. Has integrated support for NNTP
6. Has integrated mail access

Well, this list seems to be a long one for sure. With IE7, some of these wish-items have been fulfilled. For example, IE7 has tab display and supports RSS natively. It also has integrated search capability, which according to me is very useful. However, I respect the fact that on default they are using Google Search (not MSN Search), which shows that they are trying to follow customers preference (hey, we all know that Google Search is the most used search engine, respect!). Among these, I will say that the new design and outlook of IE is very very sexy, which for me as a user is also important.

However, I would have been far away more satisfied, if IE had had improved its bookmark capabilities. I personally have more than 5000 favorites, and believe me, it is really hard to search and navigate in IE. On the contrary, in Opera they have this very useful search, which digs into all directories of your favorites (not just in the root as it is in IE). But, hopefully, Microsoft will add it in the future - fingers crossed! :)

Thursday, February 02, 2006

Web 2.0 and the future of Internet

It's been a while since the term "Web 2.0" began to emerge in technology articles and information sources. I am sure that you will meet it more and more in the future. In general, Web 2.0 referes to the "evolution of World Wide Web". There, the applicatoins will become more interactive and rich in functionality and thus get over the old perception that Web is more about static content. A good article about Web 2.0 was written by Tim O'Reilly and can be found here - take a look at it, it is really great.

Back to Web 2.0, the main focus is to design a new generation of services such as Microsoft Virtual Earth, Flickr, Orb and Digg ( and there are many many more). These are very, very strong examples, showing that the era of static Web documents is far far away. Actually, if you haven't already, I strongly recomment trying these out. With Virtual Earth you have a great map service at your finger tips and an amazing "Eagle Eye" view, which shows you a close view of a given terrain. You want to find a cafe in the local area - no probs, just search it there. Orb gives you the ability to stream TV and any kind of media from diverse locations. The last one, Digg, I find really amazing. People need information for in all kinds of topics, but sources are most important. Some of them are very biased, others - not reliable. Digg is trying to solve exactly this - each article has a "digg" index, which shows how many digg-ers liked and found it useful.

Tuesday, January 31, 2006

Delivering services or buying software?

It's been a while, since I started noticing that most biggest software companies are trying to settle their business around service delivery, rather than creating conventional software. Indeed, have you asked yourself why SAP are so successful, what are they delivering so unique to its customer that it has such a huge revenue? Well, the answer is that they are not selling software, they are selling the service! I don't want to get into the shoes of their accountants, but they are really making a huge revenue where their customers don't actually have anything in their hands forever - they just pay their subscription for a given period for a given pack of services and that's it! You need assistance - SAP is here, you need education - SAP is here, you need a new feature - SAP is here, but you are not actually buying all these - you are just paying for the services.

Recently, we have been witnesses of the great success that Google. And what they have, is it an operating system? Is it a software that is so unique?No. They provided to its customers the service to be able to search very efficiently. Well, after that they have many other services like GoogleTalk, Google Video etc, but still their "customer" are just using the service rather than buying it.

And guess what - Microsoft whose biggest income so far has been from its operating systems and Microsoft Office, they are now trying to settle into this business too, because it is obviously very profitable. Go to Windows Live and you will see what I am talking about - very useful services like MSN Messenger, Security, Favorites, etc. Microsoft is planning to fight for Internet users and because of this they are now restructuring and investing in their MSN group. And I am sure that pretty interesting things are about to emerge.

But yeah, I believe that in the future the share of IT market that services are going to occupy will become dominant as opposed to the traditional software. Actually, take a look at this article: CSFB says 'traditional software is dead' (link). There you will see that this time this will happen is not too far away...

Monday, January 30, 2006

HOWTO write unit tests

I was working on a project, where the client had requested to follow the test driven development (TDD) methodology while working on his project. Before this I personally had read a lot about TDD and unit test in particular, but I had never engaged it a real project.

Some very common questions that you will have in this case is:
* What functionality should I test?
* Are my tests relevant to the business requirement?
* How should I structure my unit tests so that I know which ones to run when I make a specific change?
* How many unit tests are "good enough"?
* How should I design my code so that it is liable for easy unit testing?

One of the very good consequences of TDD is that each developer starts thinking a little bit like a software tester. We all know that developers develop to run, while testers run to break. Well, if developer invests some time to gain a more comprehensive understanding in the problem that (s)he has to implement, then chances are that (s)he will produce less bugs. And this is one of the main tenets of TDD. By developing test cases, developers tend to gain a more versatile understanding over the problem domain they have to implement and thus their code is prone to less bugs. I totally agree that this is just a theory, and basically it depends on what unit tests the developer creates, what is the code coverage of those tests, how often are the tests run and of course - are the tests actually relevant. A good place to start learning what are the most basic requirements for efficient test cases, visit the article "Write Maintainable Unit Tests That Will Save You Time And Tears" (link).

One of the biggest challenges that I had so far in my experience was to design my code so that it is easier to be unit tested. It really depends on the programming language that you use as well as the platform that you are using. My experience so far is with Microsoft .NET, where the unit testing framework which is most used is NUnit. So when it comes to design, we had to design our applications that in one hand they are easily to be tested, but on the other side the testing code is somehow out-of-the-box. Therefore, we decided to implement the business logic in separate class libraries (.DLLs), which exposed the main business classes. This has the following benefits:
1. Class libraries allows to be easily reused - thus, we wanted to use a single assembly for multiple places within our system, we were able to to this
2. Class libraries are easier to be tested - what we did was to create a "bootstrapping" code which just represented the specific unit tests on each single class / method. Thus, we had very well separation among unit testing, business logic and presentation.

Here is an article that is something like a quickstart for test driven development in C# - click here.

Monday, January 23, 2006

Java or C# - which one is more competitive?

I found this article which basically describes the trend in software development in the past 2005. I was really glad to see that Microsoft .NET is getting a fast pace over its rival Java. While years ago IDEs for Java were really far ahead compared to Microsoft Visual Studio 6 (I remember the times when Visual Assist was a not a requirement, but rather a must for this IDE, and after all it just give you a quick file navigation and syntax coloring). Well, with the release of Visual Studio 2005 Microsoft provided developers with a IDE, which really is integrated and has intent to help developers in enter into rapid application development. Actually, according to this article, now Microsoft has 67% of the market for IDEs, which is quite expressive about their huge improvement in this area.

Another topic that took my attention from this article, was about the demand for programming languages. It seems like Java is still programming language no. 1. I do know that most developer are very sensitive on this subject - all of us have been a witness if not a participant in *bloody* discussion which one is more superior Java or .NET :-) I am technology oriented so I don't take neither position in such cases - for me what is important is the technology, the programming language is just the tool for implementation. Well, I have preferences of course, but I will never get into such kind of "deadly" fight. However, I think it is positive to know what is the market demand when it comes to programming languages. Thus, every developer knowing the trends in software development in the future years, will be able to react adequately, and if needed, to start learning new technologies so that (s)he is competitive. Those of you who are interested in such kind of trends especially in programming languages, go to TIBOE page which are publishing even monthly reports on the skills demand in programming languages (here is the link).

Sunday, January 15, 2006

How hazardous are Wi-fi devices with their radiation?

Today I was reading about the radiation coming out of our cell phones - a topic that has been thoroughly discussed for a long time. I've heard a lot of stories that there is an electromagnetic radiation emerging from the headset, but nevertheless I am using my mobile without taking this that serious.

Well, I heard a similar story about Wi-Fi devices. I personally use the Wi-Fi coming with my notebook a hell of the time. Actually, I am used to hold the machine on my stomack, while I am in the bed. So normally, I got upset a little bit. I checked out the Internet for some information about how hazardous is the Wi-fi? I found this very interesting article, which shows a real lawsuit for exactly the same thing (check it out here). According to this article, it is well-known that Wi-fi's are harmful, but they are not more harmful than any other microwave that we are so used to. And even our wireless speakers and cordless phones sold everywhere are not "flowers", when it comes to radiation. Here is an excerpt from this article, which gives enough information about the case:

"
.. Wi-Fi experts argue that while wireless networks do, in fact, produce low levels of electromagnetic radiation, they emit no more than household gadgets do. If wireless networks are hazardous to your health, they say, so then is nuking a slice of pizza. Microwave ovens and many cordless phones actually operate at the same 2.4GHz frequency used by a 802.11b wireless network. Even those wireless speakers you can buy at RadioShack emit similar radiation levels. "At this point, we have no reason to believe there is any harm in wireless networks," says Wi-Fi Alliance Managing Director Frank Hanzlik.

...

In their lawsuit they assert that "responsible scientists have reported that prolonged exposure to low-intensity radio frequency radiation can break down DNA strands, cause chromosome aberrations and break down the blood-brain barrier, thereby permitting toxic proteins to invade the brain."
"

I am so used to my wireless router at home that I am 100% sure that I won't throw it away, because of this radiation. Actually, Wi-fi networks are getting more and more around us, and in general I find them really useful if not a-must. Wait a minute - do you know that Google is planning to build a Wi-fi network all across the States? Can you image in what hell of a problem they are getting into if the radiation coming out of the Wi-fi's is that hazardous? :-)

However, I guess that some sort to precaution is not bad idea, because as can be inferred from the article, it is still unknown what the damages of prolonged exposure to Wi-fi radiation to human are.

Friday, January 13, 2006

Security Development Lifecycle at Microsoft

While I was reading articles from the MSDN Magazine, I ended up on this very interesting article regarding the security development lifecycle at Microsoft: A Look Inside the Security Development Lifecycle at Microsoft (link).

It is obvious that Microsoft has made their products more robust and reliable during the last years. Face it, there is a new Internet Explorer coming out, IIS 7 is far away more secure than its predecessor, the same applies to Windows 2003 family - all of these are an obvious sign that Microsoft puts security as a very important characteristic of their products. But in order to provide it, as can be inferred form this article, there is a very solid process engaged. I personally like the idea of having a person in the team, responsible for the product security. Also, the fact that security is put into consideration early in the development process will help to build the architecture with respect to it, and afterwards, during the implementation phase, security will be a criterion for each developer.

Another thing that I read in this article and I find particularly true, is that most developers just don't know what is to write secure code. In order to mitigate the risk of security flaws, having a "security" guy on the team is going to be really very handy, because (s)he will give guidance and put attention to security issues and best practices. But after all, each developer should be knowledgeable. I am now covering the courses found at Microsoft e-Learning, courses showing the latest best practices and important flaws that every developer should be aware of. These courses are under the label "Microsoft Security Guidance Training" and they can be found here. Very interesting, very helpful and for sure after you cover these, you will have a solid base in security.

Thursday, January 05, 2006

Skype 2.0 video conference works behind firewalls

Folks,

Today I tested Skype 2.0 build 2.0.0.63 beta (download it from here) to see whether we can setup video conference, when I am behind a firewall (as it is in my case). The test was successful – Skype 2.0 allowed me to make a video conference even though I am behind a firewall.

Just to mention that I tried to do the same with MSN Messenger 7.5, but it didn’t work out.

Say *hello* to the era of free video conferencing! I find this really fascinating, and for example we will try tomorrow to setup a video conference with a prospective client. This would be a definite plus for us, because the client will not only have voice, but also visuals, which will help us build credibility easier.

Sunday, January 01, 2006

Merry Christmas and Happy New Year!

Happy New Year 2006!

I wish you all the best during the new 2006 - let you be healthy (very very important one) and let all the happiness in the world be with you. Since this is a technological blog, I wish you to buy a 2 processor monster machine to a very reasonable price, develop code with less bugs (hey, why not bug-free! :-) ), start developing for.NET platform (if not already) - at this moment I am sure that Microsoft flamers have already erased my blog from their favorites :-), but I wrote this just for fun), etc. etc. - put shortly - all the best! :-)

Cheers!