Be serious with the Lord

I got quite a bit out of brother Ron's memorial service. Although there was a strong sense of loss, I am extremely glad he has finished his course and ran his race. Now he can finally rest in the Lord and pray for the Lord's coming and our overcoming.
  • be a proper person
  • have a living that can match our desire to be useful
  • turn to my spirit quickly
  • don't missing the gatherings

Generics, Casting and Anonymous Delegates and the Where clause

I have a situation where the code looks like:

( ( TextBox ) ( _someParentControl.FindControl( "_childControlId" ) ) ).Text = "SomeText";
( ( TextBox ) ( _someParentControl.FindControl( "_childControlId" ) ) ).Enabled = someBool;

repeat about 10 times with different child control type, parent controls, child Ids, and properties.
obviously, there's a similarity and refactoring was in order.

private static void ExecuteOnControl<T>( WebControl parent, string id, Action<T> action) where T : WebControl
{
    T control = parent.FindControl( id ) as T;
    if (control != null && action != null)
    {
        action( control );
    }
}


The where clause is important because you can't cast "As" within the function without having some limits on the generc T.

Which allowed me to shrink the example down to:
ExecuteOnControl<TextBox>(_parentControl, "_childControlId", delegate(TextBox tb) { tb.Text = "someText"; });

This can be further simplified since the delegate can be declared once and used later.
Action<TextBox> tbDel = delegate(TextBox tb) { tb.Text = "someText"; };
ExecuteOnControl<TextBox>(_parentControl, "_childControlId1", tbDel);
ExecuteOnControl<TextBox>(_parentControl, "_childControlId2", tbDel);


One can argue here that the new code isn't really that much more readable though, but it was good hacking

I'll see you again, brother Ron.

A small tribute to brother Ron Topsom.

On Monday (April 2th 2007) afternoon, I lost a brother and a friend.  Ron Topsom was someone that looked after me as I went through a troubled university life (I was always a good kid, but my life went upside down due to events outside of my control).  He made sure that I at least keep turning to the Lord Jesus as well as fellowshipped with me concerning many practical things regarding my personal living with Christ, my studies as a christian, and even working as a single-working believer to be a testimony at work.

In the last few years he has been ill, but it was always good to see him strengthened by the Lord and keep going on.  Sadly, he went to be with the Lord on last Monday.

I miss him already.  I wish I had more time for more fellowship.  It's such a shame, I never have enough time for everything I wanted to do.  I pray when it's my time to go to be with the Lord, I won't have the regret that I have right now.

Thank you Lord for such a pattern of a proper christian.