Skip to main content

Rapid Business Development: LightSwitch vs. Dynamics CRM vs. SharePoint vs. ASP.NET MVC

Over a year ago I wrote a post where I compared four technologies that can be used to build business applications rapidly. The original post was inspired by how similar a number of products have become over the last few years and more importantly how Visual Studio LightSwitch, which is a specialized rapid business tool development platform built on top of Visual Studio, is going to affecting the development eco-system. That post was written in the LightSwitch Beta 2 timeframe and the world has changed a lot since then – LightSwitch has shipped, not once but TWICE! So it is about time it got a refresh.

As with the previous post I am going to compare LightSwitch against Dynamics CRM, SharePoint & ASP.NET MVC Scaffolding. If you are not aware of these different products see my older post for a brief overview of them.

I think the differences between these four are very interesting and while each has its strong & weak points, this should definitely not be looked at as a pick one only post. There are many scenarios where you want to combine them for even better experiences.

To be clear that ASP.NET MVC is greater than ASP.NET MVC Scaffolding – you can do almost anything with MVC, however for this article we are looking at the concept of rapid development and comparing MVC with MVC scaffolding, scaffolding will give you a more rapid development with trade-offs. An example of this is databases supported, where MVC supports anything .NET does but scaffolding is a subset of databases.

I have broken down the issues into twenty two (!) aspects (key points we can compare them against each other) which are grouped into six scenarios to make it easier to digest. Each scenario starts with a list of the aspects and a brief description followed by a comparison table of those aspects. All the aspects are numbered so you can easily scan the table & if there are notes available the information will give you the relevant note numbers (see image below for more info).

image

Starting

  1. Ready to go out of the box: Once installed, can it do anything? Seems silly, but quick turnaround at the start, even if actual development is longer is important as it helps with prototyping, shows some rapid development and hints at how hard it is to learn (for me at least, if it does something I find I can experiment and learn quickly). Important to note, we are not looking at making it align with your company needs here, we just want it to do something. Eating CPU cycles & RAM is not something either.
  2. Northwind Style Sample development costs: This aspect looks further than the above aspect and looks at how much more would it take to get it tailored for a company, like the fictional Northwind, to have a XRM type system as it can be done across all four. Fewer $ signs means less time and/or resources for the functionality.

LightSwitch (LS)

Dynamics CRM

SharePoint 2010 (SP)

ASP.NET MVC

My Notes

Aspect 1

Ready to go out of the box
(faster is better)

Medium

(see note 1)

Fastest

(see note 2)

Fast

Slowest

(see note 1)

  1. LS & MVC need development, while SP needs at least 5min of tailoring.
  2. CRM, is ready to go once installed.
Aspect 2

Northwind Style Sample development costs
(less is better)

$

(see note 2)

$$

$$

$$$

(see note 1)

  1. ASP.NET MVC has the highest development costs as so little is out of the box.
  2. LightSwitch excels in this scenario.

Finishing

  1. Cost for on-premise deployments: This looks at the money cost for licensing to get the solution up and running on premise (i.e. in your company). Licensing is, of course, flexible and this will vary based on who you are – so this is not indicative for all. It does not include such things as server hardware or common costs, for example operating system licensing.
  2. Deployment Complexity: Getting a solution up and running shouldn’t be difficult for an organization and a lot of time can be lost (and costs incurred) changing, upgrading and troubleshooting systems that do not want to be deployed.
  3. Deployment Documentation: When it happens that you need to deploy, having a wealth of documentation (be that video’s, best practice guides, troubleshooting material) is vital and plays a large part in getting a solution up that works every time.

 

LightSwitch (LS)

Dynamics CRM

SharePoint 2010 (SP)

ASP.NET MVC

My Notes

Aspect 1

Cost for on premise deployments

$$

Visual Studio licenses. No per user costs.

(see note 2)

$ to $$$

Cost per user & cost per server. Visual Studio only if you are doing integrations or custom workflows.

(see note 1)

$$$$ to $$$$+

Cost per user & cost per server. Visual Studio licenses for any serious work.

$$

Visual Studio licenses. No per user costs.

(see note 2)

  1. CRM on the small scale with low development is very cheap but since you pay per user can get expensive.
  2. LS & MVC only have development software costs, which is more expensive up front but do not increase as you add users to the system.
Aspect 2

Deployment Complexity
(easier is better)

Easy

(see notes 1 & 2)

Hard

(see note 1)

Hardest

(see note 1)

Easiest

(see notes 1 & 3)

  1. LS, CRM & SP all have requirements that they need to work, in increasing deployment complexity, but CRM & SP are significantly harder than LS though due to their more complete product nature.
  2. LS has a deployment system which makes it significantly easier to deploy.
  3. MVC is easiest because there is no constraints from it and with using web deploy it solves many of the headaches for administrators.
Aspect 3

Deployment Documentation

Yes

(see note 2)

Yes

(see note 2)

Yes

(see note 2)

Yes

(see note 1 & 2)

  1. With the introduction of Web Deploy, ASP.NET MVC applications have gained not only excellent tooling but also documentation.
  2. All four have GREAT communities to help as well!

User Experience

  1. Front End Technology: A good looking, feature rich UI can seriously ease adoption, and what we are looking at here is the richness level of technology used for the out of the box front end user interface.
  2. How good the standard UI looks: Completely subjective and really this is based on what I think looks best.
  3. Flexibility of out of box front end: In this aspect we are concerned about how easy it is to adjust and tweak the out of the box front end.
  4. Themability: Corporate branding is massive business and making sure the application out of the box looks like it is part of your business is important. It is important to note that both CRM & SharePoint can have custom front ends built which enable this scenario, but that requires extra development, and we are focusing on the out of the box options here and assuming you have the theme built already.

 

LightSwitch (LS)

Dynamics CRM

SharePoint 2010 (SP)

ASP.NET MVC

My Notes

Aspect 1

Front End Technology

Silverlight. Supports out of browser (desktop) & in browser
Future: HTML 5

(see note 1)

Web

Just ASP.NET

Web

ASP.NET under the covers with sprinklings of Silverlight

ASP.NET

(see note 2)

  1. LS is hampered here with the lack of communication about the Silverlight future – I wrote about this early this year. If you can avoid that pitfall, then it has the most user rich experience of all. Microsoft has also announced that LS will support HTML 5 in the future.
  2. ASP.NET MVC out of the box scaffolding isn’t pretty (that is subjective to my views of pretty – that said it has improve a lot in .NET 4.5) but can easily be improved.
Aspect 2

How good the standard UI looks (very subjective)
(higher is better)

Medium

(see note 2)

Medium

(see note 3)

Today: Very Low

Future: Medium

(see note 1)

Depends on your web designer

(see note 3)

This is the most subjective aspect:

  1. SP2010 (today) has a fairly plain out of the box UI with a bad UX to go with it. However the 2013 version of SP has a much better UI out of the box.
  2. LS ships with two UI, a ribbon inspired UI called Metro and another one called Cosmopolitan – which is a much better UI for business UI. 
  3. CRM is much better out of the box and if you are going down the MVC route you will likely be taking advantage of the best UI thanks to the complete flexibility – but that depends on how good your designers are.
Aspect 3

Flexibility of UI development in the tool
(higher is better)

High

(see note 1)

Medium

(see note 2)

Medium

(see note 2)

High

(see note 1)

  1. MVC & LS can almost do anything on the front end, especially if you combined MVC with Silverlight.
  2. SharePoint & CRM too have lots of options and work with Silverlight.
Aspect 4

Themability
(higher is better)

Today: High

Future: Highest

(see notes 1, 2 & 3)

Low

(see note 4)

Medium

(see note 3)

Highest

(see note 1)

  1. The flexibility of MVC is highest as it is a pure programming, with LS following up thanks to its strong theme support (it allows for the theme & layout to be handled separately too).  It is also important to point out the vast number of themes & shells in the community for MVC & LS.
  2. When the HTML client ships for LS, themability will be done using CSS and will be very powerful.
  3. SharePoint can be themed but not the same level as LS.
  4. CRM will always look like CRM.

Extensibility

  1. API for integration: In the short term having an API means it is easy to get data into your new solution, in the medium term it means more ways to sync data and mash up your systems and in the long term it gives you a way to get your data out. It is vital to have an API.
  2. Marketplace: Apple kicked the idea of having an AppStore into reality for many of us and now having a marketplace to get extensions, customisations or themes is an important aspect. I am ignoring public sites, like Codeplex for example, and only focusing on an official marketplaces. Galleries are just marketplaces with no vetting, which means they are bigger but the quality bar is not guaranteed.
  3. Additional Authentication Options: Only your employees or customers (which may be everyone if you are lucky enough) should access your solutions. What do we get out of the box to limit access to the system? All four systems support Windows & Forms based authentication so I am only listing other options which are available.
  4. Permission Structure (Authorisation): Being able to control what parts of a solution you can access, once you have logged in is also vital and having a lot of flexibility in this space is also important as very seldom will one structure work for everyone.

 

LightSwitch (LS)

Dynamics CRM

SharePoint 2010 (SP)

ASP.NET MVC

My Notes

Aspect 1

API for integration

Yes

(see note 2)

Yes

(see note 3)

Yes - at least 5 of them.

(see note 3)

Yes

(see note 1)

  1. MVC you can use the WebAPI to get an API for almost free or you can build a custom one.
  2. LS creates OData services for us. LS also now has the option of a service only deployment which does enable it to be a pure API system.
  3. CRM & SP both have API’s, but SP is more complex as it supports so many different API’s with different subsets of features supported.
Aspect 2

Marketplace

Gallery available

(see note 3)

Yes

(see note 1)

Nope

(see note 2)

Gallery available

(see note 3)

  1. CRM leads here in a big way with a REAL marketplace.
  2. ASP.NET MVC has its own gallery plus a strong 3rd party marketplace ecosystem.
  3. LightSwitch uses the same gallery as MVC, but with a much smaller ecosystem than MVC.
Aspect 3

Additional Authentication Options

Anonymous, Custom, Windows Authentication (AD) & Forms based.

(see notes)

Claims based authentication via STS

Anonymous and more available through custom development (e.g. Windows Live). Claims based authentication (custom development required).

Anonymous and more available through custom development (e.g. Windows Live). Claims based authentication (custom development required).

LS makes use of ASP.NET Authentication Provider so it fits nicely into the technologies developers already know.

Aspect 4

Permission Structure (Authorisation)

Very complete model for permissions. Minor coding required.

(see note 2)

Fantastic out of the box option, plus plenty of extensibility if needed.

(see note 3)

Good structure with many levels of customisation.

Out of the box is very simple.

(see note 3)

Basic support for it but can be extended through development. A lot of XML work though may be needed.

(see note 1)

  1. MVC is the lightest here, supporting authorisation options but enforcing it is up to the developer to implement.
  2. LS is much better with a great model & UI options out of the box. The only downside being that some magic strings need to be configured during development and enforced with simple (one liner) code.
  3. SP authorisation is as varied & powerful as what CRM offers. However SP get messy, users can easily can break permission inheritance, while CRM enforces authorisation all the time and makes for a better structured environment.

Information Worker Features

  1. Offline support: Being able to work when you are not in the office is a vital need for many people. So how do these platforms enable that scenario? In theory it is always possible to build this, so we are just looking at the out of box offering. This scenario is focused on offline with a laptop, not a tablet or mobile phone.
  2. Easily Import Data: How do we get information into the solution, besides the API? Does the product make this easy with out of the box tooling?
  3. Printing: Despite the promise of a paperless office, it still is not the case and being able to print is important, even if it is just to XPS or PDF for invoicing.
  4. Office Integration: Integration into Microsoft Office products (i.e. Word, Excel, Outlook, PowerPoint, Access, Publisher, and InfoPath & OneNote) means that your IW’s will be able to work in the tools that they are comfortable with, easing adoption and productivity.
  5. Mobile Device Support: Information workers are increasingly mobile and having good mobile device support is a critical feature. When I look at this I am not just thinking about the simple, does it support it but also how well it supports mobile devices.

 

LightSwitch (LS)

Dynamics CRM

SharePoint 2010 (SP)

ASP.NET MVC

My Notes

Aspect 1

Offline support

No

(see notes)

Yes

(see notes)

Yes

(see notes)

No

(see notes)

Being able to work offline is important if you are a roaming user. LS & MVC offer nothing in this space while CRM & SP both offer offline via Outlook.

Aspect 2

Easily Import Data (out of the box)

Nope

(see notes)

Yes, from CVS.

(see notes)

Yes. Multiple options.

(see notes)

Nope

(see notes)

In all cases there are tools and other ways to import data (for example LS has the http://officeintegration.codeplex.com extensions) but CRM & SP have an out of the box options.

Aspect 3

Printing (out of the box)

Nope

(see note 1)

Yes

(see note 4)

Yes – Poor

(see note 3)

Browser Level

(see notes 1 & 2)

  1. LS & MVC can have custom development solutions for printing, other than that they both offer nothing out of the box.
  2. As browser printing has improved MVC has a slight advantage being HTML based normally.
  3. SP has printing, but it is very poor.
  4. CRM leads the way here with a great print scenario.
Aspect 4

Office Integration

Low

One way export to Excel in out of browser mode only.

Others can be custom developed or use the OfficeIntegration extensions (http://officeintegration.codeplex.com)

Medium

One way to Excel. Mail merge with Word & Outlook.

Deep integration with Outlook is available too.

High

Only Publisher doesn’t have some integration with SharePoint.

Every other Office product does, some like Excel are one way while others like Access are two way.

SP internally has features that understand Office files too, for example PowerPoint Libraries show thumbnails.

None

Can be custom developed.

 
Aspect 5

Mobile Device Support

Today: Limited

Future: Fantastic

(see note 1)

Good

(see note 2)

Okay

(see note 3)

Fantastic

(see note 4)

  1. LS is today hampered by Silverlight which isn’t supported by any mobile platform, but the OData service really does make it easy to build mobile solutions. The HTML 5 future for LS does solve this completely.
  2. CRM has good features today with mobile apps for some platforms and an API that enable custom solutions to be built.
  3. SharePoint offers limited apps for platforms, but does have an out of the box system – however the out of the box HTML system is severely limited.
  4. ASP.NET MVC 4.5 has introduced fantastic new mobile support into the framework and thus is clearly today’s leader for out of the box.

Other

  1. Databases Supported: Where the data can come from for your application is a critical piece of the puzzle because it means the difference between building ETL solutions to handle moving it around if the source is supported or having it just work.
  2. Minimum Skills for Tailoring: Tailoring is what I refer to when I think of customisation of a system, without the need for a programming language. At some point you will need a developer but how far away that is and what can be done by a analyst or super user early on is important from a time to solution and cost perspective. Lower is better here.
  3. Can run in the cloud? If you not thinking about how you can leverage the cloud, then you are not thinking. Making sure the solutions can cater for the cloud is an important consideration. All four solutions can run in the cloud but how do they run is also important
  4. ALM Experience: How does this tool work with a full ALM experience? Can I unit test it easily? Will it go into source control easily and what happens when multiple developers are updating the same files? How about build server and development tool integration? All important questions in understanding a complete picture of that these tools cost or what you sacrifice with some of them.
  5. Requires Silverlight: Despite decent market penetration and ease of deployment in corporate scenarios, the requirement for Silverlight can be a deterrent to business, especially those where the CEO uses an iPad. This is not answered in the table as only LightSwitch requires Silverlight today (in the future it will support HTML). CRM has no dependencies, SharePoint has a fall back mode and if you used Silverlight with MVC it would be possible to have a fallback mode, provided you developed it.
  6. Data performance: This is also not in the table since it only applies to LightSwitch. For CRM, MVC & SharePoint I assume your front end (web) is always close enough, for example the same LAN, to the database but in LightSwitch you can really separate them. Here it is important to note LightSwitch is NOT great with data performance between backend & frontend out of the box, however with careful tailoring of data sources & screens you can greatly improve it. It sends massive amounts of data around. In my view it really does not feel optimised for low bandwidth WAN scenarios.
 

LightSwitch (LS)

Dynamics CRM

SharePoint 2010 (SP)

ASP.NET MVC

My Notes

Aspect 1

Databases Supported

Out of the box:

  • SQL Server
  • SQL Azure
  • SharePoint
  • Anything supported by WCF RIA services
  • Anything supported by OData
  • Anything that has an Entity Framework provider
  • Custom connectors can be developed for other databases.

SQL Server

SQL Server normally.

With advanced skills can use external data sources with BDC.

External content types can also be used in place of BDC with a lower skill set (power users) but at a smaller feature set supported.

For scaffolding anything supported by LinqToSQL or Entity Framework.

 
Aspect 2

Minimum Skills For Tailoring
(lower is better)

Low

(see note 3)

Lowest

(see notes 1 & 3)

Low

(see note 1)

Highest

(see note 2)

  1. Being able to tailor with less skill is a big plus for CRM & SP.
  2. MVC doesn’t have tailoring as it is all development.
  3. LS really stuck in the middle ground here – for setting it up nothing more than power user is needed and developers only needed for more complex situations, in the same was as CRM – however the requirement of Visual Studio may scare off non-developers thus it is not as low as CRM.
Aspect 3

Can run in the cloud?

Platform as a service using SQL Azure for database & compute instances for front end.

Also supports the new Azure Websites options.

Software as a service: Can get it from Microsoft & Partners at a cost per user per month.

Software as a service: Can get it from Microsoft (Office 365) & Partners at a cost per user per month.

Platform as a service using SQL Azure for database & compute instances for front end.

Also supports the new Azure Websites options.

 
Aspect 4

ALM Experience
(higher is better)

Medium

(see note 3)

Low

(see note 3)

High

(see note 2)

Highest

(see note 1)

  1. ASP.NET MVC is a pure development experience and so works well with ALM.
  2. SP plus Visual Studio 2010 or 2012 is a great ALM experience (although mocking is difficult).
  3. LS & CRM are oddly very similar with customisations in XML though so expect some source control pain. Plugin’s for CRM and LS Extensions are a great ALM scenario. CRM falls short in the unit testing scenario though.

Finally

A post like this is not possible to do without some amazing people providing feedback and I want to say a special thanks to:

SharePoint and protocol-relative URL's

Introduction to protocol-relative URL’s

Recently I learnt an amazing new trick, the protocol-relative URL where the scheme of a URL (the http bit) can be dropped and your browser will use the same scheme as the page’s URL uses. This is very useful for when you have a website on http & https. For example you can set a image URL to be

//demo.com/horse.png and if you browse to http://www.demo.com then it will load the image from http://demo.com/horse.png, but if you got to https://www.demo.com then it will load the image from https://demo.com/horse.png – and this works with CSS & JavaScript too!

This is not some odd browser trick, this is in the standard for how URL’s work!

To be clear this is similar, but not the exact same as absolute & relative URLs.

SharePoint

SharePoint (and for this post, this has only been checked with 2010 so your mileage may vary on newer/older versions) does not follow this standard and actually breaks protocol-relative URL’s in two ways.

Front End

If you are working on the SharePoint UI and putting content in a content editor web part or an text column in a list and you edit the HTML and put in a protocol-relative URL SharePoint and hit save SharePoint will “fix” it by putting the current scheme in for you! So no matter what you do, on the front end you are completely stuffed.

Example

You put in <img src=”//sharepoint/horse.png”/> SharePoint will change it to <img src=”http://sharepoint/horse.png”/> (assuming your page is on a http scheme).

Back End

The other scenario is you are working with the SharePoint web services, for example the list service, and setting the HTML that way – SharePoint once again will try and “fix” things. Interesting it does something completely different to the front end. I guess the front end uses JavaScript and the back end uses some other code. It removes the attribute completely from the HTML.

Example

You put in <img src=”//sharepoint/horse.png”/> SharePoint will change it to <img /> – yip the src attribute is gone.

Outlook 2013 Preview: The Case Of The Missing Email

Office 2013 is available in preview and being the fan boy researcher I am, I am running it. In the last week I have had an odd problem – it started when someone told me they had emailed me, but I never got it. I logged a call with the IT desk at work and they were able to find it in OWA (Outlook Web Access), and then suddenly I had it in Outlook too. I am over worked and tired maybe I just missed it – that was the thought I had, so I left it and went on believing I need a holiday.

Then yesterday I was in OWA and saw I had 25 unread while Outlook had 0 – I AM NOT CRAZY.

image

I logged a call again with the IT desk and got some awesome feedback – it is still too early to say it is fixed but I will update this post as I know more.

Patches

There is a patch already for Outlook 2013 available at: http://support.microsoft.com/kb/2737132

Not sure what it exactly does, but I am sure it is worth applying (blind faith that patches bring magic is a key requirement of a fan boy). It is worth nothing that Windows Update is not pushing this out – so you must manually get it.

Other sources of Help

There is a FANTASTIC page with 29 common issues for Outlook 2013 that is worth reading: http://www.howto-outlook.com/faq/outlook2013newandchanged.htm

One of those on their is about caching, which leads to…

Caching in Outlook 2013 is very different

Prior to 2013 Outlook would grab all the mail from the server and store it locally in an OST file giving you a locally cached copy of all the mail. Starting with Outlook 2013 that has changed, by default only the last 12 months are cached.

To change this to work like it used to:

Click File, then Account Settings ,then Account Settings…

Clipboard01

Next double click on your Exchange account.

Clipboard02

Here you’ll find a “Mail to keep offline” slider.

Clipboard03

Move that all of the way to the right to select "ALL" and restart your Outlook.

Clipboard04

Finally wait for it to update.

image

It is a preview

The last thing is a personal one – this is a preview, it is not promised to work. I have been so spoilt by great releases from Microsoft in the preview stages (Windows 8 & Visual Studio 2012) that I forget that it is a preview and could be broken. It is important to always have a backup & a way to verify it is working. For me this means I will be checking with OWA daily now.

Mythbusters: You should use an Array because it is the only collection that can be serialised

Another in my theme of investigating claims that to me sound wrong, this time that arrays should be chosen over other collections because only arrays can be serialised (or put differently, no other collection can be serialised).

For this I am assuming serialised means to XML, and it also means serialised easily. In theory anything can serialised as it just a concept, which is why I am assuming easily – i.e. no custom code outside of invoking built in framework serialisation.

Serialisation with XmlSerialiser

private static string Serialise<T>(T o)
{
    var serializer = new XmlSerializer(typeof(T));
    var memoryStream = new MemoryStream();
    serializer.Serialize(memoryStream, o);
    memoryStream.Position = 0;
    using (var reader = new StreamReader(memoryStream))
    {
        return reader.ReadToEnd();
    }
}

With the above code you can pass in an array and spits out XML. It also works perfectly with ArrayList & List<T>. This does fail with LinkedList<T> and Dictionary<T,K> which is annoying.

Serialisation with DataContractSerializer

The myth I think comes from lack of knowledge of what is in the .NET Framework, in this case thinking there is one way to serialise something when the framework ships with many of them. So lets use DataContractSerializer this time and see:

private static string Serialise2<T>(T o)
{
    var serializer = new DataContractSerializer(typeof(T));
    var memoryStream = new MemoryStream();
    serializer.WriteObject(memoryStream, o);
    memoryStream.Position = 0;
    using (var reader = new StreamReader(memoryStream))
    {
        return reader.ReadToEnd();
    }
}

Using this Array, ArrayList, List<T>, LinkedList<T> & Dictionary<T,K> are all serialised!

Myth Outcome

BUSTED! There is a simple way to serialise the collection classes in the framework – so array’s are not the only thing that can be serialised!

File attachments

MythBusters: Arrays versus Collections

Code now available at https://github.com/rmaclean/ArrayFighter. If you wish to suggest a flaw or make a suggestion to improve it please create a pull request OR give me a detailed comment explaining what is needed, why it will help/hinder etc... ideally with links.

The myths I want to tackle are:

  • Arrays are not collections
  • Arrays are faster than collections

These are two statements I have heard recently and I initially felt are wrong, so to check I myself I decided to research this myth. I am assuming when people say collections they mean classes in System.Collections or System.Collections.Generics.

Arrays are not collections

In computer science, an array type is a data type that is meant to describe a collection of elements

Source: http://en.wikipedia.org/wiki/Array_data_type

So we have established that they are collections but how to they compare to say .NET collection classes like List<T>, ArrayList & LinkedList<T>?

List<T>

Official Documentation: http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx

What it implements

The first aspect is what interfaces are implemented in each, and you can see below both implement the same interfaces that deal with collections and lists. Note that since List<T> is generic we have both generic & non-generic interfaces.

Where is the data?

Where does List>T? store data? In an internal field: _items which is just an array of T.

So List<T> is just an array? Yup! So how does it handle inserting new items? It increases the array size when needed by creating a new array and copying the pointers to the items into it.

Complexity of the operations

  • Add: O(1) operation. If the capacity needs to be increased to accommodate the new element, this method becomes an O(n) operation, where n is Count.
  • Insert: O(n) – where n is count
  • Remove: O(n) – where n is count

ArrayList

Official Documentation: http://msdn.microsoft.com/en-us/library/system.collections.arraylist.aspx

Let me warn you about ArrayList, if you are using .NET 2.0 or higher and you are using this class, I have the full right to smack you across the face with a glove. There is NO REASON TO USE THIS ANYMORE! Use List<T> instead, it is faster & safer.

What it implements

The first aspect is what interfaces are implemented in each, and you can see below both implement the same interfaces that deal with collections and lists.

  • Array implement: ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
  • ArrayList implement: IList, ICollection, IEnumerable, ICloneable

Where is the data?

Where does ArrayList store data? In an internal field: _items which is just an object[].

So ArrayList is just an array? Yup! So how does it handle inserting new items? It increases the array size when needed by creating a new array and copying the pointers to the items into it.

Complexity of the operations

  • Add: O(1) operation. If the capacity needs to be increased to accommodate the new element, this method becomes an O(n) operation, where n is Count.
  • Insert: O(n) – where n is count
  • Remove: O(n) – where n is count

Did you copy and paste List<T> for ArrayList?

Yip – because they are virtually the same, in fact the only core difference is that the internal storage is object[] versus T[]. That has side effects, like the Add methods taking in T versus object but that is it!

LinkedList<T>

Official Documentation: http://msdn.microsoft.com/en-us/library/he2s3bh7.aspx

So now we are onto something really different. An Array (and as we have seen ArrayList & List<T>) assign a continuous block of memory (number of items * item size) and then put the items in there are the correct offset.

This has the benefit for reading, for example if I need item 6, all I do is work out 6 * item size + start of array in memory and boom I am at the item. However, the problem is when I run out of space – List<T> & ArrayList solve this by making new bigger arrays! The cost of this is very high indeed (two arrays, having to copy all the items from one array to another, cleanup of the first array).

LinkedList is different, it knows about the first item in the collection, and that item has a property to the next item in the collection and so on. This means that I can add infinitely and never have issues as all I do is get the last item, and set it’s property to point to the my new item. Inserts are also way faster compared to arrays – rather than having to move all items down (as Arrays must) we just need to adjust the properties of the item before & the item I am inserting. So it is awesome? Nope – Reading is way slower.

If I need to get to item 6? I need to go to item 1, then item 2 and so on – moving along the entire way. It is slow, VERY much so. However moving backwards may be faster! This is because the node has not only a property that shows the next item but also a property that shows the previous item. So if I need to move one back it is very quick and easy, compare to arrays where I need to go back to the start and apply some math. Performance of moving backwards will really depend on how many steps backwards & the size, so in some cases array may still be faster.

What it implements

The first aspect is what interfaces are implemented in each, and you can see below both implement the same interfaces that deal with collections but not lists. So it is a collection, in the .NET sense, but not a list. It also contains the generic and non-generic versions.

  • Array implement: ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
  • LinkedList<T> implement: ICollection<T>, IEnumerable<T>, ICollection, IEnumerable, ISerializable, IDeserializationCallback

Where is the data?

LinkedList<T> stores the first item in the list in a field called head which is of type LinkedListNode<T> which points to the first node in the collection. That is it, thee rest of the items in the collection are just linked to the head.

Complexity of the operations

Myth Outcome?

BUSTED! Arrays are collections, in both CS & .NET definitions.

Arrays are faster than collections

imageSo let’s see if they are with some micro-benchmarks & the code, if you want to dispute, is below.

I ran 6 tests on Array, ArrayList, List<T>, LinkedList<T> & Dictionary<T,K>

The tests were:

  • If we know we have 1000 items ahead of time – optimise and insert 1000 ints.
  • Insert 1000 ints, but do not preallocate any space more than 4.
  • Read every item in an collection of 100 and validate it.
  • Get the 100th item and validate it.
  • Get the 100th item, and then the 99th item and validate it.
  • Get an item based on a key
  • Insert an item at position 0.

Results

9 July 2012: As I added a new test I re-tested everything (so numbers & chart has been updated) – however the winner did not change on the tests.

Inserting into a known size?

Winner: Array

No surprise here.

LinkedList disqualified because you can’t preallocate.

Disqualified

  • Dictionary: Needs a key – we only have values in this test.

Inserting into an unknown size?

Winner: List<T>.

Interesting is that I would’ve assumed LinkedList to be faster & ArrayList to be closer to List<T>.

In hindsight it makes sense that LinkedList is slower – it needs to find the last item first as we we are adding at the end.

Disqualified

  • Array: Disqualified since it can’t magically expand like the others.
  • Dictionary: Needs a key – we only have values in this test.

Read every item?

Winner: Array

Disqualified

  • Dictionary: Needs a key – we only have values in this test.

Get Item 100?

Winner: ArrayList.

Interesting here since I would’ve guessed Array but these are all so close it likely is just background noise interfering.

Disqualified

  • Dictionary: Needs a key – we only have values in this test.

Get Item 100 & 99

Winner: Array

This test was designed for LinkedList, so very surprised it didn’t win but these are all so close it likely is just background noise interfering

No surprise – it is perfect for this situation.

Disqualified

  • Dictionary: Needs a key – we only have values in this test.

Find with a key

Winner: Dictionary.

No surprise – it is perfect for this situation.

Insert At Zero

Winner: LinkedList<T>.

No surprise – it is perfect for this situation.

Disqualified

  • Array: No way to insert at zero.
  • Dictionary: Needs a key – we only have values in this test.

Raw Numbers

Test Array ArrayList List<T> LinkedList<T> Dictionary<T,K>
Known Size Insert Speed 0,0067952 0,0251845 0,0125625    
Unknown Size Insert Speed   0,0322676 0,0178365 0,0324339  
Read Every Item Forward 0,0081916 0,0135402 0,0124702 0,03132  
Get Item 100 0,0023351 0,0021007 0,0021014 0,0033034  
Get Item 100 Then Get Item99 0,0020214 0,0021889 0,002163 0,0032026  
Find Item With Key 0,0059856 0,0042258 0,0063673 0,0067397 0,0026851
Insert At Zero   0,0047753 0,0034568 0,0024224  

Myth Outcome?

BUSTED! Arrays are fast, taking half the awards for speed, but they are not universally the fastest (depends on situation) and also the other options are so close that performance is likely not the issue when considering which structure to choose.

Where do I start to learn Windows 8?

I have been asked at the talks I do, where can I go to learn Windows 8? What material is available? There is a LOT of content available for Windows 8. For me personally I learnt initially from the Windows 8 Camp in a box and building my own test apps. However the ever amazing Bruce Nicholson provided me with a fantastic list recently (so go thank him):

Presentation Dump - Mid 2012: .NET 4.5, Visual Studio, psake, JavaScript & Coded UI

With 2012 flying along it is time for the bi-annual presentation dump, where I upload most of the slides I have done in the last six months to share with you! I say most, as some presentations are NDA and those, unfortunately, I can’t share out – but where I can upload slides I do! I will also sometimes edit slides to exclude information that is NDA – so if you have questions let me know!

In this presentation dump we have:

  • What is new in .NET 4.5: This talk gives a big brain dump & a few demos of what is new & shiny in .NET 4.5. Focuses on the framework so it is mostly ignoring the language features (like async) & tooling features.
  • Visual Studio 2012 Preview: I gave this talk when it was still Visual Studio “11”, so you will see that a bit. Really covers what is new, improved and removed from the next release of Visual Studio. Definitely not a complete look, more a high light reel!
  • psake: A look at the psake tool and how it fits in the build/ci/deployment landscape.
  • JavaScript proven practises: One of my favourite talks so far this year – covers 12½ suggestions to improve the quality of your JavaScript! I am using this a lot as a reference guide when I build my code!
  • Automated UI Testing with Microsoft Technologies: A very interesting talk I gave about what Microsoft offers from a UI automation perspective for testers.

It seems like quieter period than ever before but it was not! In terms of number of unique slide shows that I can share it is very small as there is a fair amount of ones I couldn’t (even edited) and I also already uploaded two this year and finally a LOT of talks have been around Windows 8 and based on the camp in a box.

You can get all the slides and details by clicking “read more” below!

What is new in .NET 4.5

Visual Studio 2012 Preview

psake

JavaScript proven practises

Automated UI Testing with Microsoft Technologies

Windows Phone 8 Announcement - My cheat sheet of what was announced!

Windows Phone 8 Announced
Source: http://live.theverge.com/windows-phone-developer-summit-2012/

Out by Christmas (America fall really)

Same core as Windows 8 (i.e. desktop & phone are one platform!)
+ Hardware-wise, should mean a wider ranges of form factors, price points, and capabilities.
+ That means a bunch of stuff: kernel, networking, multimedia, driver support — that stuff will be shared with the two platforms.
+ IPv6
+ Improved Bluetooth
+ Hardware accelerated Direct3d
+ Manufacturers will be able to re-use the same hardware drivers they build for Windows 8 on Windows Phone 8.
+ "Dual-core & more...." CPU support

New resolutions
+ 800x480 (what we have today)
+ 1280x768
+ 1280x720
+ All 7.5 apps will run without changes on all resolutions!
+ Can optimise if you want to - OPTIONAL

Removable MicroSD support
+ Phones, music, videos & apps can all be put on the microSD

IE 10 built in
+ Same HTM rendering as desktop version

Native game development
+ DirectX is mentioned
+ I am reading that to be C++ support
+ Same drivers as Windows 8 so games can be ported quickly & easily

NFC support
+ Be able to share between devices
+ Will have a "mobile wallet"
+ Credit & debit cards
+ Loyalty & membership cards
+ Mobile wallet can work without NFC for some scenarios
+ All marketplace purchases now in the wallet
+ In App Purchases Supported :)
+ can do operator billing
+ Needs carrier "secure sim"
+ Tap & share (contact, files etc...) between devices built in!

Nokia mapping technology included in in Windows Phone 8
+ It will use NAVTEQ data, offline map support, map control for developers, and Turn-by-Turn directions.
+ Includes My Commute - remembers your daily route and shows alternatives that can improve performance

Enterprise
+ Encryption & Secure Boot
+ LOB app dev
+ Businesses can run custom secure app stores
+ Device management
+ Same tools we use today for Windows can be used to manage the phone!
+ Familiar office apps
+ I read that as normal office

New Menu UI
+ No more right hand side (apps list)
+ Just the main screen
+ Icons can be "normal", double-wide & small (one quater size)
+ Any tile can be any size
+ double wide for custom apps finally :)

Windows Phone Upgrade Story
+ 7.5 will get a bump to 7.8
+ 7.8 will include new start screen
+ Updates sent via Windows Update - BYPASSING OPERATORS!!
+ All devices to get 18 months of updates
+ Can register to get updates early too!
+ Source: http://www.winsupersite.com/article/windowsphone75/windows-phone-78-pre…
+ No 7.5 device to 8 though :(

Dev Features
+ Built in SQLite DB!
+ Speech platform will be open to all!
+ Can integrate any app into voice search
+ Can respond with voice prompts (can you say siri?)
+ Can develop in C#, VB, C++ or HTML 5!
+ Can mix & match

Built in VoIP technology
+ Skype fully integrated, looks & feels like a normal call
+ VOIP apps, not just Skype, can run in the background

Apps that use location can run in the background
+ Think map (direction apps!)

Camera
+ Self timer
+ Action shot for burst mode
+ Panorama
+ Group shot (take multiple photos and swop the faces - get rid of those closed eyes)

Who can see my tweets to a friend?

A while ago I wrote a post about an interesting Twitter behaviour – if you start a tweet with an @<username> only people who follow you & that person can see the tweet (if you unsure see the post which explains it). The question I had today was to find out who is in that list – or put who follows us both on Twitter?

Oddly, I could not find anything (besides some tools that cost money) to do this?! So I built my own awesome little tester you can use below:

First username
Second username

    For the developers among you who want to see how this all works? Check it out on bitbucket: https://bitbucket.org/rmaclean/twittercoalesce

    Known issues:

    • My website uses an older version of jQuery, and I use a newer one in this code. If the loading gives an error or gets stuck on the screen, try refreshing the page (seems to solve it).
    • If you have too many people shared between the two names - it will break. I am looking into how to solve this. If this happens - loading will get stuck :|
    • Twitter limits clients to 150 calls per hour. If the rate limit is exceeded the loading will get stuck.

    Lightswitch & the HTML Client - what does this mean?

    Lightswitch Recap

    For you to understand the rest of this post it is vital you have a high level understanding of Lightswitch and how it works. Lightswitch is a RAPID development platform from Microsoft that makes development of line of business (LOB) apps really easy. The team at Microsoft often talk about citizen developers – i.e. people who are not full time developers, but are the “IT guy” in the department or company that need to put together a great looking solution. The team also talk about no-code solutions – where you can build great systems without code.

    imageBoth statements from the team are true and false at the same time. Sure your accountant can build a CRM system with no code in Lightswitch, but Lightswitches true value is that it is a professional development tool, and in reality unless it is a really simple solution you will need a touch of code.

    What is great is that Lightswitch allows the citizen developer to write a system that can be matured by professional developers later on – it’s power is that it does not lock you into being too simple or too complex a development system.

    For me the value proposition is that you get REAL rapid development, that citizen developers can put together and extend solutions that are well architected and that when the need is there a professional developer can extend that solution and hand it back over to the citizen developer – it is the circle of Lightswitch.

    Architecture

    When you craft a (avoiding the development term here on purpose) Lightswitch create a multi-tier architecture, that is either two tier (client & database) or three tier (client, server & database). Two tier is really three tier but the server & client are just one package.

    The database can be any support by Lightswitch, the middle tier is OData and the front end is Silverlight. The choice of front end has recently hurt Lightswitch because Silverlight is dying. However if you step back for a second and think about it Lightswitch provides the easiest and fastest way to build a complete (and I mean complete, authentication, methods, proper designed) OData solution… you could always ignore the client portion and build on top of the OData server.

    Making a HTML Client

    The HTML client mode for Lightswitch is a recently announced new feature that allows you to build a client that runs in a browser, and not just Internet Explorer on Windows (Dynamics CRM I am looking at your shameful behaviour) but pretty much any browser, say on an iPad:

    Deployed app on ipad -1

    This is possible because of two things, the OData server which allows really any technology to connect to it, and the second piece of the Lightswitch system the LSML file.

    I hope you have never heard of the LSML file, as it is not a nice place to go to – it is a MASSIVE (even simple demo’s I build are thousands of lines) XML file that stores ALL of the Lightswitch system in a “Lightswitch domain language”. This enables the team to take that information, parse it and produce output based on it. So the concept of producing a parser that creates HTML rather than Silverlight is really simple… just build the parser.

    What do we know about this HTML client so far?

    It is early days, in fact there are no bits available yet, but we do know some things from the demo’s and screen shots that are available.

    • Multiple themes will be supported (their is a dark & a light at least) – thanks to the jQuery Mobile that powers it.
    • It is a separate client – so you will have a Silverlight experience and then also have the HTML experience added in.
    • It follows the true Lightswitch model of being easy to build with no code, but if you need that little extra, the JavaScript can be edited.

    Light theme - 2Dark theme -  2imageCustomizing UI with JavaScript

    The Important Two Issues

    To wrap this up it is a very exciting point in time for the Lightswitch world with so much happening that I think it is important to take a step back and find a few key aspects about this amazing feature that will help position it. There are two that really stand out to me from all the announcements:

    Separate Client

    This is not a Silverlight to HTML generator – it is separate. This means that awesome Silverlight chart you use today will not magically work in the HTML client. This has both advantages and disadvantages, but if you think about the dying of Silverlight I am very glad that they have a whole new growth path.

    It also allows for the real scenario of supporting a rich experience in Silverlight in a company (where we control all the machines and know we can run Silverlight for a long time still) and having a mobile or companion experience in HTML for those people on the road. Sure they do not get the great sales forecast chart but they can still capture their sales on their iPad.

    Web Developers

    A recent did an survey of app developers looked at what they are building today, what they were building and what they intend to build in the future (future = one year in this survey). Interestingly there are only TWO platforms that are getting growth in the future? HTML & Windows Phone. Android, iPhone and many others are all expected to decline.

    If you think about those numbers and add in the MASSIVE investments in HTML development that are in Windows 8, it should not surprise you that web development is a MAJOR area in the future of all developers. It also means that web developers can start to have way more opportunities in the market outside of building websites & portals, and that is very exciting as that little garage web designer company today could be a major line of business developer in a few years.