# Monday, 09 November 2009

I am in Berlin for TechEd 2009 while Germany is celebrating the 20th anniversary of the Berlin Wall falling. Today most of us take for granted the society we live in, however, when I was growing up Eastern Europe was “the enemy”, all colored red on a map. We were not free to do business with the “eastern block”, nor were we allowed to visit without permission. Today that is all gone and I now work for a company that was behind the “iron curtain”, a company that would never have existed if the Berlin Wall did not fall.

Last night we walked down by the Brandenburg Gate and downtown Berlin. I listened to amazing stories from my colleague at Telerik, Jan Blessenohl. Jan is German and was in university in 1989. On November 9th, he actually traveled to East Berlin to buy some cheap textbooks when the protests overwhelmed the Berlin Wall and when it fell he was right there at the Brandenburg Gate standing on the wall, a part of history.

It is amazing to be here today…

Update 1

The speaker gift at TechEd was a piece of the Berlin Wall!

Update 2 (Photos!)

I went to the Brandenburg Gate area near Potsdamplatz this evening to watch the ceremonies. What was really cool was that there were 1,000 foam dominos lined up to fall, each decorated by 1,000 artists around the world. Because there were 1,000 of them and it was pouring rain, I got to get up close to them and take lots of photos.

IMG_0765

Also a photo of the Brandenburg Gate:

IMG_0768

posted on Monday, 09 November 2009 04:25:15 (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Saturday, 07 November 2009

Next week I will be speaking at one of my favorite events, TechEd Europe, this year held in Berlin. While Barcelona is still my favorite city in the world, I am glad that we are in Berlin this year, since Monday is the 20th anniversary of the Berlin Wall falling, and our world changing forever.

I will be speaking on:

I speak on Tuesday and Wednesday, and the event is SOLD OUT. I hope you were lucky enough to get a ticket. I’ll be hanging out at the Telerik booth when I am not speaking if you want to come and say hi.

image

Technorati Tags: ,
posted on Saturday, 07 November 2009 03:17:24 (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Friday, 06 November 2009

I have been supporting PalDev, the first (and I think only) .NET User Group in Palestine for many years. It started as a vision of Jihad Hammad a friend of mine, about 6 years ago. Goksin Bakir, Malek Kemmu, and some others in the community have also rallied behind PalDev.  This is a user group that had its first meeting in a refugee camp, then moved to Al-Quds Open University. Now they have almost 200 members and just helped launch Windows 7 and organize Microsoft’s first ever TechDays in Palestine.

The event was a great success, held over three days in three cities in Palestine. Attendance at the first day in Hebron, was about 250. Goksin was suppose to speak at the event but did not have the proper visas and was turned away at the border, so he went to Jordan and did a LiveMeeting!

This is a region with a tremendous amount of political instability, to say the least. I encourage all members of the community to help out, contact Jihad and do a session via LiveMeeting, or travel to Palestine and deliver a talk. You won’t regret it and you will do more to bring peace to the Middle East then all of those politicians out there.

You can read Jihad’s post here.

img02

 

Technorati Tags:

posted on Friday, 06 November 2009 03:19:44 (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Thursday, 05 November 2009

I am in Hong Kong speaking at the Hong Kong International Computer Conference. It is a great conference, it focuses on IT as a driver for innovation and economic transformation. I was lucky enough to be doing one of the keynote presentations on how technology is so disruptive and how cloud computing changes entrepreneurship. In my talk I mention Ray Kurzweil’s Abstraction of Moore's Law, which can be summarized as saying that the next 20 years will see as much technological innovation as the past 100.

I represented Microsoft Hong Kong in this talk, and after the speech lots of people came up to me to chat. I got to talk to tons of folks at the conference: I got to talk to students and professors at Hong Kong University, the folks from One Laptop per Child, entrepreneurs (including a dude building some amazing robotics), people form NGOs, and local software developers. We got to talking about how the new technology reality has drastically changed business models. Think about digital media, the music industry has changed forever, old business models just don’t work anymore.

This got me thinking. Microsoft recently announced a great offer for Visual Studio Ultimate (yet another SKU). But the world has changed. Web 2.0 is here! So I say: All SKUs of Visual Studio should be free.The goal should be to get Visual Studio out to everyone, for free. I know that we have Express versions of these products, and for the most part, they are very capable, but I mean the real deal, Visual Studio Ultimate.

Now I know what you are thinking: Steve, have you gone soft on me?

Of course not.  I am still a disciple of Milton Friedman and a firm believer of free markets and economic incentives. But that does not mean you have to actually sell something to make money on it. I am thinking of Visual Studio 2.0.

For example, there are four versions of Visual Studio as far as I can tell. (And the fact that I have no idea is a problem.) There are the free express versions, Professional, Premium, and (the new SKU) Ultimate.

image

Microsoft should do away with all versions and give away Ultimate (without MSDN) to anyone who wants it. My mom could go and download it if she wanted to. Just have to provide some demographic information and have a Live ID.

The startup page in Visual Studio would be ad supported (and you can’t make it go away, so you will see it each time you load Visual Studio.)  I could see Telerik or our competitors wanting to sponsor that page-but not in a “pay us a million dollars model”, rather as a pay per conversion model. Basically Telerik and our competitors would pay a small fee to be on the startup page and be able to stream ads to the developers and each Telerik license sold, Microsoft takes a cut.  Note to Microsoft, since this was my idea, can Telerik have an exclusive on that page? :)

In addition, in exchange for the free Visual Studio, Microsoft will get anonymous data from the developers. What country you are in, the specs of the developer machine, installation experience, etc. Also how many projects were started in C# v VB v F#, etc. Silverlight v Web, etc. Imagine if Microsoft knew all of this data!! I want to know how many lines of C# code in Brazil were written for Windows Forms last week.

Microsoft can then sell ad space based on your environment. Think about a C# developer in Poland working mostly on Silverlight. On the startup page next time there are offers (in Polish) for Silverlight tools, conferences, books, or even job offers. How much would Dell pay to market to every developer in Australia with Visual Studio installed on an “underpowered” machine? The vendor would only know who you are if you actually clicked on the offer.

Microsoft can also make money by using Visual Studio as a sales engine for MSDN. MSDN does not really have a “sales force” and Visual Studio can be a “loss leader” for MSDN.

But MSDN’s business model would have to change as well. Why not have MSDN (not the software part) evolve into a Visual Studio based Facebook/Linkedin social network for developers. You can only get into your “MSDNFacebook” via Visual Studio. When you are coding, Visual Studio can automatically update your status (Stephen Forte is currently breaking the build….) Imagine hitting F1 and be brought to a MSDN forum search on that line of code as one option. Every .NET developer in the world would be a member of this social network! Want to find a user group? No problem! Imagine the collaboration opportunities. A whole new world of revenue opportunities would open up to Microsoft, including an IPO of MSDNFacebook! :)

In addition, the MSDN software pricing model would change. Microsoft can sell fractional MSDN licenses and specialize MSDN for local markets and different developer types. Maybe you only want MSDN for Web Development. MSDN is expensive since it includes big things like Windows Server and Exchange, etc. (I have never installed Exchange, nor will I ever do so.)  Maybe you can have MSDN options where that is excluded. Kind of like a menu where you customize just want you want and pay only for what you use. Sell more with less. (Sound familiar?)

Of course if you want the ads and the anonymous data collection turned off, you can pay an annual fee. If your employer is paying that annual fee, they can opt out of certain content, such as a job offer coming your way, etc.

Visual Studio 2.0 would be awesome. Developers get free software and more collaboration, vendors get to tap into the entire ecosystem, and Microsoft makes more money while collecting a tremendous amount of metrics, metrics that will drive new features, service packs, etc.

Maybe this will be one of the great announcements next week at the PDC……..

posted on Thursday, 05 November 2009 06:56:41 (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Wednesday, 04 November 2009

Tomorrow I will be speaking at the 2009 edition of the Hong Kong International Computer Conference. This year’s theme is on Value Creation and Economic Transformation via IT. When they asked me to put together a session, I jumped on the idea of how Cloud Computing has changed the economics of start-ups and entrepreneurship. 

I started Corzen, my last company, in 2002. We got started for around $250,000. About $75,000 of that was on building out a data center. I am a software guy, so this also took a lot of my time. In 2010, I can have more processing power, more storage, and more free time for around $99 a month from Windows Azure or Amazon EC2. Think about what this will mean, it will be much easier to start a new business in the future.

The implications of this are staggering. The late 90s was always considered the golden age of start-ups since funding was so “easy” in the .com boom. Now you can start your own business for less than $20,000! We’ll see a ton of new businesses pop up in all industries. Since you won’t need investment to get started and most entrepreneurs will use their own money, the start-ups will have tons of passion.

Innovation will take a great leap forward in the next decade. Cloud Computing will lead the way.

image

posted on Wednesday, 04 November 2009 01:43:02 (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Tuesday, 03 November 2009

I have a simple demo application that uses ADO.NET Data Services as a data service back end for a Silverlight application.  My ADO.NET Data Service uses the Entity Framework to map the Northwind database tables of Customers, Orders, and Order Details. Once the Silverlight applications sets a service reference to the ADO.NET Data Service, you can use the client side LINQ libraries to build your application. My application looks like this, it has a drop down filled with customers, a grid with Order and a grid with Order Details. As you click on each one, it will filter the rest.

image

The LINQ statement for the drop down looks something like this:

   1:  //this uses the LINQ to REST proxy (servicereference1)
   2:  NorthwindEntities dat = new NorthwindEntities(
   3:      new Uri("Northwind.svc", UriKind.Relative));
   4:   
   5:  //linq query to get customers in ComboBox
   6:  var customers = from c in dat.Customers
   7:                  orderby c.CustomerID
   8:                  select c;

 

Pretty basic LINQ stuff. What I would like to do next is bind my drop down combobox to customers. There is one catch, since we are in Silverlight, this processing has to be done asynchronously, so that data binding code has to be done elseware.

There are a few ways to do this, the most straight forward it to set a delegate and catch an event, etc. Another is to use a code block and catch the event right in the same method.

While both of these solutions are fine, I don’t like them. I don’t like them because they look funny and pollute my data access code with tons of async communication stuff. Lastly, for each area where we have a LINQ statement, we have a lot of repetitive similar looking code. Every bone in my body wants to make that generic and only call it once.

Enter the AsyncLINQManager class I wrote. Forget about the details of this class for now, I will list it below in full. For now let’s show how to use the LINQ statement with the helper. First you have to create an instance of the AsyncLINQManager and then register an event. (No getting around the events!) You can do this in the page load handler:

   1:  //ref to the linq manager
   2:  alm = new AsyncLINQManager();
   3:  //register an event so we can do the databinding
   4:  alm.OnEntityFetched += Page_OnEntityFetched;

Now your LINQ statement needs one more line of code. Here is the same LINQ statement from above, passing customers to the AsyncLINQManager:

   1:  //this uses the LINQ to REST proxy (servicereference1)
   2:  NorthwindEntities dat = new NorthwindEntities(
   3:      new Uri("Northwind.svc", UriKind.Relative));
   4:   
   5:  //linq query to get customers in ComboBox
   6:  var customers = from c in dat.Customers
   7:                  orderby c.CustomerID
   8:                  select c;
   9:  //call async functions for the linq query
  10:  alm.LinqAsync(customers);

Line 10 is the only new line of code. Now the LINQ manager will take care of all of the async processing for us and we just have to put our data binding code in Page_OnEntityFetched() shown here:

   1:  //this event handler will do the actual databinding
   2:  void Page_OnEntityFetched(EntityEventArgument args)
   3:  {
   4:      switch (args.TypeName) //we get this info from the event
   5:      {
   6:          case "Customers":
   7:              CustomerCbo.ItemsSource = args.returnedList;
   8:              break;
   9:          case "Orders":
  10:              dg.ItemsSource=args.returnedList;
  11:              break;
  12:          case "Order_Details":
  13:               dg_Details.ItemsSource = args.returnedList;
  14:              break;
  15:   
  16:      }
  17:  }

 

You will notice that we do all of our data binding here, for all of our LINQ statements. This is the value of the AsyncLINQManager, now all of my binding code is in the same place. (I am sure that there will be some who disagree, but hey, build a better AsyncLINQManager and blog about it and I will link to it. :) )

So let’s take a look at the code to query the orders, you will notice that it will call the same LINQ manager and then have to come back to Page_OnEntityFetched() to do the binding:

   1:  //orders
   2:  private void AsyncBindOrdersCbo(string customerid)
   3:  {
   4:   
   5:  //this uses the LINQ to REST proxy (servicereference1)
   6:  NorthwindEntities dat = new NorthwindEntities(
   7:      new Uri("Northwind.svc", UriKind.Relative));
   8:   
   9:  //linq query to filter the Orders in the grid
  10:  var orders = from o in dat.Orders
  11:               where o.Customers.CustomerID == customerid
  12:               orderby o.OrderDate
  13:               select o;
  14:   
  15:      alm.LinqAsync(orders);
  16:   
  17:  }

What I really  like is that you can go ahead and write a simple LINQ statement like you are use to, pass the result to the AsyncLINQManager for processing and then just have one event handler take care of all of your data binding. To me, your code is more clean and your developers can code the LINQ statements almost like normal (minus that one extra line of code) and forget about all of the async stuff.

The code for the AsyncLINQManager is here. All it is doing is sending out the async request, catching it, and then returning an IList and object name in the event args.

   1:  using System;
   2:  using System.Linq;//for IQueryable
   3:  using System.Data.Services.Client;//for DataServiceQuery
   4:  using System.Collections;//for ILIST
   5:   
   6:  namespace LinqUtilities
   7:  {
   8:      //ASYNC Linq stuff
   9:      public class AsyncLINQManager
  10:      {
  11:          //see the EntityEventArgument class below for the event args
  12:          public delegate void EntityFetchCompleted(EntityEventArgument args);
  13:          //developer must register this event in the UI code to catch the IList
  14:          public event EntityFetchCompleted OnEntityFetched;
  15:   
  16:          //pass in linq query object for execution
  17:          public void LinqAsync<T>(IQueryable<T> qry)
  18:          {
  19:              //generic async call to start the linq query
  20:              DataServiceQuery<T> dsq = (DataServiceQuery<T>)qry;
  21:              //Call the code async and assign OnFetchComplete to handle the result
  22:              dsq.BeginExecute(OnFetchComplete<T>, dsq);
  23:           }
  24:   
  25:          //method to handle the async result
  26:          void OnFetchComplete<T>(IAsyncResult result)
  27:          {
  28:              //catch the status of the async call
  29:              DataServiceQuery<T> dsq =(DataServiceQuery<T>)result.AsyncState;
  30:              //if we are done, then stuff the data into a untyped List
  31:              if (OnEntityFetched != null)
  32:              {
  33:                  //delegate for event
  34:                  OnEntityFetched(new EntityEventArgument
  35:                                 { returnedList = dsq.EndExecute(result).ToList() });
  36:              }
  37:          }
  38:   
  39:      }
  40:      
  41:      
  42:      //event args class for the event on the client to 
  43:      //see what linq query they are handling
  44:      public class EntityEventArgument : EventArgs
  45:      {
  46:          public IList returnedList { get; set; }
  47:          public string TypeName
  48:          {
  49:              get { return returnedList.Count == 0 ? string.Empty : returnedList[0].GetType().Name; }
  50:          }
  51:   
  52:      }
  53:  }

You can download the sample code and the AsyncLINQManager code from my “DataAccess Hacks and Shortcuts” session demos here.

Enjoy!

Technorati Tags: ,,
posted on Tuesday, 03 November 2009 04:42:33 (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Monday, 02 November 2009

Microsoft’s SQL Azure database offering has great 3rd party support. This week Telerik is releasing its Q3 version of its entire product line and the OpenAccess ORM will have more robust and native support for SQL Azure over what is currently available. I will expand on the example I did last week on connecting to SQL Azure by showing how to work with OpenAccess entities via WCF in a Silverlight application.

The fist thing that you have to do is create a project for your data access layer and connect to SQL Azure. I started a new class library and used the Enable Project to use ORM wizard. This is where you can specify your SQL Azure user account and credentials. I showed how to do this last week, so I will skip the steps here. (This is a new feature of Q3, in the previous version of OpenAccess, you had to use the SQL Server provider, now OpenAccess supports SQL Azure natively!)

Next we have to create a project to contain our WCF service. What we have to do next is point the Telerik Data Service Wizard to the DAL project and have it automatically create the SVC and CS files of our service for us.  The wizard will automatically create all of the CRUD methods for our entities. (In this demo I only used Customers.) In case you have not used the wizard yet, here is a walk through video on how to do that.

Telerik OpenAccess WCF Wizard Part I from Stephen Forte on Vimeo.

Now we will have two projects, one for our DAL and one for our WCF service. Now, add a Silverlight project and your solution should look like this, four projects: the DAL project, the WCF service project, the Silverlight Web project and the Silverlight project itself.

image

Next up we set a service reference to our WCF service and call the ReadCustomers method to get a list of all the customers and bind it to a XAML grid. (Remember that this being Silverlight, we have to do it all asynchronously.) We do this inside of a LoadData method in our form.

   1:  private void LoadData()
   2:  {
   3:      //ref to our service proxy
   4:      SampleWCFServiceClient wcf = new SampleWCFServiceClient();
   5:      //register the event handler-can move this up if you want
   6:      wcf.ReadCustomersCompleted += ReadCustomersCompleted;
   7:      //make an async call to ReadCustomer method of our WCF service
   8:      //get only the first 100 records (default)
   9:      wcf.ReadCustomersAsync(0, 100);
  10:  }

The first thing that we do in the code above is create a reference to our WCF service in line 4 and then register an event handler to catch the asynchronous completion of the event on line 6. On line 9 we make the (asynchronous) call to ReadCustomers(). Since ReadCustomers() will process asynchronously, we will have to go to the ReadCustomersCompleted() method to catch the event. Let’s look at that here:

   1:   
   2:  void ReadCustomersCompleted(object sender, ReadCustomersCompletedEventArgs e)
   3:  {
   4:      //if the filter is set use a LINQ statement
   5:      //this can also be done on the server via the service
   6:      if (CheckFilter.IsChecked == true)
   7:      {
   8:          var filter = from c in e.Result
   9:                       where c.Country == "Germany"
  10:                       select c;
  11:   
  12:          dataGridCustomers.ItemsSource = filter;
  13:      }
  14:      else
  15:      {
  16:          dataGridCustomers.ItemsSource = e.Result;
  17:      }
  18:  }

In ReadCustomersCompleted we are doing seeing if a checkbox is checked and if so, we do some client side LINQ statements to filter on the client for only customers in Germany. (This is a holdover from a demo I did at BASTA in Germany, of course you should move your countries to a drop down list and then filter with a parameter! Better yet, filter via the WCF service on the server!) If the checkbox is not checked, we will just show all of the customers.

image

If you want to edit a customer (or add, etc), the Silverlight grid allows you to do this inside the grid itself. However, you have to make sure that all of your dirty records are recorded so you only send back the dirty records to your backend WCF service. (Why bother updating all of the records?)

Here is the code to build the collection on the Begin Edit of the grid. This code just adds the current customer object into our custom collection (editedCustomers) so we can loop through it later on if we are doing an update.

   1:  void dataGridCustomers_BeginningEdit(object sender,
   2:   DataGridBeginningEditEventArgs e)
   3:  {
   4:      //build a list of Customer that are dirty
   5:      Customer customer = e.Row.DataContext as NorthwindWCFService.Customer;
   6:   
   7:      if (!editedCustomers.Contains(customer))
   8:      {
   9:          editedCustomers.Add(customer);
  10:      }
  11:  }

 

Now that we have our collection of dirty customers, we have to deal with the save button. The code below is run when the user clicks on the save button, saving all dirty records. Line 6 sets up the WCF service via the proxy and line 8 registers the event. Lines 11-15 is a loop of all of the dirty customers. (I get them via the custom collection editedCustomers shown above.) Inside of the loop on line 14 we make the actual asynchronous call to the WCF service’s UpdateCustomer method passing in the object and its correct ID. While the UpdateCusotmerCompleted event will fire (since this method is called asynchronously) when the update is complete, we have nothing really in that method except some cleanup of our custom collection and a message box to the users that the update is complete.

   1:  void ButtonSave_Click(object sender, RoutedEventArgs e)
   2:  {
   3:      
   4:      //the WCF service
   5:      //ref to our service proxy
   6:      SampleWCFServiceClient client = new SampleWCFServiceClient();
   7:      //register the event handler-can move this up if you want
   8:      client.UpdateCustomerCompleted += UpdateCustomerCompleted;
   9:   
  10:      //save only the dirty customers
  11:      foreach (NorthwindWCFService.Customer customer in editedCustomers)
  12:      {
  13:          //call the WCF method async to update the customer
  14:          client.UpdateCustomerAsync(customer.CustomerID.ToString(), customer);
  15:      }
  16:   
  17:  }

That is all there is too it! An add or delete is done in the same way.

Enjoy!

Technorati Tags: ,,,
posted on Monday, 02 November 2009 05:13:59 (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Sunday, 01 November 2009

I’ll be speaking this week at TechDays in Hong Kong. Doing a new session on TSQL Tips and Tricks, a session on Silverlight, and of course the Daily Scrum (on Agile development as well as scrum.)

Hope to see you there.

image

Technorati Tags:
posted on Sunday, 01 November 2009 08:44:35 (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback