I’ve entered the MIX 10K competition where the goal is to write an application using no more than 10KBytes of source code in Silverlight. I’ve decided to implement a cocktail selector application - strictly listing alcohol free cocktails only - using the web services I’ve previously built for a popular cocktail site, iCocktail.co.uk.
ICocktail.co.uk was built with Flash using XML services and since Silverlight is indeed as powerful as Flash implementation was quite an ease - my only problem was squishing in the 10K limit (thanks for Colin’s post on some tips on minifying the code). The application I’ve developed is the following:

If you like it, please vote for it on its the MIX 10K entry site.
One thing all people noticed when looking at the application at first is the cool “bouncing” effect of the cocktail name. In the flash version this was done by using an EaseOutElastic transition. Not surprisingly Silverlight has similar animation effects as Flash, these are called easing functions. To achieve the bouncing effect I only had to add the following code to the animations changing the width and height of the shape:
DoubleAnimation animation; // The animation changing width or height of the shape popping up
animation.EasingFunction=new ElasticEase(){ Oscillations=3, Springiness=1, EasingMode=EasingMode.EaseOut };
Oh, and if you’re in for some more drinks, check out iCocktail.co.uk as well!
Posted in Silverlight | 1 Comment »
As the holiday season is close I was looking for a way of sending a simple, yet nice animated Christmas card to friends. I wasn’t looking for one of the many popular sites offering e-card sending, instead I wanted something I could somewhat customize, put on my server and send the link to friends and family so they could view it in their browsers.
At first I was thinking of creating a simple application with fading pictures in Silverlight. However I’m intending to send it to some older relatives whom I don’t want to have to mess with installing the Silverlight plugin - they would probably skip from that point. Doing the card in Powerpoint was not an option as not all friends have software to open it. So that left me trying to find a Flash application that does something like that - without any luck. So at that point I almost gave up. And then realized that I’ve forgorren about one of the most simple cross-crowser solution: using javascript to do the job.
So I’ve created a nice greeting card using jQuery that fades in a few images like it was a slideshow and writes out a greeting message in the end. You can take a look at it working here: Christmas Card using jQuery demo, and here’s a screenshot of what it looks like:

I’m sharing the complete application for further re-use, you can download the package here: source code for Christmas Card using jQuery. It consists of a html page, a css file, some demo images and a javascript file. If you want to create a similar nice greeting card, you can do it the following way:
- Download the source
- Insert your images(s) into the /images folder
- Edit the first few lines of index.html; look for the lines having TODO comments.
var images = [];
// TODO: add the URLs of your images here
// These urls can be absolute URLS (http://....) or relative ones as well
// It is recommended the images are resized to 600px with for faster loading
// Be sure to whatch out for uppercase/lowercase differences!
images.push("images/01.jpg");
images.push("images/02.jpg");
images.push("images/03.jpg");
// TODO: specify the loading text
var loadingText = "Loading card...";
// TODO: specify the text appearing when the slideshow has ended
// Leave it blank if the last image has some greeting text on it
var merryChristmasText = "Merry Christmas and a Happy New Year from Gergely Orosz!";
// TODO: specify the text on the replay button
var replayText = "Replay";
// Wether the application should force images to be displayed at the given width
// For good display this option is preferred
var forceImageWidth = true;
// Width of images. If forceImageWidth is set to true images will be rendered at this width
var imageWidth = 600;
// These were the only customizations you had to do in the script
- Copy the modified source files to a server and you’re done!
christmas
So if you’re looking to create your own cross-browser compatible, jQuery based festive greeting card, here you go!
Happy Holidays!
Posted in Javascript, Random | 2 Comments »
On the Scot ALT.NET meeting held on 4th November Robert Lewis gave a talk on BDD explaining the basics, motivations and demonstrating the .NET tools available to support this methodology. I found the talk to be really interesting, mostly because Robert was focusing on the practical side of BDD – that is how .NET developers can use this methodology and at what projects might this be beneficial.
Based on this talk I’ve written a small article on what BDD is, what tools there are out there to use it in the .NET world and how it can help in software projects. Read the article on my ScottLogic blog: Behaviour Driven Development for .NET developers
Posted in .NET, Agile | 2 Comments »
I’m working on creating a zoom effect for a Silverlight Path object. This effect is easy to implement: I just have to apply a ScaleTransform and and a TranslateTransform within a TransformGroup for the Path (scale it up and move it on the screen where the user clicked to zoom). However when reaching a certain zoom level I’ve noticed some weird behaviour: the Path was drawn in some random, sometimes inverse way.
I’ve tracked the behaviour down to the point to when it seems that the problem is not with ScaleTransform but with Paths above a certain size. I’ve created a simple example project to reproduce the problem. The source can be downloaded here.
What I’m doing is drawing a simple rectangle with 5 points:

The issue
And I start to redraw it in larger sizes and at the same time re-positioning it to stay in the center (so I’m basically doing a centre zoom effect):

However when the size of the path is about 65 000px (or 80 times the height of the LayoutRoot - I used 1280*1024 resolution with the LayoutRoot grid being about 770px) the shape is drawn incorrectly:

Read the rest of this entry »
Posted in Silverlight | No Comments »
Recently I wanted to implement a very simple file upload component in Silverlight that uploads a single file and if possible shows upload progress. Having done some search I’ve found numerous examples but all of them seemed too complex for the simple task of uploading a file so I implemented a really lightweight solution. The source code can be downloaded from here: SimpleFileUpload.zip
Uploading files in Silverlight
Uploading files is quite an easy one in Silverlight: it’s basically just a request made to another server and the file contents are passed in this request. A possible way of implementing this is by using the WebClient class:
private void UploadFile()
{
FileStream _data; // The file stream to be read
string uploadUri;
byte[] fileContent = new byte[_data.Length]; // Read the contents of the stream into a byte array
_data.Read(fileContent, 0, _data.Length);
WebClient wc = new WebClient();
wc.OpenWriteCompleted += new OpenWriteCompletedEventHandler(wc_OpenWriteCompleted);
Uri u = new Uri(uploadUri);
wc.OpenWriteAsync(u, null, fileContent); // Upload the file to the server
}
void wc_OpenWriteCompleted(object sender, OpenWriteCompletedEventArgs e) // The upload completed
{
if (e.Error == null)
{
// Upload completed without error
}
Upload Progress Indicator
The above solution does the job of uploading the file well. However it does not indicate file upload progress at all: when uploading large files or when having slow internet connection this behaviour would be desirable.
Silverlight has no built-in way to monitor the number of bytes sent which means that the only way to indicate upload progress is sending the file to the server in multiple, smaller chunks. Of course this behaviour needs support from the server side as well.
The idea is that multiple calls are made to the server, every call submitting the next chunk of the file. On the server these chunks are appended to the file.
Read the rest of this entry »
Posted in .NET, PHP, Silverlight | 7 Comments »
Sense/Net 6.0, the .NET Open Source Enterprise Content Management System has released its latest, Beta 4.3 version with Active Directory synchronization implemented. This is a small feature addon to the Beta4 version of the software, which among others implemented workspace support probably first in the open source .NET ECM world.
You can see the original announcement on the Sense/Net development blog and you can download and play with the newest release from the Sense/Net project on Codeplex.
Posted in Sense/Net 6.0 | 2 Comments »
Note: before reading this article please see my views on comparing ORM tools. In short: this comparison is not suitable for comparing NHibernate and Entity Framework, due to the complexity of the tools vs the simplicity of this test; treat this post accordingly.
The reason I’m revising previous results is because some members of the NHibernate community looked into the code and discovered that the comparison wasn’t totally fair. While the test cases with Entity Framework used batch operations, the NHibernate implementation had this feature turned off. Tuna Toksoz was kind enough to re-write the critical parts of the code and apply settings enabling batching, you can download the revised source code here.
Note that I’ve made the source open for two reasons. First, I’d like the tests to be reproducible. And more importantly: I have experience with the two frameworks however I’m not an expert at any of them: therefore treat the results with caution. Anyone is free to analyze the source and if there are some issues in the code resulting in major performance drops, please let me know.
After Tuna modified the code NHibernate storage speed rocketed up compared to the previous version:
| Framework/ No. of operations |
1K |
3K |
8K |
14 K |
23K |
33K |
40K |
| NHibernate |
1,22 |
3,25 |
8,98 |
13,11 |
28 |
38 |
46 |
| Entity Framework |
2,11 |
6,18 |
18,4 |
31,3 |
51,7 |
77 |
98 |

However improving performance does not stop here. Fabio Maulo posted a great article on why the original code was far from optimal and improved runtime results even more.
Conclusion
As I’ve stated before I don’t beleive there is a good way in comparing ORM frameworks and even if there were, this little test certanly is not it.
As the contribution of the NHibernate community members showed the more complex and configurable the tool, the more experience you’ll need to make the best of this. If you’re working on a performance critical product, you’d better know you’re tool well and use it accordingly.
But which one should I use?
From the current results it seems that there is no major performance difference between two tools and even if there is it might be due to misuse. So my advice is to use which ever tool suits you more based on its features.
At first glance Entity Framework seems to have a shorter learning curve as well as some nice integrated VS tools to make development easier. On the other hand there is a constantly active and helping NHibernate community always ready to answer questions and NHibernate seems to be much more customizable at a higher level. Also see this thread on EF vs NH features and learning as well to help decide.
The decision is up to you which one you find more suitable for your needs. However since both are proven and mature solutions you won’t be making a big mistake going with which either.
Posted in ORM | 6 Comments »
Posting of the previous performance comparison results (see here) has caused a much greater response I ever expected as well as some confusion about the goal of this test that I would like to respond to.
How real (world) is this?
Most importantly a performance test is useful if it can be used for predicting performance of a real world application. Now the performance test in I did was a really primitive, batch based CRUD test. Unless you are developing an application that does batch actions such as in this test, the results can’t really be used for predicting performance of real world applications. We’re talking about two mature frameworks with lots of additional services – e.g. caching and transaction handling – that are not evaluated in this test even though they can have a huge impact on performance.
Be a little sceptic
I would suggest treating results with caution and checking on the source. There are a lot of people expert on a single ORM framework, some are experts on two but it mostly stops there. Unless stated that the author(s) is/are experts on the topic I would approach these results in a sceptic way.
As for my own case: I do have experience with the tested frameworks however am far from being an expert with any of them – so treat my results with caution. I’ve published the so anyone can analyze it and if there are some issues in the code resulting in major performance drop, hopefully someone will let me know – just as some members of the NHibernate community did after publisihing the first results.
There is no “best”
I believe there is no valid way to decide which framework is ultimately better. There is an ongoing debate about ranking ORM tools and how well a test like this is good for deciding on which framework is better. I think it is not. Just to mention a few reasons:
- Most real world applications have a far more complex working than this test simulates. What’s more, commonly used additional framework features – e.g. caching, transaction handling – are not tested at all even though these features can have a great impact on real world performance
- Performance may not be everything. Even if these performance tests would reflect performance in a real world environment (as they don’t), ORM is not used based on performance. When using an ORM tool you make a compromise to have worse performance than using native SQL and gain additional features. It’s usually a tradeoff: the more features you get, the bigger the overhead will be.
There is one case when this kind of test can be useful though. If you find a great performance difference between two frameworks (e.g 50-1000 times), it’s a good indicator that there’s either some issue with the test itself or the framework. If you’re sure that the test is written correctly this comparison could lead to the analysis of why the framework is unacceptably better than the other. If you can find the valid answer, then good. If you can’t, now that’s when things get interesting and the test was worth doing.
The best valid way of comparing an ORM tool in my opinion is based on the project you need it for. Write together your needs, weigh them and evaluate the frameworks accordingly. ORM tools are comparable just as cars are. You can’t decide which one’s better unless you know what to use it for. An F1 car may be great for a speed race but would utterly fail in a desert challenge.
Posted in ORM | 2 Comments »
As part of my thesis I measured the performance of some .NET ORM frameworks including NHibernate and Entity Framework. Measuring was done by implementing two simple applications using the same table structure and doing the same operations on the same data.
Note: before reading this article please see my views on comparing ORM tools. Also see the follow up post to this comparison for revised results.
I measured the time it took for each framework to complete these operations:
- store
- read over relations
- read by ID
- update
- delete
The results were somewhat interesting. Here is a short summary of what I’ve found out.
| Operation \ Number of operations |
NHiberante - 4K |
Entity Framework - 4K |
NHiberante - 40K |
Entity Framework- 40K |
Winner |
| Store |
37,37 |
9,19 |
1500 |
98 |
Entity Framework |
| Read over relations |
1,01 |
0,54 |
10,13 |
4,18 |
Entity Framework |
| Read by ID |
3,06 |
25,22 |
246 |
230 |
NHibernate with smaller amount of objects |
| Update |
6,61 |
7,34 |
77 |
72 |
Both |
| Delete |
3,35 |
16,76 |
58 |
1824 |
NHibernate |
Read on if you’re interested in the details of the performance measurements.
Update: the source code of the program used to measure is now available for download.
Read the rest of this entry »
Posted in .NET, Framework, ORM | 34 Comments »
I’ve recently written a blog post on Sense/Net being an open source alternative of Vignette v8 based on the preview video on Vignette v8 available online.
Stating that Sense/Net 6.0 is an alternative for Vignette v8 does sound really bold though. Vignette is (well, was, until Open Text acquired it) a company on NASDAQ with over 600 employees with an annual revenue well over $200M while Sense/Net is a company of 45 and an annual revenue of about $2M. Vignette probably spends 10x more money on R&D than the total annual income of Sense/Net. What are the chances that Sense/Net can make a software even comparable to Vignette? Practically nothing.
The reason however that I made this statement is because I couldn’t prove the other way round - that Vignette is far more advanced than Sense/Net. The easiest way would have been to place the two products next to each other and evaluate them (actually this is what some vendor neutral companies like CMS Watch or J.Boye do in the forms of reports). As a simple developer/blogger though I didn’t have that option. An evaluation version of Vignette is not available for me - or even my company: we are just too small for a such a giant. So that left me to compare with the sources Vignette provided: the video and their webpage. And based on this pretty much the same functionality can be achieved with our open source software. If you are a developer you can even install the portal featured in the video and try our yourself.
I know that the comparison is not fair at all and that Vignette has a huge number of features that Sense/Net does not. I would love to get more information on Vignette to have a better comparison so if there is any publicly available data/demo other than on the Vignette v8 page, please let me know.
Disclaimer: I am a member of the core team developing Sense/Net 6.0.
Posted in Sense/Net 6.0 | 2 Comments »