Emad Al-Ashi’s Blog

February 21, 2009

www.emadashi.com my new blog space!

Filed under: Misc, Personal — eashi @ 1:54 am

Finally, I am doing it! I am becoming a big boy and taking care of my self; moving from the caring WordPress.com world to my own hosting with my own domain: www.emadashi.com

While taking this step I had many flashes ranging from “COOL, I CAN DO ALL THAT NOW!” to “OH MY GOD, WHAT AM I DOING!”; it’s hard, has lots of responsibility, and many sacrifices like simple life, and the Google ranking I will be losing since June last year.

Checking all the stats and visits brings my tears down (not really down though!). So what I am going to do is to keep my old blog (this one) so visitors can still see my old posts and I won’t loose the ranking, what do you think? should I do that? (comment if you please)

The good thing is, though, that if you are subscribed to this blog’s feed, you don’t have to change anything; It will happen automatically and you will still get the new posts (you might get the old posts again once more when I take that step).

So anyway, I hope this step to be a new era for better life, all hope.

February 19, 2009

Google Is Moving Feedburners’ Servers

Filed under: Misc — eashi @ 7:17 pm

As the title tells, Google is moving the Feedburner servers, and my RSS feed URL has changed now to http://feeds2.feedburner.com/eashi

Google “promised” to keep the old feeds working for a while, so anyone who has subscribed to this blog will not be affected “for a while”; so if you want to stay up to date with the proper feed URL of this blog (and I hope you do :) ), please change the feed url to http://feeds2.feedburner.com/eashi.

Thank you all  for your continuous attention :)

February 7, 2009

Beware of Static Constructors

Filed under: Bunian, Development — Tags: , , — eashi @ 12:39 am

In Bunian we needed to use a static constructor for some reason, it was all going good; we tested the code and it ran smoothly…excellent (Code Coverage anyone?!).
But when I came across this situation, it appeared that the static constructor wasn’t invoked!even when “Class.Method();” is called! so lets examine it.

I have two simple classes as an Example:

public class Parent

{

    public static string DoSomething()

    {

        return “Parent: DoSomething() called”;

    }

}

public class Child : Parent

{

    static Child()

    {

        Console.WriteLine(“Child Static constructor called”);

    }

 

    public static string DoSomethingDifferent()

    {

        return “DoSomethingDifferent() called”;

    }

}

As it may be obvious, Child inherits from Parent, Child has a static constructor that we need to be executed when ever a method is invoked by Child. Now lets check the main program executing these two lines:

Console.WriteLine(Child.DoSomething()); //This code will NOT invoke the static constructor

Console.WriteLine(Child.DoSomethingDifferent());//This code WILL invoke the static constructor

The surprise (at least to me) when calling “Child.DoSomething()” the static constructor isn’t invoked! because it is in the parent!! aaaaaah! bad!! that was serious for our architecture  and we had to do lots of fixes to turns things around the right way (which I think it was for our own good for other reasons :P )

This brings up the Code Coverage topic as well; in our case that static constructor’s job was to create an instance of a member that is only needed once, and we check on it in other times by “if _instance != null”. It always ran ok because all the test code we created used to call an original Child before calling any other method that resided in the Parent.

bottom line: be ware of static constructors, and check your test code…it maybe hiding “surprises” for you ;)

Blog at WordPress.com.