Wednesday, January 24, 2007

EXISTS vs COUNT()

COUNT may be used in SQL to check if a record exists like for an example

IF(SELECT COUNT(CUSTOMER_ID) FROM TBL_CUSTOMER WHERE CUSTOMER_ID = 100) = 0

BEGIN /*LOGIC*/ END

BUT using the keyword EXISTS gives better performance THEN COUNT()

IF EXISTS(SELECT CUSTOMER_ID FROM TBL_CUSTOMER WHERE CUSTOMER_ID = 100)

BEGIN /*LOGIC*/ END

If in case the row count is needed @@ROWCOUNT can be used and also if only the first record is needed the TOP KEYWORD can be used

SELECT TOP 1 * FROM TBL_CUSTOMER

Tuesday, January 23, 2007

One more left in the CRM Reporting team

Samith left the company yesterday, to go abroad for his MIT. The CRM Reporting team started with Hashan, Crisanth and Samith , later joined by me in the mid of September.Crisanth left  the company in October and Hashan left in December and now Samith.

Reporting was a tough module, it was the first time anyone of us has done queries on a Data warehouse via MDX, we lacked experince in this area but quickly got used to it and deliverd the module (was accepted by the clients).

Working with this team was lot of fun and experince has I learnt a lot from them.

 

 

 

Sunday, January 21, 2007

Assor's wedding

Yeaterday was a day of fun, I headed out to kandy with my collegues at Parangon (the place where I used to work prior joining Virtusa) to attend the wedding of Asoor( another collegue at Paragon).

Everyone was present except Kasun and Chaturanga. We had a great deel of fun, talking about all the nuttiest and gross things in the world. As usual Fahim got hooked to himself after I threw a joke at him and he did not change his mood for the rest of the day.  Well Assor was in a good mood, he had his lunch with us ad alos said that 2 weeks of holiday after the wedding was not much to enjoy, Fizan too called for UK and had a chance to talk with all of us.

Manjula’s secret came out as well. We had tea at Rafi’s (Paragon’s Managing director) place in kandy with a piece of cake.

Alltogether the day was owesome. Thanks to Paragon.

 

Tuesday, January 16, 2007

ASP.NEt 2.0 Viewstate and good practices

View state is one of the most important features of ASP.NET because it enables stateful programming over a stateless protocol such as HTTP. Used without strict

criteria, though, the view state can easily become a burden for pages. Since view state is packed with the page, it increases size of HTTP response and request.

Fortunately the overall size of the __VIEWSTATE hidden field (in ASP.NET 2.0) in most cases is as small as half the size of the corresponding field in ASP.NET 1.x.The content of the _VIEWSTATE field (in client side) represent the state of the page when it was last processed on the server. Although sent to the client, the view state doesn't

contain any information that should be consumed by the client.

In ASP.NET 1.x, if you disable view state of controls, some of them are unable to raise events hence control become unusable. When we bind data to a grid, server encodes and put whole grid in to view state, which will increase size of view state (proportional to the data volume of grid). We cannot disable view state, if we need features like pagination, edit, and sorting.

But in ASP.NET 2.0 view state can be disabled more freely. Because controls keep contents required for their behavior in control state. View state is purely to maintain control’s UI content. Following simple guidelines can be used to handle view state appropriately.

* Use page’s view state when data elements are required to persist between requests. E.g. ViewState("DataElement") = someDataElement

You can disable page view state by setting EnableViewState="false" in page directive of aspx.

* Do not use page’s view state to persist control’s data. Enable control’s view state, so data will be available between requests. E.g. data source of a Dropdown list

* If you populate the contents of a control (from some data source) every time a page is requested, it is generally safe (and wise) to disable view state for that control. E.g. EnableViewState="false"

(CheckBoxList, ContentPager, DetailsView, FormView, GridView, ListControl - base class for BulletedList, CheckBoxList, DropDownList, ListBox, and RadioButtonList, LoginView,

MultiView, Table, etc.. keep control state, hence view state can be disabled without affecting events.)

* If you don’t want to populate contents, you can declaratively place a data source on your page and point your control to that data source with view state enabled. Above controls exhibit intelligent use

of view state when bound to declarative data sources. So there wont be any hit to backend data source in post backs.

As a refactoring tip, disable view state at page level and check when and where it breaks. If functionality breaks, verify that you have used page view state correctly.

If you have used it properly, enable view state at page level and disable at each and every control level by considering above best practices

Thursday, January 11, 2007

Nice way to start my blog

Woo what a nice way to start the blog. Today we received the acceptance for our project from the clients.

This project was on the customer relation management domain, I was working on the data warehousing module, and after a long struggle, all went well

Hi All

Hi all,

 

This is my first post to the blog, so I don’t have much to say, but will definitely post more…

Keep visiting…