Delegates Vs. Method Calls

In one of his articles on
building a CAB-like infrastructure, Jeremy
Miller
brought out a pretty interesting point: The choice between using Events/Delegates
and Direct Method Calls. This can be a controversial topic at hand, but it’s an interesting
aspect, and can significantly affect the readability of the code.

Events and delegates are very powerful features I use all the time. However, here’s
a tip: Be careful about building an entire framework or complex structure based purely
around delegate calls. I’ve been spending a lot of time the past few days tracing,
debugging and running through the code in the Base Adapter sample code in the BizTalk
Server 2004 SDK [1], which is exactly a little framework for building BizTalk Adapters.

Now, the base adapter is OK, in that it does make it a bit faster to develop adapters
by taking care of a lot of the boilerplate code necessary. However, a significant
part of it is built out of classes that use a lot of delegates (not even proper events,
unfortunately) to notify of significant events around each other; like for example
that a batch was submitted to BizTalk or that a message needs to be suspended.

The unfortunate side effect of this is that tracing the base adapter code in source
code form requires a lot of patience and a lot of Find References/Find Definition
jumps all around to figure out exactly what’s going on. In fact, I’ve spent quite
a few hours on it and the code can be significantly convoluted; and parts of it are
just a lot easier to trace using Step Though/Step Into in the debugger; which is rather
frustrating.

So next time you want to build a framework or library and think gluing all together
with delegates and events is cool; make sure you’ve got a real use case for them and
that they are not going to end up hindering readability and maintainability.

[1] The version included in the BizTalk 2006 SDK is different and
a lot simpler. I still don’t quite like it and generally prefer to write directly
against the Adapter Framework APIs, but that’s just me.

Technorati
tags: BizTalk, Base
Adapter
, Delegates

Changing text encodings of output files redirected from PowerShell.

I created a logman setting file as follows:
typeperf -q | where { $_ -like “\Phy*” } | foreach { ‘”‘ + $_.Trim() + ‘”‘ } > counter.txt


But, logman raised an error reading “Invalid counter path” when I tried to update a counter data collection with the settng file, counter.txt. That’s right. Logman requires the ANSI encoding for its setting file, while the output redirection that PowerShell created Unicode files for that redirection.


Then, How to create a output text file with different encodings?


typeperf -q | where { $_ -like “\Phy*” } | foreach { ‘”‘ + $_.Trim() + ‘”‘ } | output -encoding ASCII

Changing text encodings of output files redirected from PowerShell.

I created a logman setting file as follows:
typeperf -q | where { $_ -like “\Phy*” } | foreach { ‘”‘ + $_.Trim() + ‘”‘ } > counter.txt


But, logman raised an error reading “Invalid counter path” when I tried to update a counter data collection with the settng file, counter.txt. That’s right. Logman requires the ANSI encoding for its setting file, while the output redirection that PowerShell created Unicode files for that redirection.


Then, How to create a output text file with different encodings?


typeperf -q | where { $_ -like “\Phy*” } | foreach { ‘”‘ + $_.Trim() + ‘”‘ } | output -encoding ASCII

WordPress Update, a new security blog and love for Akismet

BlogSecurity is a new blog that focuses on security, primarily orientated around the popular WordPress blogging platform (which also powers this blog). One of their first posts was rather disturbing – of 50 WordPress blogs they reviewed, 49 weren’t running the latest version of the software and were susceptible to potentially known attacks.
As a result, […]

A sad realisation…allow or deny

A sad realisation…allow or deny

As i mentioned earlier this weeki am now a “Consultant”. This means i will spend most of my working life from this point forward on customer sites. Thats fine except I am now required to wear “notjeans”. In my world there are two kinds of pants. Jeans and NotJeans. NotJeans are for weddings, funerals, court appearances and job interview dentist appointments. My sad realisation which i was aware of already but of which I was in deep denial about is that i am nowrequired to wear NotJeans to work.
Sigh.

Imagine Cup

Last Friday and this Tuesday I was a judge (along with Mike and Chris)  for the Preliminary Finals of the New Zealand leg of the Imagine Cup Software Design Competition. 


We had the tough job of eliminating four of the seven New Zealand teams that entered. In our favour was a clear published judging criteria that the students had access to from the start of the competition.


It was great to see the future generation of ICT graduates linking up with industry mentors and producing quality projects that address real world problems.


The six teams that presented on Monday were as follows:


AUT Champs – Auckland – AUT


Hope2Go – University of Auckland


Active Ed – University of Auckland


Team Ackermen – University of Waikato


Inner-Fire.net – Victoria University of Wellington


T4 – University of Otago


Congratulations to T4, Team Ackermen and AUT Champs for making it through to the next round!


TechEd Session

TechEd Session

I just got done with my TechEd session on using WF and WCF – if you attended the session
– here is the code: teched2007.zip
(474.59 KB)
.  If you didn’t attend my session “This is not the code you are
looking for …..” 😉

Thanks for everyone who came (295 people – wow!). 

BTW – here are the three best and worst thing about teched 2007 according to the people
in my session:

BEST
1)HOL (hands on labs)
2)Just the Information
3)BOF (birds of a feather sessions)

Worst
1)Bathrooms (this was the men only of course)
2)Buses(slow/scalable)
3)Session are too short

Tech-Ed 92.5% Sold!

We knew when we opened the registrations for Tech-Ed this year that we will once again sell out the conference. Sorry we are using the largest venue that New Zealand has to offer and simply can’t get any bigger!

This is a snapshot of the registration graph from last week (the 2007 registrations are the left hand worm) and I have just this morning checked in to see that we are now at 92.5% capacity!

Darryl has a list of the track owners for this years Tech.Ed. I’m taking a welcomed break from this as I was driving it for NZ for the last two years.

Unfortunately it looks like we will sell out the event before formally publishing the speaker list! That said Darryl commented to me yesterday that we have more US Microsoft Product team speakers at this years conference than ever before which is fantastic.

If you are planning on attending REGISTER TODAY so that you don’t miss out!

The US Tech.Ed kicked off in the US this week with a back to the future theme.