Geeks With Blogs

News

Series

Add to Technorati Favorites


An Archived Managed World This blog has moved to http://www.managed-world.com/blog

Well, I've been inspired a little lately. Although I admit it is rare, I thought I would let you all know this just in case you were thinking that how inspired a person is is actually inversly proportional to how much the person weighs. Having been inspired by Rory's “What If They Were Coders” comic series, and some of the examples of “what's wrong with this code” floating around, I decided to start a series of my own. It is called “Defined By Code”. What I will try to do is boil down a certain person to their “definition” and essentially write that person in code.

If it turns out well, and you enjoy it, let me know and I will keep them coming. If you don't like it and you feel that I should be prison-blanket-partied by a group of fanatical FCC whackos, well, then, go to Sokar (you might get your way though and I might stop taking the time to write these)!!!! So, without further ado, I present the first (in a hopefully long list of many) “Defined By Code” - Britney Spears Edition (and believe it or not, they are all compilable and runnable within VS.NET 2003 as Console Applications (I have to write the code somewhere and where better than my IDE, that's WHY!!).....

class DefinedByCode
{
    [STAThread]
    static void Main(string[] args)
    {
        BritneySpears britney = new BritneySpears();
        britney.Action();

        Console.ReadLine();
    }
}

class Person
{
    private BehaviorActionCallback _actionCallback;
    public BehaviorActionCallback ActionCallback
    {
        get { return _actionCallback; }
        set { _actionCallback = value; }
    }

    public virtual void Action()
    {
        if (_actionCallback != null)
            _actionCallback();
    }
}

delegate void BehaviorActionCallback();
interface IBehavior
{
    void Action();
}

class BritneySpears : Person
{
    private BehaviorActionCallback _realActionCallback;

    public BritneySpears()
    {
        this.ActionCallback = new BehaviorActionCallback(this.GoodGirl);
        _realActionCallback = new BehaviorActionCallback(this.BadGirl);
    }

    public override void Action()
    {
        base.Action();

        if (_realActionCallback != null)
            _realActionCallback();
    }

    public void GoodGirl()
    {
        Console.WriteLine("Hello, my name is Britney Spears.");
        Console.WriteLine("I am a really good, puritan girl.");
        Console.WriteLine("I've never even kissed a boy.");
        Console.WriteLine("Boys are icky, icky, creatures!");
    }

    public void BadGirl()
    {
        Console.WriteLine("\n<InnerThoughts>");
        Console.WriteLine("Good girl, my butt!");
        Console.WriteLine("I'm a slut and nobody knows");
        Console.WriteLine("You're cute, maybe I should invite you home with me?");
        Console.WriteLine("</InnerThoughts>");
    }
}

Disclaimer: If Britney Spears happens to read this, I would like to take this opportunity to explain myself:

Dear Britney,

     I apologize and admit that this was a sick joke that I shouldn't pull on any human being. If it makes you feel better, I am fat. Not only am I fat, but I am ugly. My looks don't compare to yours. If for some reason this doesn't make you feel better, just remember that you are famous and I am not. Please take pitty on me and don't smite me with your pop-star powers. I humbly beg for your forgiveness.

Sincerely,

Jason Olson

 

Now, move along.....

Posted on Friday, March 19, 2004 1:43 PM | Back to top


Comments on this post: Defined By Code

# re: Defined By Code
Requesting Gravatar...
I liked the apology letter better then the code it self, wow I just dropped down the chair reading it. Waiting for more wit master...
Left by Rai Umair on Mar 19, 2004 5:19 PM

# re: Defined By Code
Requesting Gravatar...
"don't smite me with your pop-star powers"

haha
Left by Dave on Mar 20, 2004 10:23 PM

# re: Defined By Code
Requesting Gravatar...
Amazing , Hilarious...Please do keep continuing this series
Left by gangadhar on Mar 24, 2004 5:44 AM

# re: Defined By Code
Requesting Gravatar...
What if I want you to be "...prison-blanket-partied by a group of fanatical FCC whackos..." but I still liked it?

You've put me in a difficult position.
Left by Rich C on Mar 26, 2004 10:09 PM

Your comment:
 (will show your gravatar)


Copyright © Jason Olson | Powered by: GeeksWithBlogs.net