Wednesday, April 15, 2009

Boolean is difficult

Sometimes you see the C# code like this:

if(isValid()) {
return true;
}
else {
return false;
}

or even "better":

return (isValid()? true : false);

I always wondered why not just write the code like this:

return isValid()

Is the reason is that some of the younger developers don't have any background in C, C++ or any languages where the conditional statements return int, not bool? It is psychologically difficult for them to accept Boolean as the first class citizen - data type. For them Boolean cannot be separated from the if statements or "?" operator. Am I correct? What is your opinion?

Tuesday, April 14, 2009

JavaFx installation

Oddly enough it did not prompt me to download and install JavaFx, it just showed me the small icon. When I clicked on the icon it prompted me to download the latest Java, and after 6 minutes (on high-speed connection) and two browser restarts I've got it up and running.

Monday, April 06, 2009

Fixing Outlook annoyancies

If a message comes as plain text, Outlook will use plain text format to reply to this message. As a result the signature gets messed up, etc. This article shows how to overcome this limitations. A simple macro can convert a received email from plain text to html:

Sub ConvertMessage()
Dim oMailItem As MailItem
Set oMailItem = Application.ActiveExplorer.Selection.Item(1)
oMailItem.BodyFormat = olFormatHTML
'oMailItem.HTMLBody = oMailItem.Body
oMailItem.Close (olSave)
Set oMailItem = Nothing
End Sub

I commented out one of the lines because it works better for me this way.

Tuesday, March 31, 2009

Anger-driven development

Being angry at the badly written code stimulated me to a few hours of very productive refactoring and bug fixing. Do I need to get angry to be productive?

Monday, March 16, 2009

IOC container

I found a great idea in Dave Laribee's article in MSDN Vol 24 # 2: Don't use IOC containers for entities, only for services. I am saying this becase our team is practicing this for the last year or so.

Monday, December 08, 2008

Silverlight instead of JavaScript?

I would not recommend anyone to use Silverlight instead of JavaScript, because of low tolerance of the former to browser differences. Besides, why would you trade your almost strongly typed JavaScript to weakly typed Silverlight syntax like:

HtmlElement label1 = HtmlPage.Document.GetElementById("Label1");
label1.SetProperty("innerHTML", "Dino");
However there is one scenario that could provide a good case for using Silverlight in place of JavaScript, as described here: http://msdn.microsoft.com/en-us/magazine/dd148642.aspx . Look at this piece of code:

HtmlElement button1;
button1 = HtmlPage.Document.GetElementById("Button1");
button1.AttachEvent("click", new System.EventHandler(Button1_Click));
You can attach a managed event handler to an HTML button!

Tuesday, August 12, 2008

How to fail the build if unit tests fail.

I just realized that the way TFS is architected is that it will mark the tests "Partially Succeeded" if the unit tests fail. This does not agree with out development process. Our development process prescribes that the build should fail if any of the unit tests fail. One way to deal with this problem is to edit C:\Program Files\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets and set ContinueOnError to false.

Another way of dealing with this was suggested in the blog entry http://blogs.msdn.com/aaronhallberg/archive/2007/11/05/how-to-fail-a-build-when-tests-fail.aspx

I modified the code suggested there to make sure also that the files are not copied to the drop location if the unit tests fail.


<Target Name="AfterTest">


<!-- Refresh the build properties. -->


<GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"


BuildUri="$(BuildUri)"


Condition=" '$(IsDesktopBuild)' != 'true' ">


<Output TaskParameter="TestSuccess" PropertyName="TestSuccess" />


</GetBuildProperties>


<!-- Set CompilationStatus to Failed if TestSuccess is false. -->


<SetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"


BuildUri="$(BuildUri)"


CompilationStatus="Failed"


Condition=" '$(IsDesktopBuild)' != 'true' and '$(TestSuccess)' != 'true' "/>


<SetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"


BuildUri="$(BuildUri)"


SkipDropBuild="true"


Condition=" '$(IsDesktopBuild)' != 'true' and '$(TestSuccess)' != 'true' "/>


</Target>

Thursday, July 17, 2008

Mock object framework makes refactoring difficult

Probably unintended consequence of using a mock object framework is that it makes refactoring somewhat difficult if the method signature changes, or if methods are split/combined or rearranged to different interfaces. Sometimes I am having really hard time in getting the test back to the working condition, and often don't know why I need to do what I have to do to get it fixed.

Tuesday, July 15, 2008

FxCop rigidness

What drives me really crazy in FxCop is that I cannot easily change the MessageLevel of the built-in rules. The XML file describing rules is compiled into the rule assemblies as an embedded resource, so the only option for me is to create a new rule assembly, copy the XML file, exclude the old rule and include the new rule. I'd rather change the MessageLevel using FxCop project files.

Monday, July 14, 2008

Misfeature of FxCop 1.36

When upgraded to version 1.36 I started getting the messages "Strong name doesn't match the reference", or "Could not resolve member reference".

The solution can be found here. What worked for me is setting AssemblyReferenceResolveMode to None.

Friday, July 11, 2008

Problem with CollabNet SVN 1.5

When I upgraded I started getting messages like this:

Failed to load module for FS type 'bdb'

Apparently bdb module is not working (or maybe they forgot to include it?) in the CollabNet distribution. I had to use the old binaries to migrate the repositories from bdb to fsfs like this:

svnadmin create NEW_REPOSITORY
svnadmin dump OLD_REPOSITORY | svnadmin load NEW_REPOSITORY

where NEW_REPOSITORY is the file path to the new fsfs repository and OLD_REPOSITORY is the file path to the old bdb repository.

Sunday, July 06, 2008

BizTalk services let you expose stuff on internal network?

See http://msdn.microsoft.com/en-us/magazine/cc546613.aspx. Using RelayedHttp you can expose the web service on your internal network to the internet. But I wonder how this thing work? Is the service polling the BizTalk services all the time to check if there is any request?

Monday, May 19, 2008

Process owner

Some people own the process they are using, the others are owned by the process. It is especially sad when the people who invented the process in the first place start being owned by it.

Monday, May 12, 2008

QTP license blues

After a few times when QTP refused to find a license server I finally found a solution: in Windows firewall you need to open UDP port 5093.

Tuesday, May 06, 2008

Evangelists

There are so many Microsoft evangelists now, so I started wondering if there is also a Microsoft seminary.

Monday, April 28, 2008

AquaLogic® BPM

AquaLogic® BPM seems to be way more advanced workflow engine than Microsoft WF. In particular it is designed to work for human workflow, which Microsoft WF is not.

Typemock

If you have $450 per developer to spare consider buying TypeMock Isolator. It is especially useful when writing unit tests for a legacy system that is not well-designed. It is interesting to see how you can make sense of the spaghetti code by mocking everything: public methods, private methods, etc. Of course before that you should get ReSharper for much cheaper...

Wednesday, April 16, 2008

How to avoid session expiration

http://www.codinghorror.com/blog/archives/001100.html

Create a background JavaScript process in the browser that sends regular heartbeats to the server. Regenerate a new cookie with timed expiration, say, every 5 or 10 minutes.

Monday, April 14, 2008

VS2008

How is Visual Studio 2008 improving developer's productivity if it is twice slower than Visual Studio 2005?

Monday, April 07, 2008

VS2008 web projects

I was so happy when in VS2005 the web projects did not require any virtual directory to be set up. This allowed me to be working on multiple branches of the same web applications. In VS2008 we are back to the old stuff of requiring that the physical directory should match the virtual directory specified in the project file. WHY? This thing does not make any sense to me!