Sunday, November 26, 2006

For Itch

Before we start coding, we got an email about best practices for writing code in .NET. There was a line in the email about using ‘For’ instead of using ‘For Each’ loop (in VB .net). People have proven that ‘For’ loop is faster than (or same at max) ‘For Each’ by going unto Intermediate Language.

I don’t want to go in discussion about which one is better. Just see this and tell me which one is better to use. Isn’t it better to write simple and maintainable code than 'possibly' faster code?


'For Each
For Each str As String In BaseString.Split(" "c)
Result += SomeFunction(str)
Next

'For only
For i As Integer = 0 To BaseString.Split(" "c).Length - 1
Result += SomeFunction(BaseString.Split(" "c)(i))
Next


Saturday, November 18, 2006

How to work at same time with T-SQL Stored Procedure and Coding standards

I was having real bad time by modifying the T-SQL procedures according to our coding standards. It's because the editor which comes with SQL Sever 2005, doesn't provide auto-indent or auto-format functionality.

Another thing! Command to read stored i.e. SP_HelpText doen't read TABs (or there is a problem in my way of copy-pasting). So all my hardwork with go in vain if I don't take care about that. And the editor allows you to use TABs freely and, without mistake, it puts the tab character instead of bunch of spaces. 'Untabbify' functionality is there in the editor but I don't know why the hell it's not working everytime.

So currently, as I have to bear with this hell, I am following a new approach.

That is, first develop procedure in SQL server editor (fast for development) and then go to scintilla and format the shit. I got many problem with scintilla but all were solved when I downloaded MSI from http://gisdeveloper.tripod.com/scite.html This MSI comes with some good extensions and customized preferences. This preference are set exactly the same which I wanted (i.e. No tabs, tab size 4, font preferences etc).

So life is not so good because there is not directly 'auto-format' function, but the above approach is working until Microsoft really does something :)