September 2008 Entries

Castle ActiveRecord with multiple databases

A few months ago, I came cross this problem that I had 2 databases in my project, so that my model classes might map to tables from different databases. It took me a while to work out how to deal with it in ActiveRecord. Today, I had a same problem again, even though I still got my last project’s source code, it still took me a couple of hours to get everything right. So, I think I’d better to write it done, just in case that I will have to do it again or anyone else may need it. The Scenario: Database ......

Posted On Sunday, September 21, 2008 7:07 AM | Comments (5)

Debug into .Net Framework Source Code

I was writing some WPF testing code today. It was extremely simple code which just programmatically creates a Rectangle and adds it to a canvas. The code this something like this: Rectangle rectangle = new Rectangle { Fill = new SolidColorBrush(Colors.Blue), Stroke = new SolidColorBrush(Colors.Blue), Width = 150, Height = 120 }; rectangle.SetValue(Canvas.L... 100); rectangle.SetValue(Canvas.T... 100); canvas.Children.Add(rectang... However, I got an exception on rectangle.SetValue(Canvas.L... ......

Posted On Thursday, September 11, 2008 6:53 AM | Comments (1)

Thoughts on programming language and maintainability

Recently, I have been working on maintaining two “legacy” systems. One is in VB6, implemented by a person who was not a programmer, but only trained a few weeks for VB6. The code quality is extremely poor. There are even no indentations in the code, and all variables are not properly named, for example, if there are 5 text boxes on a form, they will be just named as Text1(0), Text1(1)…Text(4). So, I guess I don’t have to say too much and you get a picture of what it looks like. Another system is ......

Posted On Wednesday, September 10, 2008 7:25 AM | Comments (4)

Turn off Resharper’s suggestion of using implicitly typed locals

If you use resharper with Visual Studio 2008, you may have noticed that it keeps suggesting you use implicitly typed local variable declaration i.e. the var keyword. To me, it is a bit annoying. You can actually find why people think it should exist in the first place: There are some valid points, but I am not convinced. I think it is less readable in most of the case. I can’t agree with Ilya that it induces better naming ......

Posted On Monday, September 8, 2008 6:24 AM | Comments (15)

How to get a CheckBox in a Winforms DataGridView to react to the first click

I had this problem today. It looks very simple, but actually took me a while to find a solution. The problem is: I have a Winforms DataGridView, and its first column is an unbound CheckBox column which is used to select/unselect a row. I want to hook up the check/uncheck event so that I can execute some logic after a row is selected or unselected. As this is Winforms, there is no way I can hook up an event from a control’s child element. But, it is quite obvious that we can hook up DataGridView’s ......

Posted On Sunday, September 7, 2008 8:29 PM | Comments (17)

Copyright © Changhong Fu

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski