Posts

Showing posts from April, 2009

Treat Warnings as Errors

Tip: Treat Warnings as Errors Another neat day-one rule, along with DB sessions and ZERO error handling to ensure that your .Net code is as bug free as possible. The mantra during development has to be to break the app as much as possible, not supress errrors. Ban try-catch blocks! :) [update] The sooner you fall behind, the more time you will have to catch up "an informal slogan of the on-board shuttle group [that] captures the essence of keeping focused on the process" (Focus on breaking) "Gen-Xers sporting T-shirts and distracted looks, squeezing too much heroic code writing into too little time; rollerblades and mountain bikes tucked in corners; pizza boxes and Starbucks cups discarded in conference rooms... It's not the story of the on-board shuttle group" "How do they write the right stuff? The answer is, it's the process" "Software for Grown-Ups"

Control design and empty catch{} blocks

1. All code that is in the control should be reusable. Please don't put anything specific to your pages in the control For ex: Can gvTasks_RowDataBound, PopulateCaseGrid etc be reused by search too? 2. Three properties of _gvCases are already exposed as properties. If you need to do more manipulation of _gvCases in your pages, please expose the whole grid and remove these properties You can then directly work with the grid in your pages (this is not good design but it's better than putting custom code in the control) 3. Please avoid empty catch{} blocks at all costs! Like in gvTasks_RowDataBound This is the most common way to have the code ignore bugs and cause unpredictable, difficult-to-track behavior.

Web Forms Page Processing and Control Execution Lifecycle

I'm giving both a quick reference as well as the MSDN links to the full information here. Web Forms Page Processing ASP.NET Page Framework Initialization The page's Page_Init event is raised, and the page and control view state are restored. User Code Initialization The page's Page_Load event is raised. Validation The Validate method of any validator Web server controls is invoked to perform the control's specified validation. Event Handling If the page was called in response to a form event, the corresponding event handler in the page is called during this stage. Cleanup The Page_Unload event is called because the page has finished rendering and is ready to be discarded. Control Execution Lifecycle Initialize Load view state Process postback data Load Send postback change notifications Handle postback events Prerender Save state Render Dispose Unload

Abstract vs Sealed vs Static class

The main features of a static class are : They only contain static members. They cannot be instantiated. They are sealed. They cannot contain Instance Constructors. Basically: Static = Abstract + Sealed

Historical comparison of Sensex, Nifty and the S&P500

Yahoo provides data from 1997 for Sensex, from 2002 for Nifty and for 60 years or so for the S&P500 A simple averaging of historical closing day values of all 3 gives the following data: YearOfAvging Sensex/Snp Nifty/Snp Sensex/Nifty 2009 10.58 3.44 3.12 2008 11.50 3.64 3.23 2007 10.31 2.86 3.28 2006 8.22 2.35 3.15 2005 5.77 1.76 2.96 2004 4.69 1.49 2.90 2003 3.60 1.23 2.66 2002 3.42 1.12 2.91 2001 2.87 2000 3.15 1999 2.90 1998 2.73 1997 3.52 StdDev 3.18 0.93 0.19 Avg 5.64 2.24 3.03 StdDev/Avg 0.56 0.41 0.06 Some simple inferences from the above could be: 1. The ratio of Sensex/Nifty has changed little historically. Sensex is probably a little more optimistic and Nifty fluctuates about 15% less. 2. Sensex has gone from 2.7 times S&P500 to it's current almost 11 times. 3. Nifty has risen similarly, maybe about 1% less. On a related note: If you plot the S&P

.dbk file created by Sony Ericsson PC Suite

Problem: 1. View the contents of a .dbk file created by Sony Ericsson PC Suite 2. How do I open a dbk file? Solution: Rename the .dbk to .zip It will contain a bunch of plain text files, one of which has your contact list :)

gridview sorting without datasource

This is the first link any search on the topic yields: HOW TO: Using sorting / paging on GridView w/o a DataSourceControl DataSource For those of you scratching your heads wondering how he is able to pull the DataSource out of viewstate/thin air like that (a couple of people on that page seem to wonder too) The answer is seen in the full solution given by the same source He assigns to the DataSource in Page_Load :) In short, the way to page and sort a gridview is the same as what you've been doing for datagrids all these years if you're using your own data binding logic. I haven't yet seen a way to use GridView.SortDirection/SortExpression to do the job.

Failed to access IIS metabase

There is usually an error whenever you install IIS with .Net and try to run an ASP.net app the first time. And this error seems to change with every new version of .net and VS This seems to be the latest one. The fix has always been the same though C:\Program Files\Microsoft Visual Studio 9.0\VC>aspnet_regiis -i

laptop disable touchpad on ibm r52

Or for any other laptop: The quickest way is to install the appropriate driver from synaptics . This will install a device manager giving you full control over all pointing devices on your laptop.

Win Zipfldr.dll Alternative

ZipfldrAlt Windows provides no direct way to use zipfldr.dll for zipping or unzipping from the command line. So I've written a wrapper around ICSharpCode.SharpZipLib.Zip And I've used ILMerge so the exe contains the SharpZipLib dll too. You can zip and unzip whole folders from the command line with it; no installation required. But I haven't coded it to accept individual file(s), only an entire folder.

Excel error - too many different cell formats

Most of the solutions on the web aren't helpful excelforum groups.google "including the possiblity that if you delete a format of a cell it really does not go away" Removing all formatting won't help you and support.microsoft tells you nothing The issue is that this error is actually misleading, it's not the cell formats but the styles that are too many. What you need to do is this Delete styles collection The code for the macro is duplicated here for posterity Option Explicit 'Deletes All Styles (Except Normal) From Active Workbook Sub ClearStyles() Dim i&, Cell As Range, RangeOfStyles As Range Application.ScreenUpdating = False Application.EnableEvents = False 'Add a temporary sheet Sheets.Add before:=Sheets(1) 'List all the styles For i = 1 To ActiveWorkbook.Styles.Count [a65536].End(xlUp).Offset(1, 0) = ActiveWorkbook. _ Styles(i).Name Next Set RangeOfStyles = Range(Columns(1).Rows(2), _