I am not worthy

Some of the people who read this blog are amongst the cleverest, most productive and influential programmers and technical authors in the world. This, despite the fact that I am an utter fool, obsessed with toilet humour and cheap satire. I am utterly bewildered at how fortunate I am to have the ear of such industry legends as Kathleen Dollard, Julia Lerman and Mike Gunderloy, amongst others.

I was so blown away, just now when I found a comment from Kathleen Dollard that I burnt the meal I was half-way through cooking. The long suffering Mrs. Secret Geek was less than impressed, but ultimately sympathetic.

Kathleen, in case you don't know, is the author of 'Code Generation in Microsoft .NET', a topic which I am right behind, even though I confess to not having seen the book personally. On her site she uses a lord of the rings metaphor to explain the importance of Code Generation:

"...line by line code creation [is] the Ring of Doom we've all been dragging around. In spite of all our brilliant technological advances, we still write code the same way we did 20 years ago - line by line in an editor. The ring is our blindness to recognizing this legacy because we can't see past the need get that next line of code written."

I couldn't agree more. As my boss, Bill Murphy, always says:

'you simply cannot be profitable in this business unless you can automatically generate the basic maintenance programs that we find ourselves writing again and again, year after year.'

The company I work for spends a lot of time getting code generation right. It can be a frustrating purpose, writing or fixing templates when you'd rather be writing or fixing code. But the economics are a no-brainer.

Here's to code generation!

 

Riddle me this, batman.

sql,

Why do database designers deliberately create one-to-one relationships?

e.g. You can have a table with 50 columns, or you can have two tables with a one to one relationship, having 25 columns in one and 25 columns in the next (the foreign key acting as a primary key). Maybe the first column is called "Contact_Details" and the next table "Contact_Details_Extended"

What's the big advantage? Something tells me Frans Bouma might have an opinion on this. Anyone? Bueller? Bueller?

Any ideas? Leave a comment, or mail me.

 

Stupid Code To The Rescue!

A big dose of .NetFrustration this morning.

When you upgrade an assembly from version 1.0 to version 1.1 you are likely to get a lot of squiggley blue lines and warnings such as:

OR:

OR worse yet:

Google turned up blank, MSDN turned up blank, but I finally got rid of the warnings, by writing stupid code.

(Read on for some dodgy solutions and some stern lectures. :+))

For example:

Rather than:

I would write:

And voila! it works just fine.

The next failed piece of upgraded code was this

In this case you need to add two more parameters, an 'XMLResolver' and an 'evidence' param. This worked:

Evil Moral of the story is:

If a parameter is required, but you don't know why, just set it to 'nothing.'

That's not the sort of lesson I'd like to teach people. But it's what Microsoft taught me today.

Third situation was a bit trickier and called for an even nastier hack.

This worked in version 1.0, but threw a warning in 1.1:

The warning was a familiar one:

My first thought was: 'add a new parameter, value of nothing'. But this failed because the compiler couldn't resolve which overloaded interface I was after. The result of such an approach was:

i.e., 'Sure you want nothing -- but what type of nothing??' Fair cop, so I tried this instead:

Now there were no warnings and it did compile. But did it work? Who cares? Because right then i thought of a cleverer and nastier solution, that would be bound to confuse other developers. Naturally, I gravitated toward it immediately:

I didn't test that it worked, because 'hey, it should, right?'

At that moment, another, nastier solution occurred to me. I call this one: "What type of 'nothing'? **This** type of nothing!"

No time to test it, but the compiler doesn't freak, so my money says she works.

And now I can get on with writing other, better, faster bugs.

As an old friend said to me just yesterday: "One man's bug is another man's paycheck."

 

How to match a string value to its equivalent Enum value.

Updated! How to retrieve an Enum member given its name

To retrieve an Enum member given its name, use the Parse method of the Enum class, and cast the result to your Enum type:


MyEnumVal = CType(System.Enum.Parse(GetType(MyEnum), "gamma"), MyEnum)
Debug.WriteLine(MyEnumVal.ToString()) ' The output is "gamma"

Previous code:

To retrieve an Enum member given its name, use the ConvertFrom() method of the TypeConverter class and cast the result to your Enum type:

MyEnumVal = CType(TypeDescriptor.GetConverter(MyEnumVal).ConvertFrom("gamma"), MyEnum)
Debug.WriteLine(MyEnumVal.ToString()) ' The output is "gamma"

 

the unbearable lightness of being Delpino

A little bit of philosophy from Brisbane band Delpino.

(end of comment)

(nothing to see here)

 

Things I miss about London

  • leaves falling from trees
  • big coats and bitter cold
  • europe on your doorstep
  • crooked narrow streets
  • depressed shop assistants
  • people like roger, dinesh, anthony wong, liffey and scott
  • a swift-half after work that accidentally runs into the closing-time bell
  • belgian beer, belgian chocolate
  • italy just a stone's throw away
  • every alley wafts of piss
  • the tube. i even miss the frigging tube.

end of comment

(nothing to see here)

 

AspCompat='True'

Just a reminder. If you're writing an ASP.net page that invokes a RCW (runtime callable wrapper) to a COM component... you may need to include the attribute 'ASPCompat=True' in your page directive.

In particular, if you have this situation:

then it may be because ASP uses a STA (single-threaded-apartment) threading model, which the COM component may rely upon when returning calls.

The way to get the component to behave in ASP.net is to include that attribute, 'ASPCompat=True' in the calling page's page directive.

You already knew that right?

Well, should you accidentally forget... the chances of working it out on your own are very slim indeed, even with Google's help.

(end of comment)

nothing to see here... just move along

 

Royo on TV?

is it just me, or does Roy Oshergrove look like that guy off "Alias" whom Jennifer Garner is secretly in love with?

the guy off alias roy oshergrove

Come to think of it, there's someone else they *both* look like...

the guy off alias roy oshergrove royo?

(It's traditional to now say something like 'oh thats roy on the right, by the way.' But you know by now that I never indulge in such cliched humour. [100% sarcasm])

(end of comment)

nothing to see hear... comment if you want...
 

Double-posting comments: blame the software!

blog,

Everyone double-posts a comment at times. I've done it. You've done it.

When you accidentally post a comment twice, you feel like an idiot.

You curse yourself. You belt your head against the monitor, you bite your tongue and you jab needles into your eyes.

But is it really your own fault? The software could handle for it. But it doesn't. Blame the software. The major commenting engines *should* handle for it. It's an easy feature to include. But they're so damn rich, fat, lazy and yes, butt-ugly, that they left it out on purpose just to make you feel like a newbie idiot once in a while.

So send a letter to the authors of mt, .text, radio... and send it twice. they'll get the message.