Thursday, November 11, 2010

Disabling Ctrl + Enter in Outlook

I appreciate the Ctrl + Enter keystroke in Visual Studio, it inserts a line above the one you are currently at and puts a cursor there. I got used to is so much, that I tend to use it out of Visual Studio even. I am afraid I have managed to send a good deal of unfinished emails like that from Outlook.

Finally, I have found a cure. There is an option to disable Ctrl + Enter keystroke in Outlook: ToolsOptions...E-mail Options...Advanced E-mail Options... → clear a tick at "Press CTRL+ENTER to send messages".

Tuesday, July 27, 2010

Duplicated Page Parameters

I have just wondered what will happen if you set a page parameter twice. It does not seem to be explicitly documented in MSDN (I have not been particularly thorough in my searching), so I have just tried.

Having http://server/page.aspx?myparam=1&myparam=2, it is
"1,2"
that you receive from HttpContext.Current.Request.QueryString["myparam"].

The order seems to be kept, that is you obtain
"2,1"
having request http://server/page.aspx?myparam=2&myparam=1.

Tuesday, May 4, 2010

On "newly added" comments

I have just seen an enumeration modified. Some new items have been added there. The developer, probably taught to comment his code, added //newly added comments next to each new item. I guess he is very satisfied about the cleanness of his work.

I can imagine three possible scenarios.

First, no one will ever touch those comments. As a result, the items will remain //newly added for anyone reading the file, no matter the date.

Second, after some time, these comments will be deleted.

Third, and perhaps most in line with "comment your code" imperative, the developer will once change his comments to something like //not recently added and finally to //added ages ago.

What is the purpose of these comments? They are valid for some limited time. Then they just cause some confusion and/or maintenance burden.

If your code repository provides versioning, and our does indeed, anyone can reliably see what was changed in files. There is no need to manually list the changes anymore.

Monday, April 19, 2010

Why comments are evil

Comments usually are not maintained and sooner or later become confusing rather than helpful.

Recently, I have experienced another proof that comments are evil. I needed to examine usages of an identifier (web control name), that could be used both in C# code and in ASPX markup. Thus I needed to use "Find in files", i.e. text searching. There were found 51 occurrences, of which only 4 were not commented out. 47 occurrences were just slowing me down.

I wish there was an option "skip comments" in "Find in files" dialog box.

I wish people preferred deleting stuff to commenting it out.

Friday, April 2, 2010

Troubled Agile Adoption

Adoption of agile software development fails often. It has been written much on why does it happen. Recently, Cyndi Mitchell from ThoughtWorks Studios published an article named The half-agile path leads nowhere. I also liked the reaction of Steve Moyer, saying that Scrum is easy and XP is hard.

Scrum is rather easy. That is why companies tend to apply Scrum when they want to be agile. And they all want to be agile nowadays, don't they?

So what is the problem? James Shore wrote some year ago about The Decline and Fall of Agile, and he pointed out that it is how Scrum is applied that is bringing the disappointment. He even managed to put a reason -- people tend to say agile when in fact they mean sprints and daily meetings, that is to say processes and tools that Scrum offers.

And that is unsatisfactory, of course. They do not value Individuals and interactions over processes and tools!

I believe it is Manifesto for Agile Software Development that should guide you in becoming agile. Any processes and tools, although valuable, are secondary.

Sunday, March 21, 2010

Verbatim

Recently, we have discussed verbatim programs with my colleagues. Verbatim program prints itself on the output. I know that we did such a thing at the university in Pascal, but I could remember little of it. Thus I have decided to create one from scratch, although in C#. It took me some time to find a proper quotes escaping, that was the most difficult part of the program I would say. Still it is nice to see that even tough looking problems (initially) may have relatively easy solutions to be reached in a few minutes.

Here comes the source, perhaps not the best of its kind, but working fine.


using System;

namespace Verbatim
{
class Program
{
static void Main(string[] args)
{
const string ap = "\"";
const string s =
@"using System;

namespace Verbatim
{{
class Program
{{
static void Main(string[] args)
{{
const string ap = {1}\{1}{1};
const string s =
@{1}{0}{1};
Console.WriteLine(s, s, ap);
}}
}}
}}";
Console.WriteLine(s, s, ap);
}
}
}

Thursday, January 28, 2010

Long file names and paths

It was somewhat difficult for me to realize the file name length restriction in Windows. Finally I got it: The file name can only have the length such that the resulting full path will not exceed 260 characters.

E.g.: In C:\SomeDir\ you can create a file with 248 characters in name (including the extension), while in C:\SomeDir\SubDir\ you can use only 241 characters for a file name.

However, file systems used in Windows can handle paths up to 32,760 Unicode characters with each path component no more than 255 characters[1] It is possible to work with such long paths (i.e. exceeding 260 characters) in Windows, although there are some drawbacks. The best I have found regarding this topic is on BCL Team Blog.

Note: If you assign a drive letter to some folder, then working on that "drive", the full path will not contain the original folder anymore. Thus you can create a file, that you cannot work with properly in the original folder (the resulting path too lengthy), but still can be fully accessed on the "drive".

E.g.: Having mapped \\server\some_long_directory_structure\ to a virtual Z: drive, you can create and fully use a file Z:\some_file_with_long_name. However, that file may be difficult to work with when accessed as \\server\some_long_directory_structure\some_file_with_long_name.

Friday, January 15, 2010

TDD Kata

I did Roy Osherove's TDD Kata. It was refreshing and fun. When it came to step 8, my learning was stimulated, too. Well done, Roy!

I even plan to try this when doing pair programming again. I think such an exercise may help the pair to acclimatize.

I wish there was some "TDD Kata of the Day" page...