Bug Vanquisher

8 December 2007

Real News

Filed under: Fun, Windows Vista — Tanveer Badar @ 4:02 PM

image

Guess what! I kept wondering why Windows XP suddenly started displaying all windows with AERO borders. :)

Yahoo Messenger For Windows Vista

Filed under: Fun, WPF — Tanveer Badar @ 2:45 PM

Or is it just that?

If you have netfx 3.0 (or greater) installed on, you do not need Windows Vista to run it. Here is proof:

image

The other window is irrelevant apart from the fact that it really is Windows XP. The only thing missing from Yahoo Messenger (for WPF) is that it sticks "For Windows Vista" everywhere while it is entirely capable of running on any system having the required runtime.

6 December 2007

Read One, Get One Free

Filed under: Funnier — Tanveer Badar @ 12:59 AM

image 

image

These two just inned from Microsoft, upon registering my express editions of VCS and VC++, but not in readable format.

2 December 2007

Every Problem in Software can be Solved with Another Layer of Indirection

Filed under: C++ — Tanveer Badar @ 11:26 PM

How true! I keep rediscovering this fact over and over again.

As an example, consider the problem of virtual function invocation during object construction and destruction in C++. A virtual function resolves to the type of running constructor/destructor even if it has been overridden in derived classes. Apparently, C# and Java do not suffer from this particular ailment because their object type is always the most derived during constructions. Sadly they do not have destructors and have much worse problems than not being able to call proper virtual functions.

This limitation (actually a very good thing) stems from the fact that a constructor set vtable in the object to only its current type as it does not know what further derives from that type. Similarly, a destructor sets vtable to point to implementations in the current type because derived class sub-object has been destroyed by the time destructor for a base class runs.

Aside from this minor annoyance, it is part of a larger problem too. Pure virtual function calls fail during construction/destruction.

Therefore, how to overcome this particular obstacle. A very simple case is performing parameter validation in constructor. This cannot possible depend on state information as there is none at the moment.

The workaround is just around the corner. Introduce a parallel class hierarchy that performs validation, for the hierarchy under consideration acts as factories and pass a base class reference/pointer in constructors. Even passing state is possible through references and pointer or directly by copying if the object is copy-constructible.

Some code is in order here.

struct base
{
    base( int param )
    {
        validate( param );
    }

    virtual void validate( int value )
    {
        if( value < 0 )
            throw invalid_argument( "value cannot be less than zero." );
    }
};

struct derived : public base
{
    derived( int param ) 
        : base( param )
    {
    }

    void validate( int value )
    {
        base::validate( value );
        if( value > 5 )
            throw invalid_argument( "value cannot be greater than five." );
    }
};

This problem with this code derived( 10 ) passes validation because derived::validate is never called.

With the validation code moved to parallel class hierarchy we avoid this problem because those objects have already passed their construction phase.

struct basevalidator
{
    virtual void validate( int value )
    {
        if( value < 0 )
            throw invalid_argument( "value cannot be less than zero." );
    }
};

struct derivedvalidator : public basevalidator
{
    void validate( int value )
    {
        base::validate( value );
        if( value > 5 )
            throw invalid_argument( "value cannot be greater than five." );
    }
};

struct base
{
    base( int param )
    { 
        basevalidator( ).validate( param );
    } 

protected:
    base( int param , const basevalidator& validator )
    {
        validator.validate( param );
    }
};

struct derived : public base

    derived( int param ) 
        : base( param , derivedvaliator( ) )
    {
    }
};

1 December 2007

But Then, What Is "My" Culture Exactly?

Filed under: Rant vs Vent — Tanveer Badar @ 7:50 PM

A few days back, I posted what’s not my culture. Right after that post, the next day when I was going to office, I noticed something else about the bus I was sitting in which culminated in this post.

Writing all this stuff is clearly going to make my blog hit high in some nasty search-engine terms :(. But, that concerns me not, because someone should say something before it is too late.

There was a sentence written on the back of the seat in front of my that made me think all that day what is our culture turning into? The sentence was:

               "Put your hand in my pocket and touch my rocket".

Clearly, an indication of psychological disorder we call "homo-sexuality" definitely not allowed in eastern culture.

And that’s just one thing we are embracing. Over the years, that sort of behavior has firmly developed in our police and armed forces. Police specializes in being aboriginal "pedophiles". Homosexuality is common in military training institutes. And not just homosexuality, you will find drunk sailors, officers, some kind of wife-swap (even if there is no wife!) in them.

Police forces are almost entirely from Punjab and a minor fraction from interior Sindh and NWFP. Same can be said about armed forces. The problem is three fold. You can expect anything from a person coming from Punjab because generally the ethical background is "anything goes", "do it as long as you are not caught, if caught offer to others too". Men coming from interior Sindh are truly tribal beasts with no education and sympathy. Those from NWFP have women as a banned item in that far, isolated society built around stupid rules and as a result, a guy has to vent off all that piled up desire of "ooh, aah, ouch".

Additionally, over the years, I have witnessed one or two such cases per year while traveling on the bus, take any route, no restriction there! Even the beggars are riding the band wagon. There was one I saw back in June offering glimpses in return for money.

We are also very good at all other whole host of stuff no one would call the chores of a healthy society.

  • We regularly rob (again, local police a big factor), snatch mobiles and personal belongings on the street.
  • Our media may as well start broadcasting rated movies than the programs they show with women half naked.
  • The film industry is rotten right through the bottom with bitches from all over the country joining in as glamour girls. Although, I don’t think there is any need of a film industry in the first place.
  • Our education is a discovery from past and ported back to future.
  • We are not faithful to our employers in our offices and violate any rule or guideline if it hinders our personal satisfaction.
  • Political system is a laughing stock for rest of the world.

« Newer Posts

Blog at WordPress.com.