Bug Vanquisher

29 November 2008

It Bit You In The Butt

Filed under: Bugz — Tanveer Badar @ 3:20 AM

new Guid( )

Fact 1: Guid is a value type.
Fact 2: Values types are initialized to all zero upon construction.
Fact 3: Value types cannot have default constructors.
Conclusion 1: new Guid( ) should earn you lots of spanking.
Conclusion 2: Guid.NewGuid( ) is the right thing to do.

22 November 2008

Happy Birthday Windows

Filed under: Fun — Tanveer Badar @ 2:28 AM

.

25 October 2008

C++: Another Love Story

Filed under: C++ — Tanveer Badar @ 1:21 AM

After many moons, the story is like this:

Given,

    int array [ 12 ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 };

The sequence of function calls

    // reflexive returns true, is_prime is true for primes (hard-coded for now) and is_even returns true for even numbers.
    abc = query::as_query( abc ).where( reflexive( ) ).where( is_prime( ) ).where( is_even( ) ).to_array( );

    for( int i = 0 ; i < abc.size( ) ; ++i )
        std::cout << abc [ i ] << ‘ ‘;

prints 2. Btw, there was a serious bug in the implementation of where( ) which is fixed now.

Additionally,
>    Query.exe!query::queryable<
                            query::filter_iterator<
                                query::filter_iterator<
                                    std::_Vector_iterator<int,std::allocator<int> >,
                                                        reflexive>,
                            is_prime> >::
                    where<is_even>(const is_even & fn={…})  Line 240    C++

This should prove delayed execution I believe. Now, all I have to do is wait for lambda expressions in C++, coming sometime next year.

18 October 2008

Offenses Of The Highest Order

Filed under: Rant vs Vent — Tanveer Badar @ 5:36 PM
  1. Blocking on the thread processing a request for configurable time period.
  2. Modifying an existing service contract instead of creating a new one and inheriting the old one (/me is guilty).
  3. Not protecting static initializers with try { … } catch { … } blocks.
  4. Using open-source persistence layer.
  5. Being forced to work with twits who: do not know how to boot into safe mode; give a blank stare when presented with virtual; get confused when asked about many-to-one and many-to-many relationships. [Update 25/10/08: He quit last Monday. (party)]
  6. Management which throws n people at a task to get it done in 1/n time (n may be arbitrarily large).
  7. Keep getting interrupted by one person or another every 3 minutes.
  8. And I almost forgot. Expect files to be replaced when you send an email “the files which contain just the functions you will need to add to corresponding classes”.
  9. Having no replace (let alone replace all) in Windows Live Writer.

12 October 2008

Tidbit 2

Filed under: Dev inside!, Tips — Tanveer Badar @ 7:29 PM

This one pertains to CLR.

Please, please, please make sure your static constructors do not throw exceptions. Having static state in a class is already asking for trouble in the case of multiple threads, if that reason wasn’t enough proceed below.

For example,

class A
{
      static DataType1 member1 = new DataType1( );
      static DataType2 member2 = DataType2.GetDefaultInstance( );
}

If there is even the remotest chance that either DataType1’s constructor or DataType2.GetDefaultInstance will throw an exception you are better off with this version:

class A
{

    static DataType1 member1;
    static DataType2 member2

    static A( )
    {
        try
        {
            member1 = new DataType1( );
        }
        catch( Exception ex )
        {
            // do some logging
        }
        try
        {
            member2 = DataType2.GetDefaultInstance( );
        }
        catch( Exception ex )
        {
            // do some logging
        }
    }
}

The only reason for all this hassle is the avoid throwing uncaught exceptions from .cctor of a type.

Because, for a type whose static constructor throws an exception, EE ensures that no instance of that type will ever be instantiated in that appdomain.

[Update 11/03/09: Many moons after the original post, I come across this. The exact same problem happens in native world.]

Tidbit 1

Filed under: Dev inside! — Tanveer Badar @ 7:13 PM

Whenever you write an optimizer for a compiler/assembler/HW synthesizer, anything in general which will try to optimize expressions please ensure you special case a(b+c).

There is no need to do ab + ac, unless you want to split hairs.

[Disclaimer: I am allergic to memory models for the next 30 minutes.]

2 October 2008

The Legacy of Javid Iqbal

Filed under: Things in life — Tanveer Badar @ 8:38 PM

I don’t know why this particular thought crossed my mind, perhaps when I came across this:
http://www.billoreilly.com/outragefunnels.

Does anyone even remember now the horrors convicted serial killer/pedophile Javid Iqbal unleashed during 1999-2001? Whole host of parents and families who are stranded from their beloved sons and daughters.

How no one was able to track him down for over an year and no one cared to find out what motives were behind all those killings? How he died a mysterious death in police custody?

What really amazes me is that there is no information available on internet about those brutal murders. Nothing at all. Except for this little piece on BBC’s website:
http://news.bbc.co.uk/2/hi/south_asia/549787.stm, which tells one very little about what happened in the, then, past and coming future.

Why didn’t we wonder then and question authorities how he died? What veiled hand was behind him which was protected from coming to light by his unexplained death? Why no one explored the possibility that he was never a sociopath? Why isn’t there any documented data in readily accessible way after 8 years? Why aren’t there any laws yet which establish strictest punishments for such felons?

Lots of questions which will remain unanswered till no one remembers the atrocity which was once roamed amongst us safe and free, the oddity which left his legacy for God knows how many to peruse.

— — .-. … . -.-. — -.. . .- -. -.. …. — .– .. .- — -. — – .- -… .. –. ..-. .- -.

Filed under: Computer Theory, Funnier — Tanveer Badar @ 3:59 PM

– …. .   -.- . -.–   .. …   .. -.   – …. .   – — .–. .. -.-. .-.-.-   — .-.   …. . .-. . .-.-.-  -… ..- -   -.– — ..-   .– .. .-.. .-..   -. . . -..   – —   -.. . -.-. .. .–. …. . .-.   – …. .   -.- . -.–   – —   -.. . -.-. .. .–. …. . .-.   – …. .   -.-. .. .–. …. . .-.   – . -..- – .-.-.-   —… -.–.-

– …. .   -.-. — -.. .  -.. . … .. –. -.  … …. — .– …   .. -   — .-. .. –. .. -. .- – . -..   -… . ..-. — .-. .   .. -. ..-. — .-. — .- – .. — -.   – …. . — .-. -.–   .– .- …   . …- . -.   ..-. — .-. — ..- .-.. .- – . -.. .-.-.-   .— ..- … -   – —   … …. — .–   – …. .   …. — .-. .-. — .-. …   — ..-.   .– …. .- -   .- -.   .- .– ..-. ..- .-..   -.. . … .. –. -.   .. -   .. … –..–   -.-. — -. … .. -.. . .-.   .– …. -.–   .. -   -. . . -.. …   .-.. . – – . .-. -..-. .– — .-. -..   … . .–. .- .-. .- – — .-. … .-.-.-   -… -.–   – …. .   .– .- -.– –..–   — -.–   .-. .- -. -   .. -.   -. —   .– .- -.–   ..- -. -.. . .-. — .. -. . …   – …. .   … .. –. -. .. ..-. .. -.-. .- -. -.-. .   — — .-. … .   -.-. — -.. .   … . .-. …- . -..   -.. ..- .-. .. -. –.   .– .– ..   .- -. -..   .– .– .. .. .-.-.-   .. -   .– .- …   … – .. .-.. .-..   – …. .   -… . … -   – …. .. -. –.   ..- -. -.. . .-.   – …. — … .   … .. – ..- .- – .. — -. … –..–   -.-. . .-. – .- .. -. .-.. -.–   – …. .   -.. . … .. –. -.   — ..-.   . -..- – .-. . — .   .– .. – .-.-.-

-. — .– –..–   -… .- -.-. -.-   – —   – …. .   – — .–. .. -.-.   .- -   …. .- -. -.. .-.-.-   .. ..-.   -.– — ..-   –. —   – —   – …. .   .– .. -.- .. .–. . -.. .. .-   .–. .- –. .   ..   .-.. .. -. -.- . -..   – —   . .- .-. .-.. .. . .-. –..–   -.– — ..-   .– .. .-.. .-..   … . .   …. — .–   … — .- .-.. .-.. . .-.   -.-. — -.. . …   .- .-. .   …- .- .-.. .. -..   .–. .-. . ..-. .. -..- . …   — ..-.   .-.. .- .-. –. . .-.   -.-. — -.. . … .-.-.-   .-.. . – – . .-.   .   .. …   . -. -.-. — -.. . -..   .- …   .-.-.-   .- -. -..   — .- -. -.–   — – …. . .-.   .-.. . – – . .-.   -.-. — -.. . …   -… . –. .. -.   .– .. – ….   .-.-.- .-.-.-   – …. .. …   -. . -.-. . … … .. – .- – . …   – …. .- -   … — — .   — – …. . .-.   .-.. . – – . .-.   -… — ..- -. -.. .- .-. -.–   — .- .-. -.- . .-.   — ..- … -   -… .   ..- … . -..   -… . -.-. .- ..- … .   -. —   .-.. .-.. -.–.- -.- -.–.-   .–. .- .-. … . .-.   -.-. .- -. –..–   ..- -. .- — -… .. –. ..- — ..- … .-.. -.– –..–   .- .-.. .– .- -.– …   -.. . -.-. — -.. .   .. .-.-.-  

— -.   – …. .   — – …. . .-.   …. .- -. -.. –..–   …. ..- ..-. ..-. — .- -.   .- -. -..   .- .-. .. – …. — . – .. -.-.   . -. -.-. — -.. .. -. –.   …. .- …- .   – …. .   -. . -.-. . … … .- .-. -.–   .–. .-. — .–. . .-. – -.–   … …. — .-. – . .-.   -.-. — -.. . …   .- .-. .   -. — -   …- .- .-.. .. -..   .–. .-. . ..-. .. -..- . … .-.-.-   .- -. -..   .-.. . – …   -. — -   ..-. — .-. –. . -   – …. .   — .- –. -. .. ..-. .. -.-. .- – .. — -.   — ..-.   … -.– — -… — .-.. …   .-. . –.- ..- .. .-. . -..   – —   .-. . .–. .-. . … . -. -   – . -..- – .-.-.-   .-.. . – – . .-. …   .   .- -. -..   -   …. .- …- .   – …. .   … …. — .-. – . … -   -.-. — -.. . …   .- -. -..   – …. . -.–   .- .-. .   .- -   .-.. . .- … -   .—-   … -.– — -… — .-..   .-.. — -. –. .-.-.-   .-. . … -   — ..-.   – …. .   .-.. . – – . .-. …   –. . -   ..- .–.   – —   ..-. — ..- .-.   … -.– — -… — .-..   .-.. — -. –.   -.-. — -.. . … –..–   … —   .– .   .- .-. .   – .- .-.. -.- .. -. –.   .- -… — ..- -   — .- –. -. .. ..-. .. -.-. .- – .. — -.   — ..-.   .- -   .-.. . .- … -   ..— -….- ..— .-.-.- ….. -..- .-.-.-

8 September 2008

I (heart) Firefox

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

And nothing is going to change that, whatsoever!

3 September 2008

The Best Programming Language

Filed under: Dev inside!, Rant vs Vent — Tanveer Badar @ 5:30 AM

The myth doesn’t exist.

There is no single best programming languages. If you are too thick to take one as the best, you may as well open a grocery shop and ditch programming forever.

I really hate this line of chat with totally unknown, or unenlightened fresh graduates (or w/e):

<someone>: hello
<me>: hi
<someone>: what do you do for a living?
<me>: making peoples’ lives a living hell
<someone>: you are joking
<me>: of course
<someone>: your real job
<me>: programming

[Then, the stupid question comes.]

<someone>:im too interested in programming
<someone>:which language you use most
<me>:there is no single language, depends on what you are working on
<someone>: i mean present trend
<me>: there are many, there is no single answer to that question of which is the best

[Then, the same question phrased differently this time and my same reply.]

[Then, the same question phrased differently yet again for the third time and my same reply.]

Finally, I got tired of the recursive non-decision but didn’t have the nerve or brain left to tell them to buzz off.

« Newer PostsOlder Posts »

Blog at WordPress.com.