Monday, July 10, 2006

Null Coalescing Operator in C# 2.0

Today while going through David Hayden's blog I found this "??" Null Coalescing Operator in C# 2.0.

This operator (null coalescing operator) is new in C# 2.0. The null coalescing operator provides inherent null-checking capabilities. The result of the expression is based on whether the first operand is null. If the first operand is not null, it is the result of the expression, otherwise, the result falls to the second operand. In other words, return the first value if not null, otherwise the second.

a ?? b is equivalent to a != null ? a : b.

To show an example of this operator. I created a new C# windows application wrote below code for Form_Load.

private void Form1_Load(object sender, EventArgs e)
{
int? a = null, b = 1;
int? x = a ?? b;
MessageBox.Show(x.ToString()); // x = 1
}

A couple of links on this are: Fritz Onion's blog and Oliver Sturm's blog .

Wednesday, June 28, 2006

.NET Framework 3.0

WinFX is Now the .NET Framework 3.0

S. Somasegar describes the decision to rename WinFX to the .NET Framework 3.0. The comments and questions on this blog are interesting. Why does microsoft always comes up with some name and then changes that and I agree with Wasim Sadiq on Microsoft screwing up cool names.

Now one more question is .NET 3.0 = 2.0 ? It seems like taking existing .NET Framework 2.0 and adding WPF (Windows Presentation Foundation), WCF ( Windows Communication Foundation), WF (Windows Workflow Foundation) and WCS (Windows CardSpace) and calling it .NET Framework 3.0.

Monday, June 12, 2006

Unit Testing with VSTS

I attended the MS Tech-Ed session on Unit Testing with Visual Studio Team System last friday. Unit testing .NET code is not something new. Developers have been doing unit testing of .NET code since .NET is out. To name a few .NET unit testing tools are :
1.NUnit
2.MbUnit
3.TestDriven.Net

With VSTS microsoft has integrated not only unit testing framework with .NET IDE but has added supports to other testing, such as functional and load testing. Code coverage and Static Code analysis tool (FxCop) are other tools which are available with VSTS.

There has been already a lot of talk about the pricing for VSTS and different flavours of Visual studio 2005. Professional version doesnot have any of the above mentioned tools, while VSTS for developers (VSTD) has unit testing, FxCop and Code Coverage but functional (web testing) and load testing tools are not available with this. To get functional (web) testing tool and load testing tool you will have to buy Visual Studio team suite or VSTS for testers.

Unit testing tool available with VSTS is very similar to NUnit with added features like you can right click on your method/class and create unit test. It will create a unit test and test project for you. You can go ahead and modify the unit test by setting proper values etc. Other features of this unit testing framework are that you can make your test data driven and can see the coverage of your tests using code coverage.

The thing I like about this unit testing framework integrated with .NET IDE is that I can use my unit tests for load testing and as well as for my subsiquent build verification tests. Since this unit tests are nothing but similar .NET projects I can store them in source safe and can have different versions of my unit tests.

Here is a good article on MSDN on unit testing walkthrough with visual studio team test .

Tuesday, May 30, 2006

BarCampPune coming up on 17th June...

BarCamp is an ad-hoc un-conference born from the desire for people to share and learn in an open environment.

After the success of BarCamp at BarCampBangalore and BarCampMumbai it is coming to BarCamppune and I think it is going to be a greater success here. I am looking forward to this event and it is going to be a great fun.

Tuesday, May 23, 2006

Some useful articles on .NET 2.0

1. Comparing Strings in .NET 2.0

Sometimes the seemingly simplest things turn out to be the most difficult. For example, one would think that comparing strings in a program would be simple. It turns out that things can get ugly very quickly, and prior to .NET 2.0 there wasn’t a foolproof way to eliminate the problem.

Here is a good article on Comparing Strings in .NET 2.0 . This article very well describes how to compare culture-invariant strings: strings that must compare identically regardless of the culture. This article takes the well known the "Turkish I" problem to explain how to Compare Culture-Invariant Strings in .NET 2.0.

2. New Memory Management Functions in .NET 2.0

This article talks about the new memory management functions in .NET 2.0. Several new memory management facilities have been added to .NET 2.0 to have more control on garbage collector and ability to check for sufficient memory. This article also talks about new garbage collector functionality.

3. Playing Sounds with .NET 2.0

The .NET 2.0 Framework Class Library includes a new class in the System.Media namespace, called SoundPlayer. SoundPlayer provides a simple interface for loading and playing a .wav file. This is a much nicer and more robust interface than the PlaySound interface that programmers used in previous versions and is described in Playing Simple Sounds.


4. NET Delegates: A C# Bedtime Story

A nice and good article on delegates in .NET 2.0. C# Bedtime story modified for 2.0.

5. Guidelines for Test-Driven Development

Find out how to incorporate Visual Studio Team System into test-driven development practices emphasized in Agile development methodologies.

Friday, May 19, 2006

What is the Maximum Page Size in SQL Server 2000?

I have always read and also told others that 8060 is the maximum page size in SQL server 2000. Earliear when I had came accross this error "The total row size for table exceeds the maximum number of bytes per row (8060). Rows that exceed the maximum number of bytes will not be added." even if the row size in my create table script was slightly less than 8060, I used to think that SQL server requires some sapce for its overheads to store header etc. information.

Recently I came across this article What is the Maximum Page Size in SQL Server 2000? by Steve Jones. This article explains in detail where and how much space SQL server requires and also that maximum possible row size is in fact 8039.

Tuesday, March 28, 2006

Second Generation Agile Software Development

Time to market constraints is pushing the development community to respond faster. Constant pressures to get things done faster are forcing us towards light weight and faster software development processes.

The field of software development is never shy of introducing new methodologies. While no agreement on what the concept of agile refers to exists, it has generated a lot of interest. The introduction of extreme programming method known as XP has been widely acknowledged as the starting point of various agile software development approaches.

Randy Miller, on MSF for Agile Software Development, has a post that examines the next generation of agile software development. He talks about "new" XP as second generation agile software development. He also talks about the “Chinese menu” approach to creating own second generation agile processes.

MSF for Agile Software Development Process Guidance is a scenario-driven, context-based, agile software development process that utilizes many of the ideas embodied in Team System.

These are two sites dedicated to agile software development Manifesto for Agile Software Development and Agile Alliance .

Friday, March 10, 2006

Practical Tips For Boosting The Performance Of Windows Forms Apps

Practical Tips For Boosting The Performance Of Windows Forms Apps

This is a very good article on MSDN regarding performance of Windows Forms Applications. This article talks about:
1. Improving application startup time
2. Tuning up control creation and population
3. Improving painting performance
4. Rendering text and images
5. Efficient resource management

Tuesday, February 21, 2006

ASP.NET Best Practices for High Performance Applications

This is a very good article on codeproject on ASP.NET best practices for high performance. This article explains following points:

1. Plan and research before you develop
2. String concatenation
3. Avoid round trips to the server
4. Save viewstate only when necessary
5. Use of session variables carefully
6. Use Server.Transfer
7. Use server controls when appropriate and avoid creating deeply nested controls
8. Choose the data viewing control appropriate for your solution
9. Optimize code and exception handling
10. Use a DataReader for fast and efficient data binding
11. Use paging efficiently
12. Explicitly Dispose or Close all the resources
13. Disable tracing and debugging
14. Precompiling pages and disabling AutoEventWireup
15. Use of stored procedures and indexes

Click here for the article.

ASP.NET 2.0 Page LifeCycle

This chart was created by Leon Andrianarivony.


Tuesday, January 31, 2006

Static constructors in C#

Some important point regarding static constructor in C# are :

1) The static constructor for a class executes before any instance of the class is created.
2) The static constructor for a class executes before any of the static members for the class are referenced.
3) The static constructor for a class executes after the static field initializers (if any) for the class.
4) The static constructor for a class executes at most one time during a single program instantiation
5) A static constructor does not take access modifiers or have parameters.
6) A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.
7) A static constructor cannot be called directly.
8) The user has no control on when the static constructor is executed in the program.
9) A typical use of static constructors is when the class is using a log file and the constructor is used to write entries to this file.

Refrences:
1. c-sharpcorner
2. C# Language Specification
3. C# Programmer's Reference