Welcome to DevAuthority.Com Sign in | Join | Help

Mock HttpContext

I decided to write a mock HttpContext.

Behavior Driven Design


I ran across a good introductory video on BDD here; think of Behavior Driven Development as a refined version of TDD. NSpec needs some work with respect to the semantics of the API. Specifically, the term Must should be introduced into API; Should is not behaviorally strong enough for the specification (see Sapir–Whorf). I do hope the tool set matures to include a GUI similar to that of NUnit.

I do agree reflection SHOULD not be used to test private members. That said, I seldom find a need to test private method directly via reflection and do so strictly as a last resort. The InternalsVisibleTo is an extremely useful attribute in the context of testing. Microsoft should create a PrivatesVisibleTo attribute.

Anyway, enjoy.

Microsoft .NET Framework 3.0 RTM

The Microsoft .NET Framework 3.0 went RTM last night! The redistributable and SDK can be found here and here, respectively.

posted by Michael Primeaux | 0 Comments
Filed Under: , ,

Microsoft Sandcastle July 2006 CTP Released

Please see the Sandcastle CTP announcement here. Additionally, Arnand (Sandcastle team PM) has posted instructions describing how to create a CHM using Sandcastle, which can be found here.

posted by Michael Primeaux | 0 Comments
Filed Under:

NDOC 2.0 (Alpha)

I ran across an unofficial version of NDOC here that works beautifully with .NET 2.0 assemblies. Certainly the "one-click" help generation is nice. I do hope the Microsoft Sandcastle team eventually creates a similar UI.
posted by Michael Primeaux | 0 Comments
Filed Under:

Microsoft Sandcastle

As a former NDOC user, I appreciate the urgency of shipping correct and detailed API reference documentation. I think few will argue aside from elegance of the consumer API surface, a critical component of any application framework is its API reference documentation.

Recently, I've been working with a pre-release of a new Microsoft product named Sandcastle, which is a set of command-line executables and several assemblies used to generate either CHM or HXS API reference documentation from the documentation file generated by the C# compiler.

Sandcastle generates documentation using the following overall process:

  1. Use the "/doc" compiler option to generate an XML documentation file.
  2. Run the assemblies through Sandcastle (MRefBuilder, XslTransform, and BuildAssembler) to produce a set of HTML files.
  3. Generate resulting help using the Microsoft HTML Help Compiler. The help compiler version 1.0 is used to produce CHM files and version 2.0 is used to generate HXS files.

Several of the XSLTs and the CSS that shipped with my build needed a few minor modifications to produce MSDN-style documentation but overall the architecture is quite nice.

It'll be great to see how well it's received by the developer community. At the time of this writing, the Sandcastle team is targeting a CTP for next week or so.

Message Transmission Optimization Mechanism (MTOM) and Microsoft Web Services Enhancements 3.0

I've been working quite a bit over the past months with the Microsoft Web Service Enhancements (WSE) 3.0 (pronounced "wizzy"). As most are aware, WSE 3.0 supports Message Transmission Optimization Protocol (MTOM), which is the latest W3C recommendation (specification) that supercedes the Direct Internet Message Encapsulation (DIME) and WS-Attachments specifications as the mechanism for sending and optimizing the transmission of binary data within SOAP messages. The key in understanding MTOM is to understand the XML-Binary Optimized Packaging (XOP) specification. XOP presents a different mechanism for serializing an XML Infoset with a view to optimizing that serialization. This makes complete sense since the sending of binary data should be a design point of the web service method signature and not an extra package that's passed around on every method call.

To enable MTOM encoding in WSE 3.0 on the client, add the following configuration section in the web.config file:

<microsoft.web.services3>
    <messaging>
        <mtom clientMode="On" />
    </messaging>
</microsoft.web.services3>

To enable MTOM encoding in WSE 3.0 on the server, add the following configuration section in the web.config file.

<microsoft.web.services3>
    <messaging>
        <mtom serverMode="Optional" />
    </messaging>
</microsoft.web.services3>

For MTOM, WSE 3.0 formats the resulting XML to be that of an XML Infoset as structured in section 1.2 (Example) of the XML-binary Optimized Packaging (XOP) specification.  Meaning, if a web method returns a byte array and MTOM is enabled the client (clientMode="on") and enabled on the server (serverMode="required" | "always") then the infoset is serialized using the XOP format in a MIME Multipart/Related package. The normally base64-encoded content of the return value will instead be that of an xop:Include element, which in turn points to the binary octets of the returned byte array.

However, consider the scenario whereby a web method returns an arbitrarily large string.

[WebMethod]
public string Echo(string message)
{
    if (string.IsNullOrEmpty(message))
    {
        throw new ArgumentNullException("message");
    }

    return message;
}
 

Unfortunately, WSE 3.0 won’t optimize the return value since it isn’t a binary value. Setting aside hardware-based compression solutions, one might decide on a number of solutions to address the scenario. Without much thought any of the following two solutions are sufficient:

  1. Compress the return value and change the method signature to return a byte array instead of a string.
  2. Create a WSE 3.0 filter assertion that creates an XOP package containing the binary representation of the compressed string and then (as WSE does) create a MIME multipart/related message.

Certainly, the easier option is bullet 1. However, option 2 becomes desirable for scenarios where modification of the method signature isn’t possible since either by doing so would break existing consumers or the web service is part of a larger third party owned orchestration.

Before we move on, let's first review what occurs for methods that return a byte array. For example, consider the following web method:

[WebMethod]
public byte[] ToByteArray(string message)
{
    if (string.IsNullOrEmpty(message))
    {
        throw new ArgumentNullException("message");
    }

    return Encoding.UTF8.GetBytes(message);
}
 

With MTOM disabled, I'd expect the following output:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
    <soap:Header>
       <wsa:Action>http://tempuri.org/ToByteArrayResponse</wsa:Action>
        <wsa:MessageID>urn:uuid:8189b1f8-087a-417c-9621-ff32b11addf6</wsa:MessageID>
        <wsa:RelatesTo>urn:uuid:a55d363c-a6ab-448e-96bb-57ec9f519471</wsa:RelatesTo>
       <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
    </soap:Header>
    <soap:Body>
        <ToByteArrayResponse xmlns="htt://tempuri.org/">
            <ToByteArrayResult>
               aWKKapGGyQ=
            </ToByteArrayResult>
        </ToByteArrayResponse>
    </soap:Body>
</soap:Envelope>

Notice the InnerText value (in red) of the <ToByteArrayResult> element is the base64-encoded version of the byte array. Now, with MTOM enabled, I'd expect the output to look like:

MIME-Version: 1.0
Content-Type: Multipart/Related;boundary=MIME_boundary;
    type="application/xop+xml";
    start="<
mymessage.xml@example.org>";
    startinfo="application/soap+xml; action=\"
http://tempuri.org/ToByteArrayResponse\""

--MIME_boundary
Content-Type: application/xop+xml;
    charset=UTF-8;
    type="application/soap+xml; action=\"
http://tempuri.org/ToByteArrayResponse\""
Content-Transfer-Encoding: 8bit
Content-ID: <
mymessage.xml@example.org>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
 xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
 xmlns:wsa="
http://schemas.xmlsoap.org/ws/2004/08/addressing">
    <soap:Header>
        <wsa:Action>http://tempuri.org/ToByteArrayResponse</wsa:Action>
        <wsa:MessageID>urn:uuid:8189b1f8-087a-417c-9621-ff32b11addf6</wsa:MessageID>
        <wsa:RelatesTo>urn:uuid:a55d363c-a6ab-448e-96bb-57ec9f519471</wsa:RelatesTo>
        <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
    </soap:Header>
    <soap:Body>
        <ToByteArrayResponse xmlns="htt://tempuri.org/">
            <ToByteArrayResult>
                <xop:Include xmlns:xop='http://www.w3.org/2004/08/xop/include'
   href='cid:632888921985001408'/>

            </ToByteArrayResult>
        </ToByteArrayResponse>

    </soap:Body>
</soap:Envelope>

--MIME_boundary
Content-Type: application/octet
Content-Transfer-Encoding: binary
Content-ID: cid:632888921985001408

// binary octets ToByteArray result

--MIME_boundary

In this case (with MTOM enabled), the message is now a MIME multipart/related formatted message where the InnerText value of the <ToByteArrayResult> element is now replaced with an <xop:Include> element, which refers to a MIME part containing the binary value of the response.

Now that we've covered the contextual information, I can now describe what I'd like to accomplish.

For a client request, I'd like to compress the InnerXml value of the soap:Body element and replace it with an xop:Include element, which refers to a MIME part containing the compressed binary bytes. On the server, my compression filter will replace the InnerXml of the soap:Body with the uncompressed version of the byte array.

When MTOM is enabled, the wire-format should look like the following:

MIME-Version: 1.0
Content-Type: Multipart/Related;boundary=MIME_boundary;
    type="application/xop+xml";
    start="<
mymessage.xml@example.org>";
    startinfo="application/soap+xml; action=\"
http://tempuri.org/ToByteArrayResponse\""

--MIME_boundary
Content-Type: application/xop+xml;
    charset=UTF-8;
    type="application/soap+xml; action=\"
http://tempuri.org/ToByteArrayResponse\""
Content-Transfer-Encoding: 8bit
Content-ID: <
mymessage.xml@example.org>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
 xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
 xmlns:wsa="
http://schemas.xmlsoap.org/ws/2004/08/addressing">
    <soap:Header>
        <wsa:Action>http://tempuri.org/ToByteArrayResponse</wsa:Action>
        <wsa:MessageID>urn:uuid:8189b1f8-087a-417c-9621-ff32b11addf6</wsa:MessageID>
        <wsa:RelatesTo>urn:uuid:a55d363c-a6ab-448e-96bb-57ec9f519471</wsa:RelatesTo>
       <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
    </soap:Header>
    <soap:Body>
        <xop:Include xmlns:xop='http://www.w3.org/2004/08/xop/include' href='cid:632888921985001408'/>
    </soap:Body>
</soap:Envelope>

--MIME_boundary
Content-Type: application/octet
Content-Transfer-Encoding: binary
Content-ID: cid:632888921985001408

// binary octets of compressed soap:Body inner XML

--MIME_boundary

Notice, the MIME multipart/related message contains the compressed version of the entire soap:Body in the MIME boundary identified by the xop:Include element.

I’ve included a sample WSE 3.0 compression filter assertion to this blog entry, which illustrates how to propertly create an XopContentsNode so the WSE infrastructure will correctly create an XOP infoset. 

Before you take off, there are a few important points worth mentioning. First, the WSE libraries will not create an XOP package if any of the following events occur:

  1. If the compressed byte array does not reach the XOP size threshold of 768 then WSE will not XOP the resulting payload.
  2. If you invoke the XopContentsNode.Data get accessor then WSE will base64-encode the byte array. I find this point very unusual and not very intuitive.

Second, there is another catch. You should not use the WSE trace feature to see whether the resulting payload is XOPped out since the WSE tracing infrastructure is a SOAP-level tracing feature and does not operate at the transport level. Use the Microsoft Windows Network Monitor (netmon) or some other transport layer tracing tool.

Lastly, as most of us are aware, the Microsoft WSE 3.0 (and 2.0) documentation leaves a lot to the imagination. As such, I’m left with absolutely no help in understanding how to use the supported classes in the Microsoft.Web.Services3.Mime namespace. It’s sufficed to say this is a glaringly obvious pain in an otherwise stable framework.

That said, what I can glean from further inspection is the following:

  1. SoapEnvelope is a subclass of the XopDocument class and it is this class that defines the CreateBinaryNode method.
  2. The SoapEnvelope.CreateBinaryNode(…) method returns an XopContentsNode instance whose Value property contains the unaltered version of the byte array (or Stream) that is passed into the method.
  3. The XopContentsNode.Data property returns the base64-encoded version of the bytes.
  4. While I am able to use the SaveToXopPackage method defined on the XopDocument class to create a MIME part, there’s no clear documentation as to how to integrate [use of this method] into the existing WSE pipeline.

 

posted by Michael Primeaux | 0 Comments
Filed Under: , ,
Attachment(s): IDynamics.Samples.Web.Services3.zip

Announcing Beta Release of GP Ruby.NET Compiler


For this interested in Ruby.


From: Wayne Kelly [mailto:w.kelly@qut.edu.au]
Sent: Tuesday, June 20, 2006 1:19 AM
To: [Removed]
Subject: Announcing Beta Release of GP Ruby.NET Compiler

We are pleased to announce the preliminary Beta release of the Gardens Point Ruby.NET compiler. Note: this is not just a Ruby/.NET bridge, nor a Ruby Interpreter implemented on .NET, but a true .NET compiler. The compiler can be used to statically compile a Ruby source file into a verifiable .NET v2.0 assembly or it can be used to directly execute a Ruby source file (compile, load and execute). Our implementation is not yet fully complete, but it is the only Ruby compiler that we know of for either the .NET or JVM platforms that is able to pass all 871 tests in the samples/test.rb installation test suite of Ruby 1.8.2.

Complete source code of our system can be downloaded from: http://plas.fit.qut.edu.au/Ruby.NET/Download.aspx

Please note, that we have so far made no attempt to optimize the performance of our system or to provide any support for interoperability with .NET programs written in other languages. We have chosen instead to initially focus on the challenging task of achieving complete semantic compatibility with the standard Ruby interpreter. Once this is achieved we will move on to those other challenges.

To achieve full semantic compatibility, many sections of our runtime library implementation mirrors the structure of the Ruby 1.8.2 interpreter code. We thank Matz and his colleagues for making their source code available under such a liberal license that enables works such as ours. We similarly, make our system freely available under a similarly liberal open-source license. We are seeking keen Ruby and .NET programmers to assist with further testing and development (see our web site for further details).

We look forward to your feedback ...

Cheers, Wayne.
(For the GP Ruby.NET development team).


----------------------------------------------------------------------------
Dr Wayne Kelly Senior Lecturer
Email: w.kelly@qut.edu.au School of Software Engineering and DC
Phone: +61 7 3864 9336 Faculty of Information Technology Fax: +61 7
3864 9390 Queensland University of Technology

posted by Michael Primeaux | 0 Comments
Filed Under:

Bill Gates' Transition

 

From: Bill Gates
Sent: Thursday, June 15, 2006 1:41 PM
To: Microsoft and Subsidiaries: All FTE
Subject: My Transition Plans

I wanted to take a moment to share some of my thoughts, as well.

As Steve’s mail indicates, I’ve decided that two years from now, in July 2008, I want to devote more time to the work of the Bill & Melinda Gates Foundation. 

Right now and for the next two years, my full-time job is here at Microsoft, and my part-time job remains the Foundation.  Beginning in July 2008, I will switch that, to be full-time at the Foundation, while remaining involved with Microsoft as Chairman and an advisor on key development projects on a part-time basis. 

To prepare for this change, we have a well-thought-out transition process.  Again, I will continue at Microsoft full-time for the next two years, but over the course of those two years, my day-to-day responsibilities will shift to a team of incredible technical leaders who are already doing amazing things at the company. 

I feel very lucky that we’ve got extraordinary technical leaders at the company, like Ray Ozzie and Craig Mundie, who can step up to assume the roles that I’ve played.  I’ve known Ray for the last 20 years, and he has created some of the most important developments in the industry.  Craig and I have worked together for nearly 14 years, and he’s been a technical visionary and a leader on policy throughout his career.  With Ray and Craig stepping up, I feel very confident that the technical stewardship of Microsoft is in very capable hands.

And I feel the same way about our business leadership.  Our core businesses are strong and we have a clear vision for how we will meet new challenges and opportunities.  We just had our first $12 billion quarter, and we continue to generate almost a billion dollars in profit every month.  We are about to launch breakthrough versions of Windows, Office and Exchange, which are already generating a lot of excitement. 

Six years ago, Steve and I made a major transition when he stepped up to be CEO.  He’s done a fantastic job by every measure, whether it’s the people he’s brought in, the new ways he’s running the company, or just the objective results – like doubling our revenue in six years.  Steve has driven us to make bold bets on things like Xbox, Real Time Communications, business applications, IPTV, and many others including the Live platform.  Steve is the best CEO I could imagine for Microsoft – he is changing the company in ways it needs to be changed. He is bringing in new leadership at all levels.  And, he is focused on the long-term – making Microsoft a great company not just today but for decades to come. 

With Steve’s organization of the company into three divisions led by our incredible presidents – Jeff Raikes, Robbie Bach, and Kevin Johnson – we’ve laid a solid foundation for greater autonomy, agility and entrepreneurial spirit in our product groups.  And with the great addition of Kevin Turner as our COO, our leadership team has never been stronger.

Our deep technical strength is one of the key reasons I believe Microsoft is well-positioned for great success in the years ahead.  I’m very pleased that in addition to Ray, Craig, David and Rick, Steve has asked J Allard, Bob Muglia, and Steven Sinofsky to play an expanded role in shaping the company’s business and technology strategy.  And when you consider all of our remarkable Technical Fellows, Distinguished Engineers, all of the brilliant researchers working at our MSR labs around the world, and all the technical people in the business groups, I can safely say that our technical talent has never been stronger or deeper.

Obviously, this has been a very hard decision for me.  Microsoft will always be a huge part of my life, and I’m lucky to have two callings that are so important and so challenging.

On a personal note, I know that my work on global health and education issues at the Foundation would never have been possible without the enormous success of Microsoft, so I want to thank you and all of the employees past and present who have contributed so much to this company. 

For these last 31 years, I’ve had the best job in the world.  I’ve worked with some of the brightest and most passionate people in the world. Together, we’ve built a great company whose products have empowered people around the world.

We’re only at the beginning of what software can do, and I’m excited about the impact that Microsoft can have.  I’m going to take an extended vacation this summer with my family, but I’ll be back in late August and I look forward to working with all of you for the next two years and beyond, to make those dreams a reality.

Thanks.

Bill

From: Steve Ballmer
Sent: Thursday, June 15, 2006 1:31 PM
To: Microsoft and Subsidiaries: All FTE
Subject: New Era of Technical Leadership

I wanted to share some important news with you, and talk a little bit about some of my top priorities in the coming months.

Today we are announcing the news that – effective July 2008 – Bill will transition to a part-time role at the company. While this is significant news, it’s important to note that for the next two years Bill will continue full-time as Chairman, and that even after July 2008 he will continue as Chairman and an advisor on key development and business issues.

This is not a decision that either Bill or I take lightly. We have a solid transition plan, and Microsoft is well-positioned to make this transition given the depth of senior leaders we have, and our strong pipeline of products over the coming year.

As Microsoft has grown, Bill also has taken on another challenge – the amazing work of the Bill & Melinda Gates Foundation to confront critical issues like global health and education.  The Foundation’s efforts have begun to have a major impact, and there is growing need for him to spend more of his time on Foundation activities.

Bill and I have talked over the years about scaling the company’s leadership and about succession planning. Our efforts to expand the company’s leadership and delegate more authority to meet the challenges of our expanded scope of innovation are well underway. At the same time, we agreed that when the time came for Bill to reduce his time at the company, we would announce it far enough in advance to ensure a smooth transition, giving him time to work side by side with new leaders.  Bill and I are confident this plan will ensure Microsoft’s future and build from the steps we have already taken.

You can’t replace everything that Bill brings to this company with a single person, but Bill and I are confident we’ve assembled a great team that can step up and drive Microsoft innovation forward without missing a beat. 

  • Ray Ozzie will immediately take on Bill’s role of Chief Software Architect.   In Ray’s expanded role, he will partner with the Presidents to drive technical, strategic and business decisions that have cross-divisional impact.
  • Craig Mundie takes the newly created position of Chief Research and Strategy Officer.  Craig will assume Bill’s responsibility for the Company’s research and incubation activities and partner with Brad Smith to guide our intellectual property and policy work, in addition to his existing responsibilities.
  • Effective immediately, Rick Rashid and his organization will report to Craig, and David Vaskevitch, our CTO, will report to Ray and work closely with him on company-wide technical issues.  Their roles are unchanged. Eric Rudder and Jon DeVaan will also stay reporting to Bill.  In a year, we will transition all Bill’s direct reports so we are fully in our new roles.
  • Ray, Craig and I will be instituting regular meetings with Technical Fellows, Distinguished Engineers, and other top development executives, to ensure that we are incorporating their insights into our strategic thinking and decisions.

About a year ago, we organized our operations into 3 major divisions and an operating group, and gave those units broad authority.  This was a first step toward greater speed and agility, by pushing decision-making and accountability out to the individual businesses.  We have great leaders in place to run our businesses including our COO Kevin Turner, our division presidents Kevin Johnson, Jeff Raikes, and Robbie Bach.  And, of course, with Jim Allchin’s remaining time here before retirement, he’s focused on shipping a high-quality Windows Vista release.  As we enter this second phase of transition, I am especially excited to see key product leaders like Steven Sinofsky, J Allard, Bob Muglia, and others step up to new and expanded responsibilities. 

We have great teams running our businesses and spearheading our technical leadership. I am drawing from my direct reports and the people highlighted here on both the business and technical sides to form a kind of Kitchen Cabinet of advisers. They will help me make the right decisions that cut across all our businesses -- about where to innovate, where to invest, how to evolve our brand, how to manage our people and improve our effectiveness.

In the third phase, by the first of the year, many teams will have completed important milestones, giving our leaders the chance to take bold steps to further improve agility, focus on Live and other new priorities, and give exciting and expanded responsibilities to top performers. 

As we move forward, there are some basic principles that will continue to be key to our success. 

First, we take an incredibly broad view when it comes to innovation.  We invest in long-term research and we invest in product features that are ready to come to market right away.  We nurture small teams, and we do large scale projects. We innovate in development and incubation groups as well as through external acquistions.  Innovation is the top priority for the company.

Second, we are a products and services company.  We hire the most brilliant and passionate technical people, and give them the tools and environment where they can do their best work. We have never had a better year than the last one in recruiting.  The number and quality of campus and industry hires was fantastic and our retention of good performers is near an all time high. Great products brought to market by first-rate business people is the key to our long term success.

And third, we’re patient, we’re relentless, we keep working and investing and listening to our customers and improving our products until we rise to the top.  Windows, Office, and Server all took a number of years to get to critical mass. We are applying the same tenacity and long-term commitment to break through in all areas from Windows, Office, business applications and servers, to advertising, search, TV and gaming, and mobility.

Perhaps most importantly, we will be tenacious and persistent in driving our Live initiative with all the technology and business model implications that it has.

We do also need to be relentless in improving our agility, quality, and impact as a company – ensuring our products come to market on a timely basis, decisions are clear and stick, and our time and energy are focused on customers and creating new software. 

We have an amazing opportunity ahead of us.  We have only scratched the surface of what software innovation can do for our customers, and the value we can create for employees, shareholders and customers alike.

Later this afternoon we’ll be holding a company webcast to discuss our transition plans over the next two years and take your questions.  Please join me, Bill and other senior leaders at 4:30pm for the Employee Town Hall webcast.

Thanks.

Steve

Fiefdoms: Cause and Effect

I ran across a great article in CIO Magazine regarding the cause and effect of fiefdoms.

"The fiefdom syndrome stems from the inclination of managers and employees to become fixated on their own activities, their own careers, their own territory or turf to the detriment of those around them.

People who create fiefdoms can become dangerously insular, losing perspective on what is happening in the world outside their own control. They also lose their ability to act consistently on behalf of the greater good, or in a way that enhances the effectiveness of the larger organization. They often resist new situations and change.

People who create fiefdoms tend to hoard resources. They are determined to do things their own way, often duplicating or complicating what should be streamlined throughout the company, leading to runaway costs, increased bureaucracy and slower response times.

Organizations infected with fiefdoms tend to kill off or stifle individual creativity, leading to what I call the 'freeze factor': when organizations become frozen or stuck in place, letting competitors pass them by."

posted by Michael Primeaux | 0 Comments
Filed Under:

WCF Documentation Update

The WCF team released a third update to their documentation here.

posted by Michael Primeaux | 0 Comments
Filed Under:

Information Modeling

A former colleague and friend of mine recently asked if I "had time for a quick question?" He wanted my opinion as to whether he should favor an abstract or concrete information model for his specific application. My mind was instantly flooded with questions regarding concurrency rate, change management, and data partitioning requirements.

Generally speaking, the life of any distributed system directly relates to its level of entropy. Furthermore, the level of entropy in a system directly relates to the system's computational complexity. When designing applications to solve business problems, information storage and retrieval is one of the more important foundational design points. If the information schema is designed without efficiency, scalability, and flexibility in mind then not only will the system perform poorly but it will not meet the requirements imposed by future business demands.

At either end of the spectrum, an information schema is categorized as either concrete or abstract—though there most certainly are varying degrees in between. Each design has advantages and disadvantages. A concrete design is easier to conceptualize and requires less complex algorithmic considerations. In most cases, a concrete design is far less flexible than that of an abstract design. A properly designed abstract information schema remains invariant in the face of change that would otherwise impose a relatively large amount of downtime for an equivalent concrete model.

Arguably, however, many abstract systems are indeed designed with concreteness in mind. By this I mean the system is designed to contain representations of concrete constructs. Why? It's how humans think in every day life. If I ask you to describe yourself then you're statistically more likely to forgo attributes such as "person" or "human" and instead provide attributes such as height and weight. The former attributes are more abstract (relatively speaking) than the latter attributes. However, both indeed describe a concrete construct: you.

I tend to favor abstract information models but then again, I spend the majority of my time in abstract problem domains. However, regardless of which classification the solution domain requires, the following rules and considerations have proven effective in designing an efficient information model:

  1. Effectively understand the information.
  2. Describe it unambiguously.
  3. Enforce structure and style guidelines.
  4. Allow for efficient storage and retrieval of information.
  5. Keep network communication to a minimum. Don't over engineer.

The last bullet (5) is delivered with a caveat. Over engineering is a very subjective quantification that takes time to perfect and is directly related to your complete understanding of the information (bullet 1). If bullet 1 suffers then so does bullet 5.

Usually, the questions are quick. It's the answers that take the time.

A Word on Elegance

What do I mean by elegance?  Most software engineers equate elegance to efficiency. Still some equate elegance to robustness. Others choose correctness. All are variables in the equation of elegance. Many other variables exist and all are important.

Make no mistake, software is art. Some artists prefer oil on canvas as their medium. Others choose water color. As software design engineers (SDEs), we have chosen 1s and 0s to communicate our creative visions. Elegance must exist at each step in the engineering process and not only as an afterthought in the development phase. Elegance is the responsibility of each and every participant with accountability functioning as the enforcement point. Without accountability, chaos reigns. Accountability starts within.

Many SDEs find themselves searching for or memorizing patterns that “work” to shortly find themselves bulimically spewing the results onto their canvas. What happened to the elegance of originality? It’s far too easy to become a GP (“Google programmer”). Why? Because creativity and originality aren’t as convenient as letting others do the work, which leads to chaos and hard-to-maintain code; especially, when you’re not the original developer.

Stay with me; we’re only scratching the surface. Do you remember the last time you really evaluated the usability of your consumer API surface? Did your evaluation begin in the design phase? Start with a high-level view of the scenarios. Then oscillate between architectural design and the scenario-based consumer API surface. Do not think about technical design until you’re satisfied with the consumer API surface and the architectural design. Keep in mind; it’s certainly acceptable to refactor your architectural design and consumer API based on the technical design.

An apparent and even larger obstacle I’ve noticed lately is the inability for an SDE to make the jump from procedure (function)-oriented design concepts to that of object-oriented design while keeping an eye to efficiency in terms computational complexity and network round-trips. The devil is in the details. In my opinion, one can’t be an effective architect without being an even more effective SDE; period. The implementation details do change the architecture.

In general, people tend to migrate toward what makes them feel good. Rework doesn’t feel good; no one enjoys it. But, if that was true—if you truly don’t enjoy rework—then why would you not elegantly architect, design, and develop your code initially? Why do you make more work for yourself? Elegance as a foundational element is difficult. More often than not, SDEs take the easy way out because they equate efficiency to speed of completion. I’m not advocating “analysis paralysis” but instead a balanced design. Deadlines must be met. Deadlines should not be met at the expense of elegance.

It’s your canvas.

posted by Michael Primeaux | 2 Comments
Filed Under:

XRing DHT and Windows Communication Foundation (WCF)

A few weeks ago I provided a brief history of the P2P landscape in which I mentioned several Distributed Hash Table (DHT) implementations. The latest XRing DHT publication from Microsoft Research is dated September 2004. Substantial work has been done since that publication. To my knowledge, the only XRing DHT implementation exists within the Microsoft Research group and is not publicly available.

The XRing design is quite interesting and, unlike most DHT algorithms, isn't dominated by a minimalist approach and instead focuses on deployment situations where the churn rate (node join and leave rate) is low or the system is of moderate size (between 1 and approximately 1 million nodes). The design of XRing uses a layered routing scheme to deliver O(logN) routing at worse case with a usual 1-hop anywhere route (2 hops for a million nodes), which is facilitated by the Finger Table and Soft-State Routing Table (SSRT), respectively. The third routing table is the Leaf Set, which contains 2L+1 entries, where L is the number of nodes to probe on either side of the home node plus the home node.

Membership in an XRing DHT is guaranteed by a weak and eventual membership protocol, which employs a special anti-entropy protocol that allows the system to coalesce; equilibrium is eventually reached. The membership and routing layer is where all the fun happens. For my implementation, a node may join an existing XRing either (a) by sending a one-way multicast request or (b) by sending a point-to-point request to an existing member. For (a), one common pattern is to send the request over a multicast channel and the response back over a point-to-point binding, which map wonderfully into WCF.

The multicast channel is realized by using the NetPeerTcpBinding class and the point-to-point channel by the NetTcpBinding class.

[ServiceContract(Namespace = "http://ws.i-dynamics-corporation.com/P2P/Dht/XRing")]
public interface IXRingDhtDuplexMembership
{
   [OperationContract]
   void Join(DhtNodeId id);

   [OperationContract]
   void Leave(DhtNodeId id);
}

[ServiceContract(Namespace = "http://ws.i-dynamics-corporation.com/P2P/Dht/XRing", CallbackContract = typeof(IXRingDhtMulticastMembership))]
public interface IXRingDhtMulticastMembership
{
   [OperationContract(IsOneWay = true)]
   void MulticastJoin(DhtNodeId id);

   [OperationContract(IsOneWay = true)]
   void MulticastLeave(DhtNodeId id);
}

An important design goal for any DHT implementation is that of ring simulation. Therefore, it's important to allow a single process to support multiple nodes. Unfortunately, this meant I couldn't use WCF configuration files but instead had to programmatically create the contract, binding, and endpoint address for each node. This took a bit of work to accomplish due to two primary reasons:

  1. The current documentation is not in-sync with the bits.
  2. The WCF samples use configuration-defined bindings, contracts, and endpoints.

Incidentally, working with the WCF configuration files (due to bullet 1) reminded me of a quote from David Hansson that I read on Box's blog but with a minor modification:

WCF configuration files feel more like the doorknob to the gates of hell. In itself, a doorknob is hardly evil. But once you turn... :)

Fortunately (for me at least), Lutz Roeder's .NET Reflector filled in the gaps. After some caffeine, a few frustrating moments, and questioning why I even started down this path, I found myself with a working prototype.

If you run Windows 2003 R2 as the operating system on my primary development machine (as I do), then you currently have one more obstable to overcome. Per the WCF peer channel team, the Peer Name Resolution Protocol (PNRP) service is currently available only on Windows XP (SP1 + networking pack installed), Windows XP (SP2), Windows Vista, and Windows XP Professional (64-bit) [URI]. Fortunately, you are able to leverage the CustomPeerResolver sample, which can be found in the "PeerChannel\CustomPeerResolver" folder of the WinFX February CTP.

The following code fragment illustrates how to programmatically reference the custom peer resolver:

NetPeerTcpBinding binding = new NetPeerTcpBinding();
binding.Port = 4242;
binding.Security.Mode = SecurityMode.None;

//
// If the default PNRP service is not available then
// fall back to a custom peer resolver.
//
if (!NetPeerTcpBinding.IsPnrpAvailable)
{
   binding.Resolver.Custom.Address = 
      new EndpointAddress("net.tcp://resolverUri");
   binding.Resolver.Custom.Binding = 
      new NetTcpBinding(SecurityMode.None, true);
   binding.Resolver.Custom.Resolver = 
      new CustomPeerResolver();
   binding.Resolver.Mode = PeerResolverMode.Custom;
}

Overall, I'm quite impressed with the flexibility of WCF and the usability that seemingly went into the consumer API surface. Hopefully, the documentation catches up to the bits.

"Rock On" Instant Messenger Emoticon

Ok, so it's not too thought provoking but so what :-)  Check out the instant messenger emoticon attachment (below). Way too funny!

To add it to Microsoft IM (version 7.5.x at least):

  • Save the image, which is currently named "(ro).gif".
  • Open an IM window.
  • Click on the emoticon drop down list.
  • Click "more..."
  • Click the "Create..." button.
  • Locate the image and map the letter combination.

Enjoy.

posted by Michael Primeaux | 0 Comments
Filed Under:
Attachment(s): (ro).zip
More Posts Next page »