Create Silverlight Apps with Notepad

Did you know that you can write simple Silverlight applications using just a text editor without using an IDE or compiler?
Although it is recommended to use silverlight.js to start your silverlight application in a robust way, you don’t even need that. Just create a html file with a text editor of your choice and embed the XAML code.

The absolute minimum is this:



	       
	    

This is a plain html file. The Silverlight plugin is hosted using the object tag. The XAML content is not stored in a xap file, but in a local script of type text/xaml. Inside this script block any XAML can be placed.
The script can also use embedded storyboards to automatically triggers animations.
A more complex example which creates a rotating rectangle with text and a logo is shown here:





	       
	    

The script comprises of the visual elements Border, Grid, TextBlock and Image and four Storyboards which control the animation.
Inline XAML can be used to create nice looking splashscreens or single file demos.
Try it. Just copy the file above to a html file and open it. Provided that you have the Silverlight plugin installed you can see the animation.

Screenshots:

Live demo

If you want to let Silverlight interact with Javacript, just add another script block at the top of the page:


In order to call it, add the event handler to the Grid in XAML like this:

<Grid x:Name="Frame" Background="SteelBlue" Cursor="Hand" MouseLeftButtonDown="nav"> 
...

That’s it!

Forms Over Data vs. Domain Driven Design

A common challenge in Service-oriented architecture (SOA) is the design of service contracts. Beside many variations we see two basic types of contracts.

Forms over data (FOD) is an approach in which the forms in the user interface directly reflects the data structures in a database. The service-layer, if present, primarily offers create, read, update and delete (CRUD) operations for the individual database entities.

FOD is fostered by technologies such as Microsoft Access, Oracle Forms, .NET RIA Services. In JEE it is recognized as an anti pattern addressed by design (anti-)patterns such as Face Off or Session Facade.
FOD is tempting because large parts of the service-layer can be generated from an existing data model. By using the right tools, developing an FOD-application can be quick and easy.

Domain driven design (DDD) is an approach that utilizes a service-layer whose data objects are inspired by the business domain. The database structures are hidden behind a service-layer and not known by the service consumer, for instance the user interface. The domain model is usually modeled using XML Schema. DDD is typically used in SOA environments.

DDD-Pros

  1. Portable domain model – If modeled in XML-Schema the domain object can be generated on JEE, .NET and other platforms.
  2. Business alignment – A business oriented domain model can be better understood by business users, thus increasing agility.
  3. Higher degree of reusability – Services representing business concepts are more likely to be reused, for instance in BPM environments.
  4. Decoupling of user interface and database – Data structures can be changed (up to a certain degree, of course) without affecting the clients. Changes can be handled in the service layer.
  5. Maintenance – Proper domain driven services are designed to last. Paired with a versioning approach service maintenance can be simplified.

FOD-Pros

  1. Development effort – FOD is often supported out-of-the-box in many products, so that no using it would require more knowledge and development effort.

Although there are always areas in which one or the other approach makes more sense, you can clearly see my preference. I think forms over data can be particularly useful for small applications and prototypes. Especially with existing database models. For large enterprise applications one should prefer a domain driven service design in combination with a sound SOA approach.

Silverlight for Java Enterprise

At first sight Silverlight doesn’t seem to be the first choice for Java frontend development.
But having a closer look the Silverlight/Java combination offers unparalleled usability and developer productivity especially compared to existing HTML/JSF/AJAX approaches.
Two factors that are very important in todays competitive markets.

Silverlight integrates very well with Java technologies on many levels such as build and development, operations and testing, just to name a few.

If you want to know more, please attend my session the RIA Forum in Zurich – Switzerland on 29.October 2010.
I would be glad to see you there.