Category Archives: silverlight

UI design patterns for Rich Internet Applications

We are used to the idea of design patterns for software construction, following the great work of the gang of four – Design Patterns: Elements of Reusable object-oriented software by Erich Gamma, Richard Helm, Ralph Johnson and John M Vlissides. But what about patterns for user interface design? What about learning standard UI patterns and how to apply them well, so that you have an immediate head start when sitting down to create a compelling and usable application?

Ryan Stewart’s blog post on up-leveling the Flex User Interface Discussion links to the work of Theresa Neil, who spoke on Designing Rich Application at the DelveUI conference last week. She’s posted her slide show, which I’ve also embedded below:

I found it fascinating, and while I will never be a designer, this kind of methodical, structured approach to building a UI is one that developers can also appreciate.

She also has a matrix of essential controls showing which UI frameworks support them – page 21 above – though the slide only shows controls from A to D; the full set is described here.

While I’m on the subject, there’s also a thought-provoking post from Brandon Walkin on managing UI complexity. It seems Microsoft can still provide plenty of “how not to do it” examples.

Proof of concept: C#-SQLite running in Silverlight

Noah Hart has ported SQLite to C#. I was intrigued to see whether the code could be adapted to run in Silverlight, which has a cut-down .NET Framework and prohibits platform invoke to native code.

I hacked away at his code until it ran in Silverlight:

Note that the sole purpose of the exercise was to see if SQLite could be made to run, not to prepare a port that is production-ready or even code that is fit to check-in. In essence, I defined SQLITE_SILVERLIGHT, removed all the locking, adapted the file I/O to use isolated storage, and generally took as many shortcuts as I could think of to get it to compile and run. Unfortunately transactions do not work, though that can probably be fixed.

As far as I can tell, Silverlight’s Isolated Storage does not support locking at all. If the same application were opened twice, for example in different browsers, that could cause problems, but in normal use it would likely be OK.

One other point of interest: the XAP file in release mode is 257KB.

Update: The sample app is here. The hacked code is here [zip].

C#-SQLite now published

Noah Hart has published his port of SQLite to C#. The project is called C#-SQLite. The main SQLite author, D Richard Hipp, originally said that the project should not include SQLite anywhere in its name, but has now relented:

I think I would be comfortable with a name like C#-SQLite. The prefix makes it clear that it is a reimplementation, not the original. People notice prefixes much more readily than suffixes. There is also precedent for changing a prefix for a reimplementation. Lucene, for example, was ported to C-Lucene. I’m sure there are others.

The whole point of this exercise it to avoid confusing people. Folks who use C#-SQLite need to be fully aware that what they are using is distinct and separate from the original SQLite. As long as that one condition is met, I am happy.

I downloaded the code, compiled in Visual Studio 2008 (requires project conversion), ran the shell and tried a couple of commands. It works!

Of course there are already a million ways to use SQLite from .NET, but they all require platform invoke to native code, which is not allowed in some scenarios for security and/or cross platform reasons – Silverlight being a prime example.

Next question: how hard will it be to get this working in a Silverlight project?

See also SQLite C# port raises hopes for a Silverlight local database manager which has some early performance results.

Technorati Tags: ,,

SQLite C# port raises hopes for a Silverlight local database manager

Yesterday programmer Noah Hart announced a port of SQLite to C#:

I am pleased to announce that the C# port is done to the point where others can look at it.

Unfortunately the code was taken offline almost immediately afterwards, thanks to the intervention of the author of SQLite, D Richard Hipp:

Noah, you are welcomed, even encouraged, to take the source code to SQLite and translate it in any way you want and do whatever you want with it. But you need to make it abundantly clear to everyone on your site and in the comments of your source code that your code is not the original SQLite … SQLite is a registered trade mark. If I don’t defend the trademark, then I could lose it. So, I really do need to insist that you not use the name "SQLite" for your product.

The reason given is that Dr Hipp does not want to receive support requests for the port, though the intervention is a little surprising since there are other 3rd party adaptions out there that do use the SQLite name, though these generally modify or wrap the original code rather than porting it completely.

Still, Hart has taken it in his stride and it looks as if the code may be back soon under the name sqlsharp – a Google code project with that name has been created. I hope this is the name since I suggested it, though it is rather an obvious one and I might not have been the first.

Why the interest? First, it’s always interesting to compare languages. Currently, Hart says his executable compiles to 528kb vs 506kb for the native version, and performs 3-5 times more slowly (results in rows per second):

Test SQLite3 C# SQLite3
Inserts 300K 1300K
Selects 1500K 8450K
Updates 60K 300K
Deletes 250K 700K

Although that may seem disappointing, SQLite is remarkably fast so even 5 times slower is still acceptable in many contexts; and there are no doubt many possibilities for optimisation.

What’s the point? Hart says it was a C# learning exercise, which is fair enough. Others are hopeful for a local database manager for Microsoft Silverlight, writing to isolated storage. Competitor Adobe AIR includes SQLite in the runtime, as does Google Gears.

Silverlight may a stretch for Hart’s port. Silverlight does not allow platform invoke or code marked as unsafe; and while there are apparently only a few p/invoke calls I’m guessing there may be many unsafe sections since the original SQLite makes heavy use of pointers.*

Although Silverlight is an implementation of the .NET Framework, it does not include the System.Data namespace. It does include System.Linq.

There are a few other efforts at creating a local database manager for Silverlight, including McObject’s Perst, db4o (work in progress), and Silverlight Database which works by persisting XML.

*Update: the project has now been published as csharp-sqlite, which is an excellent name; it looks as if Hipp relented to some extent. Now that I’ve seen the code I find I’m wrong about unsafe sections. In fact, I added C#-Sqlite to a Silverlight project and it failed to compile with a mere 53 errors, many of them related to file locking – possibly less necessary in isolated storage? A Silverlight port looks feasible.

Morgan Stanley: why we didn’t use Silverlight for Matrix

I attended an online briefing about Morgan Stanley’s Matrix [warning: lots of Flash with sound effects], a tool for financial trading which has been written in Adobe Flex.  Adobe’s Andrew Shorten has more information here, and notes:

Matrix was developed by Morgan Stanley with user experience consultation from Adobe Professional Services and technical delivery by Lab 49 in partnership with Adobe Professional Services and others.

Unfortunately I missed the first part of the briefing thanks to streaming issues (I wasn’t alone), but things settled down after 15 minutes or so. Hishaam Mufti-Bey, Matrix founder and global director at Morgan Stanley, spoke about the application and the technology it uses. He emphasized the value of zero-install:

The technology is out of the way, no-one has a problem with running the application. It’s now about how tight our prices are, how good our content is, which is always what we wanted to have happen … we want to deliver our franchise to the client without taxing their systems, or having to get past firewall issues, or install software and IT security will get in the way and it takes months to deploy.

I couldn’t agree more. The app itself looks great, though details of how it works were sketchy, I guess for commercial reasons. We were also told little about the server side of the application. Performance is said to be good, despite what is apparently 600,000 lines of code (I’m not 100% clear if this is all Flex code running on the client):

We’ve seen up to 40 currency players running on the screen and getting up to about 400 updates a second

claimed Mufti-Bey, though he added later than lack of multi-threading support is an issue. Next, he took a pop at Microsoft’s Silverlight:

Going out to clients and not installing software, that is a major show-stopper for Silverlight. If Silverlight turned around and offered that one day, that I didn’t need to install stuff on the client’s PC, then it would be a head-to-head. Flash is on 97.7% of the world’s browsers. That was a major consideration for us.

It’s an interesting point, though I’d have thought his comments need some qualification. Flash and Silverlight are both browser plug-ins, so the install issue is similar: if the plug-in is already installed, the app will just run in the browser, but if it is not installed in the right version, the user will need to install the plug-in first. According to riastats.com Flash is up to about 74.5% for version 10 and 20.5% for version 9; I’m not sure if Matrix requires version 10, but if it does then Mufti-Bey is exaggerating a little. Matrix currently uses Flash 9 (see comments). Silverlight by contrast is on 30% for version 2 and 1% for the just-released version 3.

Installing a browser plug-in is easy for most of us, but in a locked-down corporate environment may be problematic, and there is always some percentage of installs that will be troublesome. I’ve found installing Silverlight a smooth and quick process; but undoubtedly Flash is a de-facto standard whereas Silverlight is not. Microsoft can only address this by persuading more of us to develop Silverlight apps, and using it more in its own sites and products – like the forthcoming Office 2010 web applications, for example.

Still, the need to install the Silverlight plug-in where necessary is far less burdensome than either a classic Windows setup, or a requirement for the full .Net Framework; and Microsoft has also removed the requirement to run Windows itself by supporting Intel Mac. It sounds as if Microsoft is going in the right direction, even if catching Flash is a tough challenge.

That might not be enough, according to Mufti-Bey. Asked about the importance of designer-developer workflow, he remarked:

You have to look at the people that use that technology. The design community. That’s the biggest problem that Microsoft has. The designers all carry around Apple laptops, they all use the Photosuite [sic] set of software tools. It’s like asking structural engineers to stop using CAD applications. That’s the tool that they use, and if you can’t convince them to switch away from your software suite you are going to get a limited number of designers that will use Microsoft’s toolset … if you can’t get the designers to switch, to learn a new language, then how can you possibly ever get some traction?

Well, it wasn’t the answer to the question posed, but an interesting point nevertheless. Let’s presume that he is right, and nobody will switch from Photoshop. Is it so hard for Mac-wielding designers to work with .NET developers? There must be something in it, bearing in mind the effort Microsoft has made to improve Photoshop import in Expression Blend 3.0.

Overall I would like to have heard more about the process and challenges of developing a large Flex application, and less about why not to use Silverlight, interesting topic though it is.

Office 2010 puts SharePoint in the centre

Microsoft has released a semi-public preview of Office 2010 – not a beta, so more than ever subject to change – as announced at its Worldwide Partner Conference in New Orleans. I’ve been trying it out, and wrote a quick review for The Register.

For the most part this is a refinement of Office 2007 rather than anything new and radical. That’s not a surprise; Microsoft’s boldest ideas (like the Ribbon) tend to survive for at least two versions before being sidelined, and I doubt the market would have responded well to anything disruptive this time around.

Still, there are two things which deserve highlighting. One is 64-bit; this is overdue and most welcome, even though many, probably most users will not notice the difference. For those that do, it really matters.

The other is the web applications. Although the obvious spin on this is that Microsoft is taking on the likes of Google, Zoho and Adobe Acrobat.com, it is important not to miss the other angle, which is that SharePoint is now firmly in the centre of Office. The web applications are built on SharePoint, and for the first time you can do your work equipped with nothing more than a browser.

Office Groove is now called SharePoint Workspace and lets you synchronize a SharePoint site to your local PC or laptop.

Presuming this works satisfactorily, it makes SharePoint both more usable and more compelling. I know plenty of small businesses who have looked at SharePoint in Small Business Server but never been able to make sense of it; these new approaches may well make the difference.

A side effect, which I am sure has not gone unnoticed by the folk at Redmond, is that shifting away from SharePoint to OpenOffice is harder then shifting from Office to OpenOffice. Lock-in is alive and well.

Another snag with SharePoint is that it gets very expensive once you start trying to use all its features. However, this is what I was told about licensing the web applications:

The Web apps will be licensed along with the Office client apps, so when a business purchases Office through their volume licensing agreement, they get the license to run Web apps on their own servers.  For customers of Microsoft Online Services (SharePoint and Exchange hosted by Microsoft) customers will be able to subscribe to the Web apps.

It doesn’t sound too bad; and the hosted option is important to note as well. Further, there will be some kind of free option:

400 million Windows Live consumers will have access to Office Web applications at no cost.

One day, Microsoft should start taking stuff out of Office, rather than putting it in. Who would not want a leaner Outlook? Maybe the new web applications built with Silverlight are the beginning of just such a new generation. 

I’ve posted some screenshots and further comments here.

Silverlight 3 is out

Microsoft has released Silverlight 3, though some pieces of the platform are still not done – it seems there is always something to wait for.

There are links to the tools developers and designers need to install here:

http://silverlight.net/GetStarted/

Note that Expression Blend and Sketchflow are still at Release Candidate stage.

The .NET RIA services, a server-side piece that simplifies authentication and database operations, is available in a new July 2009 preview:

http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=76bb3a07-3846-4564-b0c3-27972bcaabce&displaylang=en#filelist

See this excellent post by Nikhil Kothari for more on RIA Services – it’s from March but does a good job of explaining what they are about.

Using Silverlight 3, or plan to? I’d love to hear from you, along with your views on what is best and what is worst about Microsoft’s RIA efforts.

Adobe “Committed to bringing Flash Player to the iPhone”

Adobe CEO commented during yesterday’s earnings call:

We are also equally committed to bringing the Flash Player to the iPhone, so now we do have a Flash Player 10 version for smartphones. We continue to work with Apple. We need more APIs and cooperation to bring the capabilities of Flash to the iPhone and we think it’s in both of our best interests to make sure that 85% of the top 100 websites that use Flash, that that experience is available to the Apple customers.

The real question is not whether Adobe is committed to this, but whether Apple will allow it. I think the stake are high for Adobe, which is why I have such keen interest. The longer the iPhone remains Flash-free, the more those “85% of the top 100 websites” will question their use of Flash and wonder if they should try to migrate towards more universal HTML and JavaScript technology. On the other hand, if Adobe gets its stuff on iPhone it will give it a further advantage over rival plug-ins like Microsoft’s Silverlight.

I mean, if you build your entire cloud platform around the Flash client, what do you do if the key mobile device out there refuses to support it?

Transcript from Seeking Alpha.

Technorati Tags: ,,,

New Visual Studio 2010 beta has WPF editor, Silverlight designer

I’ve just downloaded and installed the Visual Studio 2010 beta 1 release. I’ve not explored much yet – and it is rather slow in a virtual machine – but it does now seem to have the new editor and other pieces built with Windows Presentation Foundation.

A landmark for both WPF and Visual Studio.

I also noticed that the Silverlight visual designer now works as you would expect, though I had to download the developer runtime and SDK separately:

I’d welcome comments from anyone using the beta.