Category Archives: Software Development

iPhone

Standard

“In more bad news for Windows Mobile, Apple shipped more iPhones in the quarter than the total of all handsets based on the Microsoft system, even though their numbers actually increased by 42%.” (See article Apple and RIM tussle for Q4 prizes as smartphones boom)

I’m really sorry, but I don’t think Windows Mobile 6.5 or 7 is going to make any difference, it seems that Microsoft is not going to be able to produce anything compelling enough, soon enough.   I don’t think there’s going to be a “comeback”.

In case you think that the iPhone is all hype and marketing, I have a question for you.  Have you ever tried using one?  I have yet to meet anyone who has had less than a “revelatory” experience using an iPhone. 

I’ve had a great experience developing for the platform (I think the Compact Framework is excellent).

I believe the future of mobile computing is and is going to be huge, but I’m afraid Windows Mobile isn’t going to play a significant role anymore. 

Future handset operating systems will be various, including of course the iPhone and Android.

Other mobile devices such as tablet computers and netbooks will probably continue to run Windows, so I think Microsoft should concentrate their efforts on continuing to ensure relevance on this form factor.

For developers I think the news is all good.  There are great opportunities out their in mobility, if we are willing to “move on” in our choice of development technologies. 

 

Links

Permanent Link to IE6 for Windows Mobile – Better, but not brilliant

The Mobile Spoon: What happens when a Windows Mobile Addict breaks his vow and buys an iPhone?

Apple and RIM tussle for Q4 prizes as smartphones boom

 


Share this post :

Estranged Siblings – Silverlight Mobile and the Compact Framework CLR

Standard

An illustration that contemplates the cojoined nature of Silverlight and the Compact Framework

 

At PDC 2008 in the session Microsoft Silverlight 2 for Mobile- Developing for Mobile Devices, Amit Chopra revealed some interesting details about Silverlight Mobile that I haven’t seen written elsewhere.

The presentation mainly consists of “here’s Silverlight running on Windows Mobile”.   The interesting bits are at the end.  I dear reader, present these to you here.

 

Compact Framework, small but mighty

The compact framework, is small yet mighty.  (Some may say mighty ugly...by default)

The Compact Framework provides a great deal of rich device integration and sheer programmability. It is a pleasure to create software for.  I even think that Compact Framework based applications have been a reason for customers, particularly in the Mobile Fieldworker areas to adopt Windows Mobile devices.

If you’re a Compact Framework developer like me, you may have been frustrated by the default “yesterday” appearance of the System.Windows.Forms forms engine.  It takes a great deal of work to make forms look good. 

Silverlight, a Framework Apart?

Two frameworks, Silverlight and Compact Framework, so alike, yet so different.

I for one was very excited last year at the thought of a Silverlight (ie WPF) graphics engine being available for Mobile Device development.  I was then saddened to learn that the Silverlight runtime would not be extending the Compact Framework, but would exist in addition to Compact Framework.

This is disappointing news. (I am now showing my disappointed face….beware!) It appears that Microsoft (at the moment) seem determined to give Silverlight minimal access to the device.  This is aligned with the idea that Silverlight is only a competitor to traditional Flash app that runs from a Web page. 

Although this may be acceptable for certain kinds of desktop oriented Silverlight applications, I doubt this is a believable use case for mobile developers.  The power of mobility is not only the ability to access data anywhere, but the ability to talk to the features of the device.

In the presentation mentioned at the outset, there was declaration of the intention to support Webcams, accelerometer and other device features in the future, depending on the support for this on other platforms (eg Windows and Mac). 

So, we are restricted to the lowest common denominator.  You may believe this is for technical reasons.  It isn’t. Because….

Silverlight Uses the Compact Framework!

Diagram of Silverlight Architecture on Windows Mobile

Amit said that the Silverlight runtime for Windows Mobile may be smaller because it may omit certain codecs and it also shares the Compact Framework Clr.    He went on to say that the Compact Framework would be a prerequisite to installing the Silverlight runtime.

A new and nobler purpose for Silverlight Mobile

I give you....Silver-Knight

It’s Microsoft’s belief that targeting Windows Mobile 6.? (Sorry about that WM2003 and 5) and Nokia phones will mean Web users will eschew DHTML and Flash websites for Silverlight ones.  

With the proliferation of device operating systems (particularly that pesky iPhone) I don’t think this is a likely scenario.  Do you?  Well do you?

I’ve I got an idea!  As it’s unlikely Microsoft will backtrack on their “one platform everywhere” philosophy for Silverlight, why not, in addition enable Silverlight as a cutdown WPF for the Compact Framework on Windows Mobile? Microsoft, I know you can!  Doing this would earn the gratitude of all Compact Developers and provide a side benefit to their current Silverlight efforts on Mobile.

Call to Action

If you agree, please add a comment or bookmark this article using the links below, blog about this yourself or email the people at Microsoft.   Amit said they wanted feedback, lets give it!

(BTW Any physical resemblance between Amit and myself is entirely coincidental, so don’t say it)

 

Links

Microsoft Silverlight 2 for Mobile- Developing for Mobile Devices

Amit Chopra’s Blog (Email) – WIndows Mobile Program Mananger

Giorgio Sardo’s Blog (Email: gisardo @ microsoft  com) – Evangelist for Windows Mobile

 


Share this post :

Silverlight Announcements at PDC 2008

Standard

image

I’m at PDC2008 day 2.  There were lots of announcements, including a first look at the Windows 7 user interface.

There were some really interesting announcements regarding support for Ribbon and Multitouch in WPF and MFC along with quite a few demos of real products using the technology.

I saw a very impressive demo of the “Office Online” product that provides Word, Excel, Powerpoint and Onenote for the web.  What I saw today is far in advance of any other web-based productivity suite I’ve seen before.   They said that some of the functionality was provided by Silverlight.  I’m not sure how much.

Exciting news for me is the Silverlight Tooklit.  This provides 12 new controls:

  • AutoCompleteBox
  • NumericUpDown
  • Viewbox
  • Expander
  • ImplicitStyleManager
  • Charting
  • TreeView
  • DockPanel
  • WrapPanel
  • Label
  • HeaderedContentControl
  • HeaderedItemsControl

 

More information here : http://www.codeplex.com/Silverlight

So does that make Silverlight a “Game Changer” yet?


Share this post :

Windows Azure and it’s implications on Software Architecture

Standard

image

It’s the first offical day of PDC2008 in Los Angeles.  I’ve just listened to Ray Ozzie’s (pronounced as Ahhh-zeee) keynote on Microsoft’s vision for cloud computing.  I seem to recall something similar being announced at PDC2001, but I’m sure they really mean it this time.

I wondered what Dave Cutler was up to lately.  Apparently he’s helped build “Windows Azure”, previously known under the code name “Project Red Dog”, along with Amitabh Srivasta, an operating system exclusively run at Microsoft Data Centers (“the cloud”).

I think Microsoft have outlined how they intended to provide services in both the traditional “in house” sense, and a hosted sense.   With the Microsoft Online Services (Exchange, Sharepoint, Crm etc) Microsoft hope to provide an alternative for customers who dont have the resources to run their own datacenter.

So what’s this got to do with application architecture? 

Microsoft will be providing hosted versions of all their applications.  Windows Azure provides Microsoft based developers to provide hosted versions of their own applications.   Although platforms such as GoogleApps look really interesting, a platform that allows the hosting of Microsoft technologies without redevelopment is more compelling.

Primarily it seems that the application architecture that would suit this environment best is that of a scaleable SOA or Web based application.  This doesn’t rule out any client architecture particularly, but an asp.net based application would certainly have an advantage.


Share this post :

Automatically stretching a Silverlight 2 control on a webpage

Standard

image

A couple of fun hours were spent trying to get my Silverlight content to resize when the user resized the browser. 

I mean, what’s the point of having your Silverlight content replace HTML if it wont flow and resize when the user resizes the browser? I want my Silverlight content to take up the whole browser frame.

The Html Code

You’d think this would be the default behaviour for an asp.net tag definition like this:

<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/TechnologyOneCrm.xap" Version="2.0" Width="100%" Height="100%" />

 

Sadly this is not enough.  Your silverlight sits there in a dumb un-resizeable box.

The Xaml

When you create a Silverlight 2 control in Visual Studio 2008 or blend, the UserControl typically has Height and Width properties set, something like this:

<UserControl x:Class="Daphne.WorkplaceHome"
    xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Width="900" Height="400" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
    <Grid x:Name="LayoutRoot" Background="White" >
    </Grid>
</UserControl>

 

The Elusive Auto

Hence the reason why your content is not resizable.

One solution is to remove the Width and Height property.   Another is to set them to “Auto”, like so:

<UserControl x:Class="Daphne.WorkplaceHome"
    xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Width="Auto" Height="Auto" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
    <Grid x:Name="LayoutRoot" Background="White" >
    </Grid>
</UserControl>

 

If you run the project, it will start resizing.  Unfortunately this causes the designer in Blend and VS2008 look like rubbish.  (or more rubbish than usual anyway).

The trick is to set the Width and Height properties to “Auto” after the the screen has been rendered.

 

In WPF (apparently) you can use code like this:

Partial Public Class Page
    Inherits UserControl
    Public Sub New()
        InitializeComponent()

        Me.Height = new System.Windows.LengthConverter().ConvertFromString("Auto")
        Me.Width =  new System.Windows.LengthConverter().ConvertFromString("Auto")
    End Sub

...

 

Sadly, in another twist of fate, “LengthConverter” does not exist in Silverlight.

The Silverlight Solution – Who’s your Nan?

 

image

 

Fortunately, browsing the type library showed me that setting the property value of Height or Width to “System.Double.Nan” has the same effect as “Auto”.

So, in the intialise of your Silverlight control, put this:

 

Partial Public Class Page
    Inherits UserControl
    Public Sub New()
        InitializeComponent()

        Me.Height = System.Double.NaN
        Me.Width = System.Double.NaN
    End Sub

 

I am not sure if Microsoft intend to support LengthConverter (or TypeDescriptor.GetConverter!) in a future Silverlight version, but I’m guessing not.

Links

 


Share this post :

WPF and the Supervising Controller/Presenter Pattern

Standard

image

I’ve previously stated that the MVP pattern could be advantages for XAML based applications.  I haven’t provided WPF examples yet as I fear that these may compromise the design-ability of the XAML layout.  

Florian Krusch describes the beginnings of an MVP style pattern for WPF (and Silverlight) applications in his article:

WPF – DM-V-VM or M-V-P – WTF?

He states that the pattern described by Martin Fowler  “Supervising Controller Pattern” (still under development at time of writing) may be relevant in this case.  (The term Controller and Presenter are used interchangeably in Fowler’s article)

This pattern has been created in order to facilitate frameworks such as WPF that have a data binding capability.   I understand however that it expects one-way data binding (read) with the view look at the model directly.  Updates to fields are delegated to the controller, which in turn updates the model.  This sortve neuters the 2-way data binding in WPF.

The true objective of these architectures is testability, with the assumption of the view being difficult to work with in the unit test environment.

An architecture that may work is something like the diagram below:

 

image 

In this proposal both the View and Model could be mocked successfully.

In future posts I’ll endeavour to  create some code to show how this may work in the real world.


Share this post :

Weird Science – Defining Winforms in XAML

Standard

image

I like to think of XAML as an “object instantiation script”.  According the to the main books on the subject it should be possible to utilise XAML to create any kind of .net object. 

Practical examples include WWF (Windows Workflow Foundation) , which allows the storage of definition in XAML, which is nothing to do WPF.  WPF (Windows Presentation Foundation) was the original reason XAML was created, but XAML was designed to be independent.

So I was thinking, why not see if I can define a traditional “Winform” in XAML.    Why would I want to?   I thought it might be fun.   As it turns out, it may actually be useful in some scenarios.  (With a great stretch of the imagination)

So does it work?  Oh yes it works and it works well.   “Well” means that VS2008 provides full intellisense for tags within the Xaml designer, as well as “code behind”.  Now that, my friends, is cool.  Imagine being able to create form layouts using XML tags instead of that oh-so-last year winforms designer!  The result is surprisingly WPF like, which I find intriguing.

To create the example below, I created a WPF project, then removed the default WPF “Window1.xaml” and replaced it with my own “Form1.xaml”:

<Form Name="Form1" x:Class="Form1"  Text="Hello" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
        >
    <Form.Controls>
        <FlowLayoutPanel>
            <FlowLayoutPanel.Controls>
                <TextBox Name="txtName" x:Name="txtName" />
                <Button Name="cmdSayHello" Text="Say Hello" Click="Button_Click" /> 
            </FlowLayoutPanel.Controls>
        </FlowLayoutPanel>
    </Form.Controls>
</Form>

Please note that features such as code behind (partial classes), event hooks and most things in the “x” namespace work fine.

Creating XAML from an existing Winform

For even more fun and games, you can feed a running instance of a Winform into XAML Writer and get XAML source.  Sadly winforms incorporates read-only properties, so without massaging the Xml you’re not going to be able to clone a Winform using XAML serialization just yet.

The code would look something like this:

Dim loWinform As Form = Me ' Some Winform
Dim lsWinformXaml As String = XamlWriter.Save(loWinForm)
Dim loClonedForm As Form = XamlReader.Load(new XmlTextReader(new StringReader(xaml)))

 

See this Mike Hillberg’s object cloning article for more information.

 

So where from here?

What’s the use of it?  Well for me it proved that Xaml can be used to create any sort of object graph.  

Possible uses for this:

  • Embedding Winforms instantiation code within a WPF XAML document (something I haven’t tried)
  • Streaming Winforms form definitions from a server down to a client (effectively allowing a WebServer to render Winforms just like it renders HTML pages)
  • Providing a good interim step in creating a Winforms to WPF Converter

 

Any Comments?

If you find this topic interesting, ask questions or download a sample project, write some comments on the blog.  If I can see interest in the topic I may develop it further.


Share this post :

kick it on DotNetKicks.com

Seeing is Believing – Using Powerpoint as a UI Design Tool

Standard

Image that provides a visual metaphor about how different owls see things differently

When talking about “interaction design”, designers talk about the practice of “Wire Framing”. 

In the past this “Wire Framing” involved creating fairly primitive mock-ups of user interfaces on paper, arranged to make a “Story Board”, much in the same way as makers of animated cartoons always have.

The use of these story boards has allowed designers to “run through” prospective designs with real users as well as developers.  A useful tool.

Although paper is certainly a useful tool (I use it alot myself).  I can’t help wondering if there’s a way of doing this on a computer effectively.  You’d think there would be wouldn’t you?

Draw It!

One approach is to use a graphics editor such as Photoshop or the ubiquitous MS Paint (for goodness sake use Paint.NET at least….).    This is good in that it helps the stakeholders understand what it is that the new product will look like.  It’s bad in that it isn’t interactive and it usually takes lots of time, sometimes with a mediocre result.  It’s good if you have a Graphic Artist to help.  (The difference between a developer and a Graphic Artist producing a piece of work is that although they will probably both take ages to produce something, at least the Graphic Artist produces something worth looking at).

Prototypes

Another approach is to create a prototype using the actual development tools.  In the Microsoft World, run up Visual Studio and start churning out miracles.  Sadly however this approach is still development and developers can get bogged down in the detail.

There’s also the “scary” side to an operational prototype.  That nightmare scenario where development budgets are reduced and the boss says “why don’t we just put the prototype into production”……Enough said.

So the trick, in my opinion is to create something that looks as real as possible (ie as impressive as possible), but clearly is not the “real thing”.

 

Enter – Expression Blend

The era of User Experiences ushers in another alluring alternative.  Microsoft for example offer designer-oriented products such as “Expression Blend” that allow designers to create WPF and Silverlight based user interfaces without having to run the equivalent development tool “Visual Studio”. 

Allegedly Expression Blend will allow designers to create user interfaces.  At last designers have the power to wireframe in a rich way, creating user experiences that behave like prototypes.   Like the craftsman in his workshop, the designer has created a beautiful puppet, which dances for his appreciative masters.  But what if Pinnochio wants to become a “real boy”?

When it comes time to create real software the developers add the code, like Blue Faerie’s pixie dust and bring the user interfaces to life.

A pretty story indeed.  But will it happen?  In the Microsoft world it’s something that was promised with web frameworks such as ASP.Net in the early days, the dream of separating  ui design from programming content.

Sometimes creating the desired ui experience does take a while, even for someone proficient in Expression Blend.   (Happy to be howled down on this point)  A lot longer than doing a hand sketch or using MS Paint anyway.

Powerpoint Magic

A technique that has been used in my team is to use PowerPoint to do our Ui concept demos.      It has proven to be so believable, I’ve had stakeholders ask me to click on ui elements that are not part of the demo, despite repeatedly telling them “it’s only powerpoint”. 

We create different slides for each ui state.  In it’s simplest form we press enter to advance to the next ui state. 

This does NOT involve complex animation and transitions.  This sort of thing, even in a normal powerpoint presentation just wastes time.

If there’s time we’ll add “Custom Actions” (Mouse Hover or Click) to some UI elements to advance to the next slide, but that’s it.

To create the slides, we usually begin with a base (in the case of a browser based app this may be a screenshot of a webbrowser frame).  Take screenshots of various UI elements from other applications using screen capture software.  (this is built in to Vista….I recommend using Gadwin if you’re running XP)  The more of these you have the more realistic your concept will look.  Use the built-in powerpoint text boxes for more conceptual work.

The screenshot below a screenshot of a proposed PDA application.   It uses a screenshot of Visual Studio’s emulator as a base:

Sample PDA Application Screenshot

 

Using this approach can have these advantages:

  • It can look exactly like the real thing
  • It’s easy to do
  • It’s fast
  • You can add annotations
  • You can add limited interactivity
  • It works for any kind of application, not just Microsoft Wpf/Silverlight
  • You can use any Powerpoint-like tool

Conclusion

The “User Experience” is a becoming a key differentiator in many software markets.  Creating prototypes can be an important technique in creating compelling Ui experiences.  Perhaps more of this would be done if people realised that even a tool like PowerPoint can be used to do this.

Links

 


Share this post :

Visual Basic 9 for the Insane – Extension Methods

Standard

 

image

Am I the only one who found “Shared” (aka Static) methods disturbing?  Loving true Object Oriented programming, when reviewing .net 1.0 Beta 1 I was aghast (similar to being agog) in that I knew my less sophisticated software developing brethren would use this as a way of avoiding using OO.  (also don’t get me started on the Module keyword in VB)   I was  not disappointed.

As much as I tried to encourage these simple souls to inherit, override and extend, they happily pointed out the cursed “NotInheritable” (sealed) classes.  My dreams of adding my own methods to existing classes such as “String” were dashed.  The “subroutine” brigade merrily created their “Utils” modules and using OO for “everything” appeared to be unattainable.

Fortunately the situation has been approved.  I give you the new VB9 feature of “Extension Methods”.  These are cool methods that can be effectively added to any class, whether “NotInheritable” or not.

A feature of the string class I really like is the “StartsWith” and “EndsWith” methods.  They allow me to check if a string has certain characters at the beginning or end of a target string.

What if I wanted to check if there was a string anywhere within a target string?  No easy boolean operator there.  (There is “IndexOf” but returns a -1 if not found. Yuk!)

Now if I was one of the simple Shared method lovers I may create a module like this:

Module Utils
    Public Function ContainsString(ByVal targ As String, ByVal toFind As String) As Boolean
        Return tar.IndexOf(toFind) <> -1
    End Function

End Module

To do the check, you’d have code that looked like this:

Dim lsString = "The red sun set in the west"

    If Utils.ContainsString(lsString, "red") Then
        MsgBox("Contains Red")
    End If

To some this may be beautiful.  To me it is not. 

I prefer this syntax:

Dim lsString = "The red sun set in the west"

If lsString.ContainsString("red") Then
           MsgBox("Contains Red")
End If

To make this happen, simple add the *<Extension()> attribute:

Imports System.Runtime.CompilerServices
Module Utils
    <Extension()> Public Function ContainsString(ByVal targetString As String, ByVal stringToFind As String) As Boolean
        Return targetString.IndexOf(stringToFind) <> -1
    End Function

End Module

Pretty cool eh?  I’m quite excited at the possibilities.  It honours the accessor keywords (Public,Friend,Private) so you can use it within assemblies safely without having to have debates.

Extension methods even work for generic types, such as “List(Of T)”, so they really are without limits. 

Note: Sadly this requires targeting .Net Framework 3.5 and doesn’t appear to work on the Compact Framework.

 

 

 

 

End Module

Visual Basic 9 for the Insane – A class with no name – Anonymous Types

Standard

image

Now we’re starting enter strange territory.  I give you a syntax that allows you to create classes “on the fly” :

Dim loClasslessSmurf = New With {.Name = "Brainy", .AnnoyingTrait = "Whiny Voice"}

This syntax creates a “temporary” class with the properties you specify.  This is known as an “anonymous type”.  (Or a type with no name)  This is the equivalent of:

Public NotInheritable Class XXXX
  Public Name As String
  Public AnnoyingTrait As String
End Class

These classes do not have methods on them.  They are intended as useful temporary data holders for inline processing.  They were created for the LINQ language feature to allow results to be returned without having to create result container classes.

Differences between Cousins

It appears that the behaviour between VB9 and CSharp3.0 differs when creating an anonymous types.  If you create one in CSharp, the properties are read-only.  If you create them in VB9 the properties are writeable.