|
|
Adventures in Architecture
-
Some metrics that we captured on my project: (I think the numbers speak for themselves) | Operation | VS 2005 | VS 2008 | % Improvement | | Start the IDE | 00:30 | 00:09 | 70% | | Load solution | 03:45 | 00:45 | 80% | | Get Latest (no changes) | 00:13 | 00:05 | 62% | | Rebuild solution | 02:21 | 01:58 | 16% | | Run all tests | 05:29 | 03:44 | 32% | | Start the application | 00:19 | 00:18 | 5% |
FYI our solution has 33 projects in it (including a database project, a web application project, numerous DLLs, an EXE and a WiX installer) and there are almost 1,600 unit and integration tests.
|
-
-
Strength, utility and beauty. Here we will be exploring a number of the traditional “ilities” of software architecture and seeing how they can be related to these three architectural qualities. These three qualities have been around for quite a while, under their Latin names of firmitas, utilitas and venustas, and were first written about by Vitruvius. Now architecture is always created with the intention of supporting something, e.g. an application (in the case of application architecture) or a business (in the case of enterprise architecture). For brevity, I’ll refer to “the thing which the architecture supports” as “the system”, although I believe that my points here relate to all types of software architecture. Utilitas, or Utility: Functional and behavioural aspects of the architecture The architecture needs to guarantee that the system can perform operations in a certain manner. Architectural aspects which achieve this are: · Availability – expected levels of uptime that the architecture can provide · Auditability – keeping a log of changes and operations within the system. · Correctness and verifiability – sometimes operations within the system can be externally verified. The architecture needs to support and pass such verification. · Environmental compatibility – the architecture needs to fit into its environment, e.g. there may be a high latency network which needs to be considered · Performance – how quickly operations can be performed · Security and confidentiality – authentication and authorisation · Transactionality – the architecture needs to ensure that operations are atomic A person can only really be called an architect if they can design an architecture that works, i.e. displays these aspects. Firmitas, or Strength: Non-functional aspects of the architecture In addition to supporting the operations of the system, there are a number of further considerations for architecture: · Adaptability – how well the architecture can cope to evolving situations without being changed · Efficiency – how well does the architecture use its resources such as CPU, memory, bandwidth, etc · Extensibility – how easily can the architecture be extended and changed · Maintainability – this is really just a combination of extensibility and understandability. If an architecture is easy to understand and easy to change, then it is easy to maintain. · Recoverability – is it possible to reconstitute the state of the system after a disaster · Reliability – how stable is the architecture under normal circumstances · Resiliance – how stable is the architecture under abnormal circumstances · Scalability – can the throughput of the system be increased without requiring changes · Understandability – how easy is it to comprehend the architecture Really good architects manage to incorporate these aspects into architecture they design. Venustas, or Beauty: Aesthetic aspects of the architecture Beauty, as a quality, is practically impossible to define objectively. “Beauty is in the eye of the beholder”, as the saying goes. However, you do know beauty when you see it. Here are some points which I think contribute to making architecture beautiful: · Conceptual integrity – sometimes called the principle of least surprise, there should be an underlying theme or vision that unifies the design of the architecture at all levels · Elegance – closely related to simplicity, elegance implies a certain understated effortlessness · Simplicity – an architecture should be as simple as possible, but not simplistic An architect that can incorporate these aspects into a design that also displays utility and strength, is really one of the greats. And so what? And so we have a bit of a framework for inspecting the quality of architecture. I don’t regard all of these aspects as quantitative, but at least we can discuss architecture in qualitative terms. In my next post, I’ll be discussing some of the specific considerations of iterative development of software and how these points here should influence that process.
|
-
Lately I've been investigating software architecture with regard to how it can impact on an agile development project. I recently read (here) a very short list that resonated really powerfully with me and describes key architectural virtues (explanations are mine): - Strength - reliable, secure, resilient to change
- Utility - must deliver either business value or (more likely) developer productivity
- Beauty - easy to understand and communicate, clean design, minimal
It turns out that these ideas have been around for quite a while, under their Latin names of firmitas, utilitas and venustas. I hope to produce a series of blog posts detailing my thoughts and expanding on some of these points, including why I think this question is especially relevant to iterative development.
|
-
The MIX07 Keynote includes a brief screen capture from the Daily Mail eReader and reminded me that I had meant to blog about the speech synthesis portion of the app. It's something which many users might not have seen, because it's only available on Windows Vista. Vista includes the Speech API (SAPI) version 5.3 which provides a text-to-speech (TTS) engine which is greatly superior to SAPI 5.2 which shipped with Windows XP. 
How it looks The way the UI works is pretty straightforward - it's meant to mimic an autocue. So a user will trigger the functionality and the window you see on the right will appear. As the user's computer begins speaking the news story, the text will slowly scroll up. The word currently being spoken will always be bold and will always appear in the letterbox. I'm presonally a bit tickled that this bit of UI made it into Ray Ozzie's keynote presentation (even if it was only for about a quarter of a second) because I developed this part of the eReader and wrote this UI. Getting SAPI to produce speech The TTS functionality is actually quite easy to kick off. All it takes is a call to the appropriate function, passing in a string holding the text to be read, and SAPI will begin to speak. Specifically, .Net 3.0 provides a System.Speech assembly which does all the hard work for you. This assembly includes the class System.Speech.Synthesis.SpeechSynthesizer which has a method public void Speak(string textToSpeak). This is easy to use if all you want is text-to-speech. The problem is that this is a synchronous call. So the call will block until the speech rendering is complete. To get around this, the SpeechSynthesizer class also includes a method SpeakAsync. This does pretty much what you'd expect and runs the TTS activity on a background thread. Getting updated with TTS progress Now the SpeechSynthesizer class even provides some helpful events relating to the progress of the speech rendering. However, it turns out that the SAPI libraries regard these events as sort of incidental to their main job - i.e. they will raise the events when they can. So there is every possibility that these events will occur some time after the actual speech rendering of a word (or phoneme, etc) has started. The SAPI library also seems to stop raising the events altogether, if the event handlers are consuming too much time. This was probably a design decision made by Microsoft that the quality of the speech shouldn't be affected by calls to user code. This last point means that you need to be very careful how you write your event handlers. I suspect that a fair amount of time is consumed with the transition from the unmanaged SAPI libraries back into the System.Speech assembly, which doesn't leave much time for your C# code to do anything useful. It certainly doesn't leave enough time to update a XAML UI. The initial approach I used would update the UI with about 2 or 3 words and then UI updating would cease altogether. The solution was (a) to be very, very careful to write efficient code; (b) use the Output window for debug info rather than trying to break into the running code; and (c) make good use of asynchronous delegates. The SAPI events are called on a background thread, which means that a Dispatcher.Invoke call is needed before code can update the UI at all. So the simplest solution was to replace this with a Dispatcher.BeginInvoke call which then updated the UI asynchronously to the event handler. Constructing the UI It took a little bit of trial and error to get a XAML UI that could efficiently update without continually doing a lot of layout work. Ironically, the grey letterbox with its opacity and the opacity gradient of the textual content were the easy bits! And getting a thick window border of Vista glass was also pretty trivial. The part which took some effort was working out that to display the content I needed to use a ScrollViewer control with three separate Run elements - one for the text which had been read, one for the text being read and one for the text which is still to be read. The updates from the TTS engine can then simply be translated into shuffling characters between the various Run elements. Getting the highlighted word to stay in the letterbox also took some trial and error. The solution lay in the following line of code: Rect screenPosition = CurrentlyReadingRun.ContentStart.GetCharacterRect(LogicalDirection.Forward); This gave me the screen co-ordinates of the currently bold word, which I then used like so: _scrollViewer.ScrollToVerticalOffset(screenPosition.Top + _scrollViewer.VerticalOffset - _paddingHeight);
|
-
If you attempt to start Windows SharePoint Services Search service and receive the following message: 
Try modifying the Log On Identity of the service. In my case, it was setup to log on as "Local Service". After I changed this to "Local System", the service started without any errors. Note that this error message was received from the Services Administrative Tool. The WSS web front-end simply hung when attempting to start the WSS Search service.
|
-
In my new project, we're using Team Foundation Server (TFS) as our source code repository and also as our continuous integration (CI) engine. The CI aspect is handled neatly by Automaton which leaves me to setup the build process (or the Team Build Type, as it is referred to in TFS parlance). Automated unit tests form the backbone of any decent CI process. It wasn't entirely straightforward to set these up, so I thought I'd share my experience with the community. It's worth noting that we are using MS Test for unit tests, i.e. the unit tests built into Visual Studio Team System (VSTS), and not Nunit. I expected that this would simplify the build process since I wouldn't be integrating Nunit results back into the build report. This has been the case, but there are a few gotchas. As stated on MSDN "How to setup a build server": In order to run tests during build, Team Edition for Testers must be installed on the build computer. In order to run unit testing, code coverage or code analysis, Team Edition for Developers must be installed on the build computer.
I find it quite suprising that I need a Visual Studio installation on the server, but the docs are pretty clear on this point. Are there any licence implications of this? The Visual Studio 2005 Team System licensing white paper states: As part of the build process, Team Foundation Server may run quality tests and/or analysis on the precompiled or compiled code. These tests rely on functionality found within Team System client products, typically within the Team Edition for Software Developers or Team Edition for Software Testers products. These products may be installed on the build machine by licensed users of those products, as long as they are not directly used by any individuals who are not licensed for those products.
In short, licencing is not a problem. Now unit tests really are just a type of test, so I'm not entirely clear whether I need VS TE for Testers or VS TE for Developers. I'm planning to do some automated system testing and so I've installed the relevant bits from both editions on our build server. I'd guess that you really only need VS TE for Developers. So you would think that now our build server ought to be fully setup and we now ought to be able to execute unit tests. Well you can, but only if they are part of a test list. VSTS groups tests into lists and you need to specify (in the TfsBuild.proj file) the name of a test list containing unit tests to execute. This is clear in the TfsBuild.proj file, where you need: <MetaDataFile Include="$(SolutionRoot)\Main\Src\Solutions\Server1.vsmdi"> <TestList>List of Unit Tests</TestList> </MetaDataFile> I don't think this is good enough. It's enough of a problem for me to get developers to write unit tests. I don't want to have to then get hold of a VS TE for Testers installation (which is the edition that allows you to edit test lists) and then add these unit tests into the appropriate list to get executed. And it seems that I'm not the only one. Enough people have complained about this that Buck Hodges (the dev lead for Team Build) has posted some modifications to TFS that allow you to execute all unit tests in a DLL. These take the form of a DLL containing an updated MS Build task and a revised Microsoft.TeamFoundations.Build.targets file (plus some docs). Both of these files need to be installed on your build server. Having done that, you can get rid of the MetaDataFile element in TfsBuild.proj and replice it with: <TestContainerInOutput Include="%2a%2a\%2a.UnitTests.dll" /> This (rather odd) syntax translates into **\*.UnitTests.dll. In other words, you can just specify which DLLs contain your unit tests and the Team Build will now execute them all.
|
-
On my current project, we create SharePoint sites in response to calls to a particular webservice and there is one site per domain entity. In this webservice, there is a certain amount of customisation of the site homepage which needs to be done. In particular, we have an RSS Aggregator web part and we want this to point to a different URL for each site. I couldn't find anywhere on the web that had a sample of doing this, so I thought I'd blog the solution: // Reconfigure the RSS Reader to query against the company name SPLimitedWebPartManager WPMgr = NewSite.GetLimitedWebPartManager("default.aspx", PersonalizationScope.Shared); foreach (WebPart wp in WPMgr.WebParts) { RSSAggregatorWebPart RssPart = wp as RSSAggregatorWebPart; if (RssPart != null) { string QueryString = HttpContext.Current.Server.UrlEncode(person.Company); RssPart.FeedUrl = RssPart.FeedUrl.Replace("company", QueryString); WPMgr.SaveChanges(RssPart); } } Clearly NewSite and person.Company are defined higher up in my code, but you can do whatever you want with the FeedUrl property. To get this to work you need to have references to: System.Web [for System.Web.WebPart and System.Web.UI.WebControls.WebParts.PersonalizationScope] Microsoft.SharePoint [for Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager] Microsoft.SharePoint.Portal [for Microsoft.SharePoint.Portal.WebControls.RSSAggregatorWebPart]
The list above also shows which namespaces I import through using declarations. PS. Apologies to anyone who's disappointed at the lack of WPF/E content in my latest posts. I hope to play some more with that technology soon, but there'll probably be a pre-dominance of MOSS posts in the coming months. If you are really uninterested in MOSS posts, then make sure you only subscribe to a tagged feed and not to the main one.
|
-
I'm doing some work with Microsoft Office SharePoint Server (MOSS) and I recently discovered that with MOSS (and WSS v3) the administration utility is extensible. Stsadm.exe is something that I have a love-hate relationship with, but it's interesting that it's commands work on a provider model. Tony Bierman has posted all the details on the SharePoint Solutions Blog and Andrew Connell has some real-world examples of custom commands. I can see these custom commands being really useful in many MOSS deployment scenarios - anyone who has ever tried to write an MSI or a batch file deployment for a SharePoint site will know how invaluable stsadm.exe really is. Of course it does raise a bootstrapping issue, in that you have to get your custom commands deployed before you can use them for the rest of your deployment. However, this shouldn't be an insurmountable problem.
|
-
Apologies to my readers, but my blog has a been little quiet of late. Hopefully I'll be able to share the reasons for this with everyone soon! In the meantime, here's a WPF/E sample I've been meaning to post for some time. Essentially it's a button that looks like it's made of glass. The button pulsates when you hover over it and glows when it's pressed. A picture is worth a thousand words so here it is: 
I couldn't get a reasonable screen capture of the hover-over effect, so you'll have to take my word for it (or download and run the attached files). There are a number of XAML elements which go into making up the button. They are clearly commented in the XAML but the list is as follows: - Drop-shadow: an ellipse with a radial gradient of black fading to tranparent
- Button surround: a white ellipse slightly bigger than the green one
- Black button background: only visible round the edges of the green when the button is pressed
- Main button colour: the green (or whatever color you want) of the button. This ellipse is clipped to its initial outline, thus allowing us to move the ellipse slightly for the button press without it overlapping the button surround
- Top glow: an ellipse with a linear gradient background of white (at the top) fading to transparent. Smaller than the main button colour and positioned so that the tops are the same
- Bottom glow: an ellipse the same size as the main button colour but with a linear gradient background of white (at the bottom) fading to transparent. This is also clipped as per the main button colour.
- Hover-over glow: an ellipse the same size as the main button colour with a radial gradient background of white (at the centre of the ellipse) fading to transparent. This is initially transparent.
- Transparent element for catching mouse events: on top of all of this is a transparent ellipse the same size as the white button surround for catching MouseEnter, MouseLeave, MouseLeftButtonDown and MouseLeftButtonUp events. This element also contains the Storyboard for the pulsating hover-over effect (although this could be in any XAML element).
Who would've thought a button could be so complex? I am quite proud of the fact that the actual button colour only appears once in all of the above XAML elements. So it's a single change if you fancy a red button rather than a green one. Now all of this is in a canvas and the Loaded event of the canvas calls a JavaScript function. The other mouse handlers are attached through script. The script itself is pretty straightforward, but a bit fiddly in places. The MouseEnter and MouseLeave event handlers just call Begin() and Stop() methods on the Storyboard. The MouseLeftButtonDown handler has to adjust the position of a number of elements, as well as moving the clipping geometry on a couple of elements so that the clip geometry doesn't move with the element. The MouseLeftButtonUp handler reverses these effects. If you want to make this into a proper button (i.e. one that actually does something) then you need to add some script into the MouseLeftButtonUp event handler. This script could call other script (for client-side actions), make an ASP.Net postback (for server-side actions), trigger an AJAX call (for AJAX apps) or doing anything else you fancy. Issues I hit: It's not possible to use the RoutedEvent on an EventTrigger to catch anything other than a Loaded event (confirmed by Joe Stegman in the forums). This is why I need script to call the Begin and Stop methods on my Storyboard. As a result of this, animations tend to start running as soon as everything is loaded. This is why one of the first things I do is to stop the animation. Future enhancements: It's fiddly to put more than one of these on a Canvas. They can share the script, but not the XAML. The way forward here may be for the script to create the XAML elements, but this sort of code always looks ugly. It's also a bit poor that you need to hack an event handler to get the button to do anything. It would be much better to be able to pass a JavaScript function into the object constructor and have this called appropriately. As ever, it would be great to hear from anyone who uses this code. [PS. I had wanted to post this as a sample you could run, but our blogging software is preventing me from doing this. Sorry but you'll have to download and run this in order to see it in action. As I mentioned previously, IE users need to ensure that load this via HTTP and not directly from the filesystem.]
|
-
There are two main ways to develop WPF/E within Visual Studio 2005 - one is to edit the XAML in the XML Editor, and the other is to use Cider, the XAML WPF designer. There are pros and cons to each approach, and some configuration for each. Using Cider
Cider is the Visual Studio designer for WPF and XAML and is shown to the right. It is available in CTP (there are no plans for an RTM version for VS 2005). You can edit in a design view or a XAML view and they are synchronised. This sounds great. The only problem is that you have to be very careful to limit yourself to the WPF/E subset of XAML. Cider targets the full set of XAML and WPF, so you may find that you end up developing something that doesn't work in WPF/E. If you've developed anything with WPF/E, you'll know that the runtime errors are not particularly informative and so you might not want to go down this route. Also, for Cider to work your XAML document needs to be in the namespace http://schemas.microsoft.com/winfx/2006/xaml/presentation. This isn't the WPF/E namespace. Using the XML Editor
I was very disappointed when I'd installed the WPF/E SDK and Visual Studio didn't give me Intellisense on my WPF/E XAML. It turns out that this isn't very difficult to enable. All you have to do is copy the file "wpfe.xsd" from the WPF/E SDK Schema directory into the Visual Studio schema directory. In my case, I copied the file from C:\Program Files\Microsoft SDKs\WPFE\Help\XSD to C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas
These are the default directories so your system is likely to be the same. It's worth noting that the default namespace on your XAML document needs to be http://schemas.microsoft.com/client/2007 for Visual Studio to associate the schema. This is the proper WPF/E namespace. Getting Visual Studio to Use the XML Editor If you have installed Cider, you will find that Visual Studio wants to open all XAML documents using this and not using the XML editor. If you do want to use the XML Editor, you need to inform Visual Studio of this. To open XAML files in the XML editor by default you can go to the Tools / Options window and under Text Editor / File Extensions set .xaml files to open in the XML Editor. A screenshot of this is below. If you then want to open a XAML file in Cider, you will need to right-click from the Solution Explorer and choose "Open With ...". And this is the other way of getting XAML files to open in the XML Editor (i.e. without modifying your options). You can always right-click on your XAML file and go through the "Open With ..." dialog. Personally, I prefer just to double-click. 
|
-
So you've installed the WPF/E runtime and played with a few samples. You've probably also installed the WPF/E SDK and opened up some of the sample source code. What next? Write your own WPF/E code, of course! Adam Kinney has posted a video on Channel 9 about Getting Started with WPF/E. It's worth a listen (I say listen because the code on his screen is illegible, but it's interesting anyway). In this video he opens up a WPF/E project template and uses that as a starting point. So where is this template and how can you get it? Well, there's a hard way and an easy way to get it ... The Hard Way If you've installed the WPF/E SDK there is a link in there's a link in your Start Menu which should look like the image to the right. This links to an installer which will get the WPF/E project template loaded.
Not too hard, you think? Well it's not that simple. This installer requires some additional Visual Studio bits. Specifically you need to download and install the following: This is a bit of a bother as it will affect your Visual Studio installation outside of your WPF/E development. But if you liked the VS2003 web projects and you miss them then go ahead. The Easy Way Project templates are really just specially constructed zip files and Visual Studio 2005 has a special folder where you can add your own. This is configured on Tools / Options / Projects and Solutions, but it defaults to "[My Documents]\Visual Studio 2005\Templates\ProjectTemplates". So if you go to this folder, open up the "Visual C#" folder (or whichever sub-folder you prefer) you can copy in the project template which I've attached to this post. Then you'll get the WPF/E template showing up in your New Project window as follows without installing anything else: 
EDIT [2006-12-06]: I've modified the attached template for: EDIT [2006-12-08]: I modified the namespace back to http://schemas.microsoft.com/client/2007. Once you've copied the wpfe.xsd file correctly, Visual Studio will then give you Intellisense. See my next post for more info.
|
-
Trying out some of the WPF/E samples, I noticed some rather odd behaviour. I loaded a sample directly off my file system and was rewarded with a blank security and a notice that Internet Explorer was blocking some active content. I then setup a virtual directory on my local IIS instance and everything was fine. You can see the two redenderings here: 
Now this sounded to me like a security problem, and that's exactly what it is. When you load the page via HTTP then Internet Explorer will work out which Internet Zone you are in (Intranet, Trusted Sites, Internet, etc) and the configured security. Below to the right is a screenshot of the default WPF/E security settings and you can see that it will run content, even for the Internet zone.
However thes settings only applies to pages loaded via HTTP. If you are loading some HTML directly from your file system (like I was) then there are some different security settings. The defaults are shown below and you'll notice that they prohibit active content, which includes WPF/E XAML files.
So strangely enough, as far as XAML and WPF/E go, your local file system is a more restrictive location than the Internet. Work that out if you can!
|
-
The Dec 2006 CTP of WPF/E is now available for download. If you're interested in this, you'll want to check out the following links: And lastly, you can always check my own summary of what WPF/E has to offer (written pre-release).
|
-
There's been some noise recently about WPF Everywhere (or WPF/E), a technology which was announced at PDC05 and Joe Stegman from Microsoft demonstrated at MIX06. Here I'm going to collect together a few web resources about this technology. So what is it? According to Mike Harsh's Blog: It is a cross-platform, cross-browser web technology that supports a subset of WPF XAML. WPF/E also has a friction-free install model and the download size we’re targeting is very small. WPF/E supports programmability through javascript for tight browser integration. The WPF/E package also contains a small, cross platform subset of the CLR and .NET Framework that can run C# or VB.NET code.
So that sounds interesting, but what can you do with it? These screenshots are also taken from Mike Harsh's blog: 
Here's a transparent vector image with a clock that animates on top of the background. And it's being displayed in Firefox. And to show the flexibility of a markup-based UI, here's a simple Notepad type application. In a browser. The user can enter some XAML and the WPF/E browser plugin is set to display this via JavaScript.
So this is very interesting, but how simple is it to develop and what can you do with it? Tim Anderson has published a great article which gets into some of the nuts and bolts of developing with WPF/E and outlines some of the things you can and can't do with it. Interestingly, Microsoft seem to be having a small change of philosophy, as indicated by the "E" in WPF/E. Specifically, this technology will not be limited to Internet Explorer or the latest incarnation of Windows and will not even be limited to Microsoft operating systems! Microsoft will be providing a browser plugin which is cross-platform. They are specifically targetting IE, Safari and Firefox running on Windows 2000, Windows 2003, Windows XP and Windows Vista, as well as Firefox and Safari running Mac OS X. Apparently they are aiming for a download size of 2MB, so it shouldn't even be too onerous for most users to install. Of course there is no official release date, but Joe Stegman posted a blog entry on 12 Nov 06 in which he said a CTP will be available "soon". So a roundup of other useful links:
|
|
|
|