Riding The Bench


After nearly a year and a half, I've finally rolled off of leading an enormous project requiring the better part of my days/nights/weekends. While taking some time "on the bench" between assignments, I am happy to be able to return to blogging some of my findings, questions and random rants

author: John Saunders | Posted On Wednesday, February 25, 2009 2:55 PM | Feedback (0)

Second Life has Mono


For those that haven't experienced Second Life, it is an online virtual world imagined and created entirely by its residents. Noticed that I said experienced, rather than played, since Second Life isn't really what you'd call a game. Best of all, Second Life doesn't cost a thing to experience (though owning land can be costly).

Since it's 2003 launch, Second Life has grown to inhabit millions upon millions of residents. Inside Second Life you're introduced to a world of entertainment, experiences, and creations of fellow residents, and are able to begin choosing your own destiny where you can do basically anything that you can imagine.

Second Life consists of a large server farm primarily running on Linux operating systems. Among these servers there are login servers, user servers, space servers, data servers, simulators and several others. The simulators themselves are responsible for running the physics engine, collision detection, and sending updates to the client viewers. The client viewers handle the location of objects, determining velocity and other physical information, but do not handle any sort of detection collision. A robust scripting language, the Linden Scripting Language (LSL), is available to the residents themselves so that they can create the world as they see it. This script runs within the simulators' virtual machine. This is where Mono comes in. A beta is officially in progress to test LSL compilation to Mono bytecode within a beta set of simulators with Mono viewers!

For those that aren't aware of Mono, it is an open-source implementation of the .NET Framework which allows client and server .NET applications to run on Linux, Solaris, Mac OS X, Windows and Unix.

Second Life allows for endless opportunity for its residents to say  skydive, visit foreign countries, participate in political debates, build homes, run businesses, and the list goes on and on as far as you can imagine. My personal favorite thing to do in Second Life is to participate in Second Life .NET Users Group (SLDNUG). This is a community of Microsoft .NET users sharing ideas, participating in group presentations hosted by Microsoft developers, and helping to bring more users to the community itself. If interested, you can join SLDNUG by visiting the Facebook page.

author: John Saunders | Posted On Tuesday, February 05, 2008 3:04 PM | Feedback (0)

Enterprise Application Development using the Microsoft .NET Platform - Part 1


This will be the first in a series of articles covering Enterprise Application Development using the Microsoft .NET Platform.

In this first article, I'd like to give you an understanding of the fundamentals of the Microsoft .NET Framework.

This will lay groundwork for upcoming sessions covering object-orientation (OO), software design patterns, service-orientation or Service Oriented Architecture (SOA), Microsoft BizTalk, Visual Studio, Team Foundation Server and other related Microsoft tools and best practices that enable development of distributed applications.

An Introduction to the Microsoft .NET Platform

author: John Saunders | Posted On Tuesday, January 29, 2008 11:50 AM | Feedback (0)

Consultant Evangelism


Working as a consultant, I often find myself preaching the .NET gospel attempting to "save" my client's development teams. I've yet to see a team that hasn't been able to benefit from implementing Microsoft platform solutions, but initially there's a general vibe against drinking the cool-aid. Most of this push back stems from a lack of understanding of the tools that are available. I'm not here to say that .NET can solve world peace, but enterprise software applications can be rapidly developed, easily maintained, scale out to support demand and provide the interoperability required to support legacy systems.

Most of my work consists of providing architectural designs, rapid proofs of concepts, and development team direction through implementation before moving on to the next client. That said, there's often a lot of instruction required to bring my colleagues up to speed, not just on the Microsoft .NET platform and related tools, but on fundamental software development skills applied at a more general level.

Once more I have been asked to provide instruction now after having sold the concept, and again I kick myself for not saving previously prepared training sessions given to other clients. I am happy to do this again though, since bringing more developers to the .NET community makes me very happy, and often what these people can bring TO the .NET community only benefits everyone!

I'd like to use this forum to both keep this training material handy, and also to share with the community the guidance that I can offer after having used the .NET platform almost exclusively for the past six years (~2002).

My goal is to start from the basics, ultimately offering you an understanding of how to architect distributed applications for your enterprise.

John Saunders
MCP, MCDST, MCAD, MCSD

Microsoft Certified Solution Developer

author: John Saunders | Posted On Monday, January 28, 2008 4:21 PM | Feedback (0)

ADO.NET Entity Framework


Now that I'm feeling a bit more comfortable with LINQ to SQL and LINQ to XML, I really wanted to begin exploring the ADO.NET Entity Framework and LINQ to Entities.

I started by going to
msdn.microsoft.com/data and installed the ADO.NET Entity Framework Beta 3 and ADO.NET Entity Framework Tools CTP 2 (for Beta 3).

At first glance, I didn't notice anything new being provided by the Tools CTP, so I started a simple C# Console Application. From the Add New Item menu, I noticed an ADO.NET Entity Data Model template. After adding the data model, you're asked if you would like to generate the model contents from a database, or create a new one. Considering that I didn't know what exactly went into the model, I went with the generated approach. You are then asked to create a connection or use an existing and give a name for the connection settings to be saved in the App.Config. You'll see that it creates an "Entity connection string".

metadata=.\Model1.csdl|.\Model1.ssdl|.\Model1.msl;provider=System.Data.SqlClient;provider connection string="Data Source=LOCALHOST;Initial Catalog=Northwind;Integrated Security=True"

Finally you are able to choose the database objects (tables, views, stored procedures) to include within your model and give a name for the model namespace. Once generated, you'll find a ".edmx" file with an associated Designer class within the solution. The edmx Model appears similar to the reverse engineered tables, but also there are different types associated with each entity. In fact, each of these entities are classes that were generated to represent the data structure. Along with the scalar values of the associated table (i.e. Customers.Address), you'll notice "Navigation Properties" representing collections of related entities.

Notice the Orders and Products collections associated to the Order_Details entity? Ok, this is very interesting stuff that I'll explore more a little later. I want to see the what's changed for ADO.NET!

I decided to start simple. Suppose I wanted to see a list of customers who haven't made any purchases. Maybe we should send them some coupons! So, I'm thinking I'll create a database connection and execute a query using LINQ against the connection. Well..

Along with my Entity Types and Associations that were created with my model, I also have what's called an EntityContainer called NorthwindEntities that contains Entity Sets and Association Sets (and optionally imported functions). Again, further exploration required, but let's see what we can do with this EntityContainer.

Notice the Orders entity collection associated with the cus object. I didn't write any query or join to do that!

I truely have to explore more to be qualified to speak on the topic of ADO.NET Entity Framework, but after 20 minutes of investigation, I am happy about what I am seeing!

More on this topic to come!

author: John Saunders | Posted On Wednesday, January 23, 2008 9:39 PM | Feedback (0)

Multithreaded WPF UX


In my last post, I talked about a hidden method on the Dispatcher associated with a WPF control to check if the current thread has access to the control. I thought that I would take a moment to explain how I actually used the CheckAccess() method.

To start with, I have a combobox in a WPF window that I would like to load a list of categories into without freezing the window itself. To load the items into the combobox, which I'd like to do at runtime, I'll use the Loaded event on the combobox.

<ComboBox Height="26" HorizontalAlignment="Left" Margin="133,0,0,3.95440729483283" Name="comboBox1" VerticalAlignment="Bottom" Width="121" Loaded="comboboxLoaded" DisplayMemberPath="Name" />

Now, I'll follow the typical pattern of calling the data access method on another thread from the comboboxLoaded method.

protected void comboboxLoaded(object sender, EventArgs e)
{

System.Threading.Thread thread = new System.Threading.Thread(Load);
thread.IsBackground = true;
thread.Start();

}

Here you'll notice I'm calling a method called Load() on a new thread. This typically would be the extent of the threading that I might do to ensure that my Load method does not hold up my UX thread. (By the way, I've grown quite fond of the term of UX (User Experience) rather than UI.) What I want to be sure of though is that the thread that I created has access to the control.

private delegate void loadCategories();
private void Load()
{

CategoryList categories = CategoryList.GetCategoryList();
if (comboBox1.Dispatcher.CheckAccess())
{

comboBox1.ItemsSource = categories;

}
else
{

comboBox1.Dispatcher.BeginInvoke(DispatcherPriority.Render,
new loadCategories(delegate
{

comboBox1.ItemsSource = categories;

}));

}

}

You'll notice that if an invoke is required, the CheckAccess() method will return false, giving me the opportunity to pass the logic off to the loadCategories delegate. This may seem a bit like overkill, but given the rich experience abilities given by WPF, the last thing that I'd want is my UI flickering or freezing up while I'm doing databinding. I think I'll explore this a bit more and build a resuable control to extend from that will auto delegate logic when necessary.

author: John Saunders | Posted On Tuesday, January 15, 2008 8:53 AM | Feedback (4)

Hidden Methods - EditorBrowsable


Recently while exploring multi-threading with WPF, I came across a method on a WPF control's Dispatcher to check if the current thread has access to the control.

 myButton.Dispatcher.CheckAccess();

Now, the funny thing about this method is that it is a public method, but unavailble from Intellisense within Visual Studio. If manually typed in, it compiles and executes just fine, but there was no idication of that method existing. Now how could that be? Could I have missed something? Obviously I did - this method of hiding members has been available at least as far back as the 1.1 version of the framework.

[EditorBrowsable(1)]
public boolean CheckAccess();

This attribute takes a parameter which is an EditorBrowsableState. This is an enumeration defined as:

Always = 0 //The property or method is always browsable from within an editor.
Never = 1
//The property or method is never browsable from within an editor.
Advanced = 2 //The property or method is a feature that only advanced users should see. An editor can either show or hide such properties.

First of all, who determines whether I am an advanced user or not? Well, that's an option set in Visual Studio.

Hide Advanced Members

Ok, so by default these Advanced members aren't hidden. Whew! But as for the EditorBrowsable(1) members, keep in mind there may be more available than what you are seeing!

More on MSDN...

author: John Saunders | Posted On Monday, January 14, 2008 9:13 PM | Feedback (0)

2008 Microsoft CES Keynote


After first giving the keynote address for the Computer Electronics Show almost 15 years ago, Bill Gates gave his final speech in Las Vegas on January 6th. Bill spoke about the past 10 years of software and where he sees the next "digital decade" taking us.

He also took time to talk briefly about the fact that this would be his last CES keynote and the fact that in July of '08 he'll be moving from his fulltime position at Microsoft to working fulltime on his foundation. Having been employed with Microsoft since the age of 17, he joked about the fact of not knowing what he would do that last day at work this summer. He showed us a humerous video where celebraties such as Jay Z, Bono, Jon Stewart, Stephen Spielberg, Hillary Clinton, Barack Obama and more roast him in the skit around his last day.

Once back into speaking on the Second Digital Decade, Bill (along with other Microsoft spokesman) showed us several new products that were in the works at Microsoft. Some of these included the Windows Surface,  visual recogition devices, Silverlight (i.e. MSN and NBC partners to create the 2008 Olympics website), Windows Media Room, and much more. Bill spoke about the service "cloud" where rich devices will be service connected to bring high definition experiences with more natural user interfaces.

All in all, a very powerful presentation (oh yea, Slash even comes on stage in the end with a guitar solo to lead it out). Very good speech and well worth taking an hour out to watch it.

www.microsoft.com/ces/

author: John Saunders | Posted On Sunday, January 13, 2008 3:45 PM | Feedback (0)

Serializable Voodoo


Here's an interesting concept that I'm trying to sort out in my head..

Passing objects by value - creates a copy of the object and changes made to that copy aren't reflected in the original value.

Passing objects by reference - passes a reference to the original object and changes made are reflected immediately.

Passing Serializable objects by reference - The object is actually passed by value, but the .Net Framework treats the copy as a reference to the original object. Changes made to the copy are passed back to the calling code when the operation is complete and then the original object is replaced with a reference to the new copy!

Previous references made to the original object still point to the original value so there is the possibility of having two copies floating around at this point. Should we follow a true SOA model, encapsulating our logic so that we are only exposing the contracts, this is perfect for distributed environments.

Serializable Contact object instantiated in client app domain -> passed to application server where data access methods are called and attributes populated -> passed back to client. This allows for perfect n-tier distributed implementations.

With the Framework itself determining when to create that additional copy (e.g. it will not create a seperate copy if passed within the same machine from layer to layer), this seems like the way all object-oriented systems should work..

I wonder how Java handles that?

author: jsaunders | Posted On Thursday, January 03, 2008 9:56 AM | Feedback (0)

LINQ to Objects


I've been playing around with LINQ to Objects and have come across something quite odd...

Say we have this statement:

Dim myCustomers = From customer In customers _

Where customer.Id = 5 _
Select customer.Id, _
FullName = customer.FirstName & _
" " & customer.LastName
For Each customer In myCustomers.Distinct()
Console.WriteLine(customer.FullName)
Next



FullName becomes a ReadOnly Property here and acts as
if it belonged to the Customer class.

Now, say we take out the first field in the select list:
Dim myCustomers = From customer In customers _

Where customer.Id = 5 _
Select FullName = _
customer.FirstName & " " & _
customer.LastName
For Each customer In myCustomers.Distinct()
Console.WriteLine(customer.FullName)
Next


This doesn't compile? It treats FullName now as an
extension of String?
Error 1 'FullName' is not a member of 'String'.



That makes no sense to me.. Maybe it's because it's after 1am,
but I'd love if someone wanted to make some sense of that...

author: jsaunders | Posted On Thursday, January 03, 2008 9:56 AM | Feedback (0)