The Essence of Software Architecture

by kevin 5/11/2008 5:00:00 PM

I stumbled on a quote today by Antoine de Saint-Exupéry, the famous aviator and author of The Little Prince which I think describes good software architecture. Here's the quote:

A designer knows he has achieved perfection not when there is
nothing left to add, but when there is nothing left to take away.

Software architecture, in my experience, is about having a passion for obscuring complexity in favor of simplicity. Apple knows this at the macro level, for sure. I wonder if they really know that down to the smallest turtle that they can perceive. I don't think so. But they are further along than most. Juval Löwy often says, "For the beginning software architect, there are many choices. For the master, there are but few." This quote expresses the same sentiment as de Saint-Exupéry's thought. Perfection in the design of anything can only be achieved when the designer is willing to strip the thing to it's essentials. Then the creation becomes a tool that will resonate with the craftsman that uses it.

At the risk of making this look like an IDesign plug, Michele Leroux Bustamante says in her Learning WCF book, "Little SOA enables Big SOA." Great book, by the way. She could not be more on target. It really is turtles all the way down. Elegance in software design at any level begets more elegance. There are few right ways of doing things and when you do them consistently at all levels of your design, you can approach perfection.

Is perfect software really achievable? Perhaps. I know that when I wrote scads of assembly language code decades ago, I achieved absolute perfection for one or two algorithms. But nowadays, I think that many people use SOA as a crutch, a tool for hiding imperfections in their designs. We wouldn't scramble to building façades all the time if this weren't true. WCF helps because it strips away so much of what Juval calls "the plumbing", allowing for a level of abstraction in the delivery of information that was previously difficult to attain. It's an exciting time to be a software architect.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Architecture | Book Recommendations | Software Development | WCF

Flow Diagram for Silverlight Cross-Domain Policy Checks

by kevin 5/9/2008 10:48:00 AM

Last week, I blogged about Overcoming Cross-Domain Issues in Silverlight which recommended the use of a proxy service for making cross-domain calls. I'll be writing more about the security considerations of using that method in the coming days. For now, here's a flow diagram I created to better understand what the WebClient class in Silverlight is doing when making cross-domain calls. If you see any problems with my interpretation, I invite corrections by commenting on this blog post.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Silverlight

My Google Notebooks Go Public

by kevin 5/7/2008 9:22:00 AM
I have begun to organize my links, notes and sample code using Google Notebook. The first one that I've made publicly available is my Silverlight and WPF notebook. You can access all of the notebooks that I make public from here. I'll be adding more every day.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General

Silverlight Tip - Loading XAML Fragments Dynamically

by kevin 5/5/2008 10:32:00 AM

Being able to instantiate XAML controls from text fragments at runtime is very convenient, especially when you have a lot of properties to set. Using a block of text to hydrate a new XAML control is often a much more compact and efficient alternative to dozens of lines of code that would be required in C#, for example. However, when you load XAML text up at runtime in Silverlight 2, there are a couple of things of which you should be wary. First of all, the string containing the XAML fragment must contain only one root element. And that node must include a namespace reference to http://schemas.microsoft.com/client/2007. If you forget to reference that namespace, you'll get a XamlParseException when you attempt to load the XAML.  As an example, look at the following C# code which creates a TextBlock object:

In this code, the XAML text fragment contains the necessary namespace reference and an attribute setting the Text property to "Hello world!" The XamlReader class in the System.Windows.Markup namespace is then used to load up the XAML text using the Load method which returns a System.Object. Since the root node of the XAML text was a <TextBlock/>, the resultant object is actually an instance of the System.Windows.Controls.TextBlock type. So the cast to that type succeeds, yielding a disconnected TextBlock.

I say that the new TextBlock is "disconnected" because just after it is created, it is not associated with any other UIElement. Controls are not really usable until they are connected to a canvas and ultimately to an application. Most XAML controls have a property called Children which is a UIElementCollection. That collection's Add method can be use to attach the new TextBlock and render it. Of course, casting the result of the Load method to a TextBlock isn't necessary. But to be attached via the UIElementCollection.Add method, you'll have to cast the Load result to the UIElement base class at a minimum.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

C# | Silverlight

Overcoming Cross-Domain Issues in Silverlight

by kevin 5/2/2008 9:24:00 AM

One of the easiest ways to deal with cross-domain issues in Silverlight is to write a WCF service that acts as a proxy for the calls you want to make. For example, in my Twitter control, I want to be able to load XML from the RESTful Twitter service at the following address:

http://twitter.com/statuses/user_timeline/wkh.xml

However, when invoking the RESTful Twitter service from a WebClient in Silverlight, I get the dreaded "Download Failure" error when I call DownloadStringAsync. This is because the Twitter.com site doesn't have an entry in its clientaccesspolicy.xml file for my test domain. And that's never going to happen, right? To solve this problem, consider exposing a WCF service from the site from which the Silverlight control emanated. The WebClient class can be used on the server side without the same cross-domain control being applied by Twitter.com. For the example outlined above, I called my service TwitterProxy. The ITwitterProxy couldn't be simpler:

using System.ServiceModel;

[ServiceContract( Namespace = "urn:gotnet:biz:Services:2008:05" )]
public interface ITwitterProxy
{
    [OperationContract]
    string GetUserTimeline( string user, int count );
}

The service implementation is also quite simple. It uses the WebClient just as I would from Silverlight (if I could):

using System;
using System.Net;

public class TwitterProxy : ITwitterProxy
{
    public string GetUserTimeline(string user, int count)
    {
        user = (user != null) ? user.Trim() : String.Empty;
        count = (count < 1) ? 1 : (count > 20) ? 20 : count;
        WebClient client = new WebClient();
        Uri uri = new Uri( String.Format("http://twitter.com/statuses" +
            "/user_timeline/{0}.xml?count={1}", user, count ) );
        return client.DownloadString(uri);
    }
}

Expose an SVC file on the server to host the new service. In this example, the URL to invoke the new service is:

http://localhost/WebSite/TwitterProxy.svc

So, to invoke this service from Silverlight, add a proxy to the Silverlight control, using the service address and invoke it like this:

private void OnLayoutRootLoaded(object sender, RoutedEventArgs e)
{
    TwitterProxyClient client = new TwitterProxyClient(
        new BasicHttpBinding(), new EndpointAddress(
        "http://localhost/Website/TwitterProxy.svc"));
    client.GetUserTimelineCompleted += OnGetUserTimelineCompleted;
    client.GetUserTimelineAsync("wkh", 10);
}

void OnGetUserTimelineCompleted(object sender,
    GetUserTimelineCompletedEventArgs e)
{
    // open a Twitter Status dialog, passing the XML string
    NavigationHelper.Navigate(new FadeTransition(
        TimeSpan.FromMilliseconds(750.0d)), new Status(e.Result));
}

The dreaded "Download failure" error is gone. Nice. of course, the potentially bad side effect of this technique is that all of the Twitter service traffic will be flowing through the server that's hosting the TwitterProxy. Think about that before using this technique.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Architecture | Silverlight | WCF

Silverlight Richmond Code Camp Presentation

by kevin 4/26/2008 1:02:00 PM

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

C# | DLR | IronPython | Richmond | Silverlight | Software Development | User Group | Visual Studio

Look Ma! No Proxy! Richmond Code Camp Presentation and Code

by kevin 4/26/2008 9:01:00 AM

These are the slides and source code that I used in my Richmond Code Camp 2008.1 presentation called "Look Ma! No Proxy!". This presentation concerns the problems related to proxy generation for traditional web services development. In this presentation, I propose a model for the future where proxies are no longer needed, at least not pre-built proxies as we use today. A bit of dynamic code generation, some C# client code and a bit of IronPython to glue things together. Mmm, mmm, good!

Look Ma No Proxy by Kevin Hazzard.pptx (197.46 kb)

ProxyGen20080426.zip (818.56 kb)

Strange Behavior for Silverlight's HtmlPage.Window.Navigate Method

by kevin 4/21/2008 2:41:00 PM

I found some odd behavior today with respect to the way that Silverlight's HtmlPage.Window.Navigate method works. If a page is cacheable by the client, calling HtmlPage.Window.Navigate will always choose to load the cached version of the page. With IE7, it does this without attempting a cache update check. Normally, IE7 will emit a cache update check for cached content, expecting an HTTP 304 response code, meaning that the cached version is up-to-date. However, when HtmlPage.Window.Navigate references a cached resource, it honors the cached content without checking for an update. This is how Firefox normally behaves and it threw me for a loop as a result. Check out the following code.

// this one will used a cached version always
HtmlPage.Window.Navigate(new Uri("http://server/targetpage.aspx"));
// this one will ignore the cache
HtmlPage.Window.Eval("window.location.href='http://server/targetpage.aspx'");

In that code, the first method call will cause the browser to use a cached page. This is true even if the cache-control was set to private, which is the default. It also does not check for a cache update as IE7 normally does. The second call injects JavaScript into the hosting page for execution. That one seems to force the browser to ignore the cache where the target page was received with the private cache-control policy. I don't know if this is a bug but I know it's not documented that way. I should mention that this happens on Silverlight 2 Beta 1.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

C# | Debugging | Silverlight

Book Recommendation for Here Comes Everybody by Clay Shirky

by kevin 4/20/2008 12:39:00 PM

Here Comes Everybody by Clay ShirkyI am about halfway through Clay Shirky's latest book called Here Comes Everybody: The Power of Organizing without Organizations. I've been tracking his writings since I read through Joel Spolsky's compilation called The Best Software Writing I. I don't know Clay Shirky personally but I'm going to refer to him as Clay in this post because it seems a bit less creepy than referring to him as Mr. Shirky.

This book is very good so far. The basic premise is that when "mass amatuerization" occurs, professions that had been previously created to solve problems often vanish with plenty of misunderstanding and resistence. As a software architect, I am sympathetic to the shift that social computing brings to my world-view. In fact, Clay references Tim O'Reilly's article entitled "The Architecture of Participation" in the book. There's the A-word. That's my job, right? I'm the software architect.

But as Clay and Tim point out, the architecture of a thing is as much defined by what people do in response to a problem as it is defined by what we, the professionals, decide will be done about it. How many times have you designed a great piece of software only to find out that the users are still tracking artifacts in your system using a spreadsheet? They're mailing the spreadsheets to one another as an ad hoc version control system. It's maddending, right? But this common example shows that when the cost of creating your own solution to a problem falls below what you would pay professionals to build it as you conceive it, the professional's job evaporates or becomes marginalized. Clay draws some relevant analogies in the book including how modern print newspapers cannot compete with bloggers and how Bible scribes couldn't compete after Gutenberg invented the printing press either.

While modern newspapers are struggling in the wake of the mass amatuerization of written words, newspaper owners should be looking to the other analogy that Clay wrote about. While it's true that the Bible scribes were essentially wiped out by the mass amatuerization afforded by the printing press, what replaced them eventually evolved into a wide range of new professions. Of course, modern journalism and all of the related newspaper professions are counted among them. What Gutenberg's invention did was to expose that the need for printed words was much larger than the output that the professionals of the period could produce. Now, the same thing is happening to the newspapers. The once bifurcation or trifurcation (is that a real word) of the readership has been exposed as a polyfurcation (now, I know that's one's not real) of interests and opinions.

I don't take the paper anymore. I don't watch the morning or evening news, local or national. I don't even listen to the local radio stations. I just don't like their bent, if you know what I mean. But I do read a few blogs and listen to a few podcasts every day. And I will occasionally pop over to CNN, Fox News or the BBC websites to get their spin on a subject. The point is that my lifestyle as an information consumer has evolved into a sort of digital mashup of daily activities rather than committing to the Post or the Times as my single source of information. Of course, modern newspapers are not single sources of information. They draw content from dozens of sources and hundreds of writers every day. And that may very well be what allows them to survive in the blogosphere of the future. The ability of the traditional newspapers to organize and deliver those mashups for me may create a whole new profession of content aggregators (not editors) who know me, know what I like, know what I find provocative, funny, call-to-action, etc.

What about software development? What can we learn and how can we adapt early to the coming changes? Google Apps, the Facebook Platform, Amazon Web Services and dozens of other APIs are emerging nowadays that allow average users to build usable software on their own. Should we be as worried as the Bible scribes should have been in the wake of movable type systems? Maybe. But we have many advantages that the scribes didn't have. Among them, thanks to print, broadcast and Internet media, we can perceive the threat more quickly than it will spread, before it can mature into a set of new, competing professions. Secondly, mass amatuerization is creating a lot of really bad software today. That's not to say that there isn't a lot of bad software out there already. It's just that when we look closely at the fundamental problems that created our profession, there are some obstacles that Google, Facebook and Amazon will be hard pressed to handle. For example, how are exceptions reported and managed across a Franken-app (an application whose body parts come from different vendors)? Certainly, Dr. Frankenstein realized that this hand needs to communicate with that arm. So I had better get the nerve endings just right. The players in the mass amatuerization of software today aren't thinking that way... yet. And what happens when the network cable is disconnected? Adobe Air is answering that latter question fairly well but Adobe's platform competes with Google's which competes with Amazon's, et cetera, et cetera. While they are all too busy competing with one another to form a unified front, we have a little time to plan.

I think the best thing that software professionals can and should be doing today is introspecting about what Clay calls the scarcities that create a profession. In the print media analogies so far, there are always those who have emerged to define the new scarcities that exist in the light of new paradigms that pop up. Those people become leaders in the new space because they have expended the necessary energy to define, provide for or in some cases to create the scarcity that makes a new profession valuable to consumers. What scarcities exist in the emerging software development models that will translate into positions of leadership in this next century? I have some ideas on this subject which I will be writing about soon. Until then, read Clay's book and let me know what you think.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Architecture | Book Recommendations

My Visual Studio Fonts and Colors

by kevin 4/18/2008 2:07:00 PM

I do a lot of demos: training, teaching, mentoring, etc. I get asked about my Visual Studio fonts and colors quite often. I use Tomas Restrepo's Nightingale scheme for Visual Studio 2008. Here's the link to his VS Color Scheme page. Scroll down to check out Nightingale and other nice schemes he's made available. I like the contrast of Nightingale and how colorful it is. I use a different font though called DejaVuSans Mono. It's clean and compact yet bold.

Here's a screen shot of the Nightingale theme with the DejaVuSans Mono font that I use. By the way, setting the vertical guidelines that you see in the image below is done through a registry hack. See the REG script below if you're interested.

Save the text below as a REG file, then right-click on the file and select Merge to update Visual Studio 2008 to show gridlines at positions 4, 8 and 80. Of course, if you want vertical guides at other positions, change the Guides string to your liking. Visual Studio 2005 respects this setting, too. Just change 9.0 to 8.0 in the path. Here's the REG merge script:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Text Editor]
"Guides"="RGB(128,128,128) 4 8 80"

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Fun | General | Software Development | Visual Studio

Powered by BlogEngine.NET 1.3.1.0
Theme by Mads Kristensen

About W. Kevin Hazzard

Name of author Welcome. I am a software architect living in Richmond, Virginia USA. I teach software development courses at a local college. Here, you'll find my musings about SOA and other technology trends.

E-mail me Send mail


Calendar

<<  May 2008  >>
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sign in