Welcome to TheRunTime.com

We are a community of technical bloggers devoted to improving the business of development. This is a place where you will find expert advice on some of the advanced technical topics facing developers today. There will also be tutorials geared at novice developers, and content about the business aspects we must all deal with. Our number one commitment is to keep the content in our main feed relevant, reliable, and useful to you. I hope you enjoy our site and encourage you to subscribe to the main feed today.

Latest Posts

Facebook .NET Programmers Group XNA Session Posted

NET PROGRAMMERS2bcropSmall2 The recordings for the session I gave on XNA Game Studio 3.0 and the XNA Framework to the Facebook .NET Programmers Group have now been posted.  In this session, I give an overview of XNA Game Studio 3.0 and the XNA Framework while building a simple Space Invaders clone named Alien Attack.  This game is gone into even greater detail with more features in chapter 1 of our Coding4Fun book.

You can find a quick, low-res, streaming version below, or you can download and play the recording at a higher resolution in Microsoft Office Live Meeting.  I had a great time presenting the topic and hope to speak to the group again in the future!


Meeting #13 - Coding4Fun: Designing a Video Game using XNA Game Studio 3.0 from Muneeb on Vimeo.

Cross Posted from www.brianpeek.com.

posted @ 6/25/2009 3:02 AM by Brian Peek

Better JavaScript class generation

For years, I have been espousing how great Script# is. I often do an advanced MS ASP.NET Ajax client talk and end it with a Script# talk. Mainly because I think that the idea of learning the nuances of JavaScript OO techniques can be a little confusing. It’s really the challenge (All you need to do is search the archives of my blog and you’ll see my own confusion on this topic).

I think many web developers can wrap their heads around building the functionality, but making something private/public/static can get a little confusing. Especially if you are used to using something like C# or VB to do it.

Kevin “ByteMaster” Wolf and I have been talking about this. As a result of those talks I started playing with an idea of allowing developers create something that feels more like OO… Anyway, I have come up with a very alpha version.

A Better OO For JavaScript??

   1: compileClasses({    
   2:     testClass: {        
   3:         ctor: function() {            
   4:             // this is a test        
   5:         },        
   6:         private: {            
   7:             privateVar:1,            
   8:             privateMethd:function() {                
   9:                 // test method            
  10:             }        
  11:         },        
  12:         public:{            
  13:             // public stuff here            
  14:             publicVar:"2"        
  15:         },        
  16:         static:{            
  17:             //public statics            
  18:             staticVar:"test"        
  19:         }    
  20:     },    
  21:     testClass2: {        
  22:         ctor: testFunc,        
  23:         private: {            
  24:             privateVar2:"2"        
  25:         },        
  26:         public:{            
  27:             publicMethod:function() {                
  28:                 return true;            
  29:             },            
  30:             myVar:"this is a test",            
  31:             dispose:function() {            
  32:             }        
  33:         },        
  34:         implements:["Sys.IDisposable"]    
  35:     }
  36: });

Two classes are defined here.. the first one is the testClass. you will see that I’m creating a JSON object that has members called “ctor” (constructor), “private” (private members are contained within this object), “public” (public members are contained within this object),”static” (static public members are contained within this object), and “implements” (“array of interfaces that are implemented). I also will handle single inheritance using a member called “inherits.”

I think this makes class definition a little more straightforward for those of us who aren’t closure gurus, and it just might replace the pull of Script# on my life.

Right now this all works with a simple function that uses the MS Ajax Client framework. I’m considering doing this for other frameworks (so if you love some other framework, never fear I’m considering your framework as well).

I created a codeplex project which contains a single release that contains a simple ASP.NET project (could have been a simple html page too).. Don’t fret I expect the code to be a ton cleaner in the next version (I’m reading the MEAP version of John Resig’s Secrets of the JavaScript Ninja (and am learning a ton!)

Here’s the link: JsClassDef Project

Let me know what you think.. does it stink? is it cool? I know it ain’t Resig-like, but both Kevin and I think the simplified structure is nice and not un-JavaScript-like

posted @ 6/24/2009 5:15 PM by Jay Kimble

Status of Wii MotionPlus Support for WiimoteLib

wii-motionplus Ok, I get about 10 emails a day on this, so I figure a status update is in order.

The Wii MotionPlus extension for the Wiimote was released last week.  Since then, I and others have been working to figure out how the device works.  Unfortunately, it does NOT work as every other extension controller has worked up until this point, mostly due to the fact that the Wii MotionPlus accessory has an expansion port of its own so all of the other extension controllers can plug into it.

In the past few days, some progress has been made thanks to the folks over at wiibrew.org, although functionality is nowhere near complete.  For example, it’s currently impossible to have the Wiimote notify you when the Wii MotionPlus is inserted into the bottom of the Wiimote, like all of the other extension controllers do.

I have been working with the information at wiibrew.org and am trying to get things working reliably with my library so that developers can actually get some degree of functionality out of it.

So, all that said, expect to see a new (likely beta) version of WiimoteLib “soon” that has some bare-bones Wii MotionPlus functionality included.  It won’t be perfect, complete, or bug free, but it will allow you to tinker with the device a bit.  I will update my blog when the new version is available.  Thanks!

Cross Posted from www.brianpeek.com.

posted @ 6/19/2009 1:43 PM by Brian Peek

Using the Ajax control toolbox with jQuery (and ASP.NET MVC)

[Here’s a preview of something I’m going to show Thursday night at the Tampa MVC group.]

You may have thought that by jumping on ASP.NET MVC that you have to leave behind all the cool Ajax Control Toolbox controls.. or more than likely you realize that it’s possible to use them, but one has to be a “JavaScript Rocket Scientist” to use them..

It’s really not, but you do need a couple things to use them.. First of all go here (Bertrand Le Roy’s blog) and pick up the jQuery plugin that let’s you instantiate MS Ajax Behaviors. Next go here to the Ajax Control Toolbox project and get both the ScriptFilesOnly project and the Source code as with MVC you won’t need anything but the JS files since the source/DLLs are for WebForms-related controls, but the Source code contains the debug version of the JS files which we’ll need (By the way, 6 months from now that link to the Ajax Control Toolbox will be old so you’ll probably want to get the latest release, and not the release I pointed at).

Now let’s look at how you would wire up the DropShadow behavior (aka the DropShadow Extender). First of all, we need to figure out the references. Thanks to Visual Studio 2008, this is easy. Using the text editor/view of your choice, open up the DropShadowBehavior.Debug.js from the Source project (not the ScriptOnly zip); this is located under the zip file at .\AjaxControlToolkitSource\AjaxControlToolkit\DropShadow. When you open up the file you will see the following at the top of the file:

   1: /// <reference name="MicrosoftAjax.debug.js" />
   2: /// <reference name="MicrosoftAjaxTimer.debug.js" />
   3: /// <reference name="MicrosoftAjaxWebForms.debug.js" />
   4: /// <reference path="../ExtenderBase/BaseScripts.js" />
   5: /// <reference path="../Common/Common.js" />
   6: /// <reference path="../RoundedCorners/RoundedCornersBehavior.js" />
   7: /// <reference path="../Compat/Timer/Timer.js" />

The first 3 items are all the standard MS Ajax client library, so we’ll need to reference those. Now we need to look at the last 4 items. If you open up the files from the ScriptOnly zip file, you aren’t going to find these exact named files; to find the right file look at the end of the file name to find the actual file you need to reference. You’ll also need to reference jQuery and Bertrand Le Roy plugins. Here’s what the references look like:

   1: <script src="Scripts/MicrosoftAjax.js" type="text/javascript"></script>
   2: <script src="Scripts/jquery-1.3.2.js" type="text/javascript"></script>
   3: <script src="Scripts/JqueryPlugin/jquery.MicrosoftAjax.js" type="text/javascript"></script>
   4:  
   5: <script src="Scripts/MicrosoftAjaxTimer.js" type="text/javascript"></script>    
   6: <script src="Scripts/MicrosoftAjaxWebForms.js" type="text/javascript"></script>    
   7: <script src="Scripts/AjaxCT/AjaxControlToolkit.ExtenderBase.BaseScripts.js" type="text/javascript"></script>
   8: <script src="Scripts/AjaxCT/AjaxControlToolkit.Common.Common.js" type="text/javascript"></script>
   9: <script src="Scripts/AjaxCT/AjaxControlToolkit.RoundedCorners.RoundedCornersBehavior.js" type="text/javascript"></script>
  10: <script src="Scripts/AjaxCT/AjaxControlToolkit.Compat.Timer.Timer.js" type="text/javascript"></script>
  11: <script src="Scripts/AjaxCT/AjaxControlToolkit.DropShadow.DropShadowBehavior.js" type="text/javascript"></script>

Here’s how we can then make every div with a “box” class to have a drop shadow:

   1: $().ready(function() {
   2:     $(".box").create(AjaxControlToolkit.DropShadowBehavior,
   3:             { 
   4:                 Opacity: 0.3,
   5:                 Rounded: false,
   6:                 TrackPosition: true,
   7:                 Width: 5
   8:             });
   9: });

See that JSON string (lines 3-8). If you look at those settings closely and compare them to the Ajax Control Toolbox documentation web site, you’ll see that these are the same settings that the extender uses which should make everything easy.

posted @ 6/9/2009 10:19 PM by Jay Kimble

Tampa ux… Meeting tomorrow night (Wed. June 10th, 2009).. 7:30pm

We are meeting at Buffalo Wild Wings across the street from our normal location tomorrow night. If you have had any complaints or suggestions about how we run Tampa UX, you need to be there. It’s an important meeting. We have some ideas that we want to run by you guys and see what you guys think.. We can’t do this without you!

posted @ 6/9/2009 9:20 AM by Jay Kimble

The Coding4Fun Show – Ep 1 with Andy Beaulieu

logo The very first episode of my new Coding4Fun Show is now up on Channel 9.  This is a show I plan on doing monthly, interviewing developers creating fun and interesting projects, and showcasing what they’re doing.

In this first episode, I interview Andy Beaulieu and we discuss his Physics Helper for Silverlight, Blend, and Farseer.  You’ll learn a bit about how he made the library, and how you can use it in your own applications for some pretty cool effects.  You should see the video below if you have Silverlight installed, otherwise head over to the episode on Channel 9 to watch and download in a variety of formats for offline viewing.

Get Microsoft Silverlight
The Coding4Fun Show: Physics Helper for Silverlight by Andy Beaulieu

Have a look and let me know what you think.  It’s my first time trying this out, so I’d love to hear your feedback.  Thanks!

Cross Posted from www.brianpeek.com.

posted @ 6/8/2009 10:22 PM by Brian Peek

clientscript as the view controller

I’m finalizing my demos for next week’s talk at the Tampa ASP.NET MVC user group. I’m also in the midst of a deploy to our test servers of among other things a page that is an experimental architecture for me and my team. I was talking with my boss (Perry for those of you who attend Tampa UX). He had to do a little touch up on my quickly thrown together UI. He told me after playing with it that he really liked how it performs and even how it works. He thinks it’s a pretty good UX.

It’s actually very similar to DT Mini Mint (the app I’ll show at Tampa ASP.NET MVC user group next week).

The idea behind it is that the initial page is pushed out by the server and then additional data is retrieved on the fly via services (or JSON views in MVC) using JavaScript; additional functions like updates, deletes, adds, and more complex operations use the same mechanism.. so the page never refreshes once it has been rendered the first time (no, I’m not using any kind of partial view in any of my examples.. not that I couldn’t, but I don’t have that much to render in either app).

I jokingly referred to “Jay’s Dream Architecture” on Twitter, but was never really able to fully quantify what I was talking about. I likened it to MVC where the model was the service, and the controller was the JavaScript code..

After Christopher Bennage came to Tampa UX last month, we came up with a term (that I’m sure already existed): JavaScript View Controller (or JC). I loved annoying Christopher by saying I was going to attribute the MVCJC pattern to him (it seems he really loves the over use of letters in Pattern names <smile />). So remember he came up with the name for this pattern…

I’m finding more and more that I am building key pages (not all pages) that have everything they need to get started but then user interactions that would normally cause a Postback or a Ajax Postback (for an UpdatePanel), etc. I’m replacing with a client-side Ajax call to a service (for WebForms) or a client-side Ajax call to a controller action (for ASP.NET MVC). The end result is a fairly responsive UI that gives me options.

Back to my discussion with my boss today.. One of the things we realized is that side effect of this is there is an occasion where I have in memory the all the data in memory for render a client side paged grid (we’re talking at most 1000 rows of data… more like no more than 700 rows.. probably much smaller than that). We realized with this architecture and the rows in memory we could easily let the user filter the results client-side via textbox that updates the grid after filtering by the value in the test box.. without any hops back to the server)..

A similar thing for my ASP.NET MVC talk in 2 weeks is that I’m going to be replacing a standard select with an autocomplete text box that uses the original select’s options array as the source for the autocomplete suggestions text (you’ll be able to type something new and that new item will be dynamically added to the DB on save). The idea is that the client browser has pieces of data already and doesn’t need to retrieve it. There are also Jquery cache plugins that can help with this (something I won’t be showing)..

Bottom line is that the client is a for real place where we can write code and make the user’s experience better (I know I’ve not been one to totally go gaga in this arena in the past, but I’m starting to warm to it.. I think Jquery is the big reason why, too.. it’s very mature and really makes it easy to write complex interactions without writing tons of code..)

posted @ 6/1/2009 2:34 PM by Jay Kimble

Facebook .NET Programmers Group Session on XNA 3.0

image I will be giving a session on Tuesday, June 2nd at 6pm EST to the Facebook .NET Programmers group on XNA 3.0.  This is an online session and everyone is welcome to attend.

Topic: Building a Video Game with XNA Game Studio 3.0
Abstract: This session will demonstrate how to build a very simple 2D game (a Space Invaders clone) using XNA Game Studio 3.0. Attendees will learn how to effectively use the content pipeline, import 2D sprites into XNA, manage input from the keyboard, mouse, Xbox 360 controller and Zune, manage game state, and debug the resulting game. The sample code will be built on a PC and run on the PC, Xbox 360, and Zune platforms when complete.
Date: June 2nd, 2009
Time: 6PM Eastern | 10PM GMT/UTC - Get local event time in your city: http://tinyurl.com/l9hq65
Add to Outlook: http://tinyurl.com/mpp5of
RSVP and Event Details: http://www.facebook.com/event.php?eid=49178981206
Live Meeting Link to join meeting: http://tinyurl.com/ago484

I’ll also be giving away a copy or two of our Coding4Fun book.  Hope to “see” you all there!

Cross Posted from www.brianpeek.com.

posted @ 5/29/2009 5:46 AM by Brian Peek

Setting Focus to Control in an IFRAME using JQuery

Had a gnarly problem this afternoon, while trying to set focus to a control in an IFRAME.

Using JQuery, I had created the IFRAME with the JQuery plugin ThickBox. ThickBox provides functionality that can simulate a modal dialog using an IFRAME, loading a page from a URL into the IFRAME (check out the demo here - scroll down to "Inline Content"). The page loaded inside the IFRAME contained code to set the focus which was actually being called, but after the page loaded something else was stealing the focus.

I began to look at the javascript code in the parent that created the IFRAME.

I discovered to set the focus to a control in an IFRAME that has already been loaded, you need to set the focus to the IFRAME first (thanks Alex King). I also benefited from "How to access IFRAME in JQuery" over at ProCoding (thanks Taras Ilnytskyy).

Here's the code to set focus to a control in an IFRAME using JQuery (called from the parent window, after the IFRAME has been loaded and shown):
	
//get the IFRAME element - note no hashes in the name, we're using browser functionality
var iframeRef = document.getElementById("IFRAMEID");
//focus the IFRAME element
$(iframeRef).focus();
//use JQuery to find the control in the IFRAME and set focus
$(iframeRef).contents().find("#CONTROLID").focus();
I hope this helps someone!

UPDATE: Fixed formatting.

Tags: , , ,

posted @ 5/28/2009 2:58 PM by Thomas Williams

Firefox vs Flock

I've blogged previously about how I use the Flock web browser, but recently decided to try my luck at the latest release of Firefox.

Flock had several features that enticed me to adopt it in late 2007: social media sidebar integrated with Facebook, blog post editor, in-built image uploader which connected to Flickr and Picasa, media bar, and one-click access to services I constantly used (like Delicious).

My biggest gripe with Flock was that the user interface was not customisable enough. Also, the browser had more features than I'd ever need.

Buying a widescreen monitor with very limited vertical space was the straw that finally made me switch from Flock to Firefox, permanently. Here's a comparison between the two (the red highlights represent the menu & toolbar space used):

I use a couple of Firefox add-ons to reduce the vertical space used (that's the other thing...Firefox has an unbelievable collection of add-ons):
Flock was good to me. Now, I just need the screen space, and don't need a lot of its features.

Tags: , ,

posted @ 5/25/2009 6:54 PM by Thomas Williams

IDENTITY vs. ROWGUID, Part II

So wow, this was the week of nonstop GUID ID discussion (in many different forms). Given that, I thought it'd be appropriate to expand on my last post. Surprisingly, the discussions have been angst and rant-free, which is a good thing. I've often wondered why professional engineers stoop to zealous and rancorous name-calling in dogmatic flames rather than objectively looking at all sides of an issue like the scientists we're supposed to be, so it's nice to engage in something that doesn't sound like jihad run amok.

This brings us to a central point in the debate, which falls into that fulcrum point between KISS/YAGNI and purposeful programming. One of the arguments often leveled against RAD development or the so-called "Mort" programmers, is they thrash about until they find something, anything, that appears to work and go with it, never taking into account the harm the approach might entail; the idea being that developers ought to program with a sufficient understanding of the stakes, and code with intent and purpose, not out of incident. We then have to balance that notion against the concept of YAGNI, which means not to over-evaluate nor over-engineer a situation and go with the best yet simplest solution available. However, I'm finding that a lot of people hide behind YAGNI, and use it as a crude bludgeoning tool for bashing and ignoring what they can't comprehend – which is the wrong approach to take. With that in mind, I'd like to point out once more that the purpose of my posts here isn't to say "Thou shalt never use GUIDs as IDs", but rather that I'm presenting issues that are crucial in order to make informed decisions. More importantly, I'm presenting arguments for both sides and allowing you (the reader) to come to your own conclusions based on your particular scenario, which is far more objective and constructive than saying "always do this" or "never do that".

One of the points I raised about using nonsequential GUIDs for keys is the index fragmentation. I soon realized that a lot of people didn't fully comprehend what this really meant, so this post is really a primer on index fragmentation and why you should or shouldn't care.

First, if your tables are very small, this doesn't pose much of a problem, if any at all. In fact, if your tables are small enough (for example, 10 rows or less) an index can be completely ignored for queries, as the query optimizer can favor a table scan over an index scan, since with so few records, a table scan can reach a desirable record faster than (or on par with) going via index on average.

Second, the problems you encounter with index fragmentation grow proportionally with table size and frequency of access. In other words, the more data there is, and the more concurrent reads/writes taking place, the more you will get noticeably slammed by index fragmentation. What this means is that to a certain degree, you can live with index fragmentation if you feel you absolutely have to, depending largely on the nature (size and use) of the table. Don't relegate this decision for later consideration! It's not a trivial matter to change the key and index structure of a table post production deployment. This could impact your entire architecture.

Before showing you what's really at stake with index fragmentation, it's important to understand the indexes themselves. And I find that with most developers I talk to today, the understanding of databases is very limited because they see it as some abstract physical storage black box not unlike a relationally structured file system (I can hear the anguished screams of terror DBAs are giving off right now).

First, SQL Server has two kinds of indexes: clustered and non-clustered. They are both implemented as B-Trees, meaning that you have a tree structure of nodes (for fast searching). In both cases, the indexed values are stored in order (from min to max, or alphabetically). The main difference between clustered and non-clustered indexes is that clustered indexes incorporate the actual storage of the data, whereas non-clustered indexes are separate lookups pointing to the data. OK, for a better idea of this notion, think of clustered indexes like a directory, encyclopedia, or phone book – the contents of the book itself are stored in order by a name or key. A non-clustered index is more like an index in a chemistry textbook: the index entries are in ordered, but it is separate from the content (found way in the back in some appendix), and each index entry points back to a specific fragment of actual content, which is in turn written out completely independent of the order of the index. Otherwise, both are pretty similar in terms of physical storage in the DB file. There are other nuances (such as whether or not unique keys are present), but those are somewhat inconsequential to this particular matter.

SQL Server is designed around pages of data, each containing 8Kb. As long as data is contained within a single page, things are fast. But when SQL Server has to switch pages, you get a performance hit, particularly when said page isn't contained in the same block (extent) and/or isn't cached and physical IO has to occur. Just like everything else in the DB, your indexes are written on pages. Now let's say that (in a really simplified view) your index, containing simple integer IDs for this example, looks like this:

original index

Notice that each page is full and everything is sequential and contiguous. This is what a good index is supposed to look like. The index Value here is the ID itself. Now let's pretend I have to insert a row where the index value (the key in this case) is 6. This entry has to be written into a page that already has data, and worse, is already full. Now SQL Server has to do a page split and relocation – which is very expensive for a write. Your index would now look like this:

original index

Notice that for entry 6 to be inserted in order, the rest of that page had to be split off, and relocated to a new page – which also happens to be at the end, so the page itself is also out of order. This affects query performance in a number of ways because the pages aren't contiguous (the scan has to bounce around), and caching will be difficult depending on the spacing between the pages (which is why this problem grows worse as the table gets larger). For severely fragmented indexes, which is what happens with random/pseudo-random/hashed values (like non-sequential GUIDs), page switching on queries will be very noticeable.

Also, notice that you now have partially-filled pages. Page 1 and Page 3 have holes with no data. This sharply increases the size of the data file for large, fragmented indexes. So in addition to GUIDs being physically larger values than the INT IDs, you get substantial data bloat with page fragmentation.

You can avoid a lot of these problems simply by using sequential GUID keys (for example, by using the NEWSEQUENTIALID() function) if you don't care much for INT IDs. Though the size of the data will increase, obviously, storage is cheap and a lot of people simply won't care, although you still have to take performance into account. However, this isn't really possible when using client-side generated IDs, barring some complex infrastructure.

So what makes me curious is why people want to use client-side generated IDs to begin with. This is genuine curiosity because it's possible the solution is solving problems that no longer exist or might be better served with a different solution. One of the reasons for client-generated unique IDs used to be that you couldn't always depend on the server to hand you the correct the identity value for parent-child relationships inserted in batch. For example, @@IDENTITY could hand you the wrong ID value since it grabbed the last ID produced by the session, which could have been the result of an insert trigger write to a different table, rather than the identity insert of the present command statement (as an example). However, there are more elegant ways around this today, particularly with the SCOPE_IDENTITY() function. Of course, that's all SQL Server specific, so YMMV depending on your particular scenario.

posted @ 5/21/2009 4:30 PM by DevPrime

IDENTITY vs. ROWGUID

I had the pleasure of once again talking with Dan Simmons from MS at a TechEd mix session. He probably thinks I'm a pain in the butt with all my EF requests, but I do enjoy our conversations. Anyway, after the session, we were discussing data architectural decisions with some of the attendees when primary keys came up. At some point, the issue took a turn towards the old INT ID vs. GUID discussion. Ironically, I had the same discussion with someone else this week, so I figured it would make a good post.

INT ID vs. GUID is one of those long-standing arguments that for whatever reason rival SProcs vs. No-SProcs in terms of passionate opposition. People either love GUIDs or hate them. But the fact of the matter is that a lot of people simply have a hard time understanding the details enough to make an informed decision.

My first reaction is to say that GUID keys are there for a reason. That reason, as far as I can tell from back in the day was replication. In fact, on some of the tooling, you'll see uniqueidentifier identities referred to as replication identities. At this point, Dan quickly pointed out that GUIDs aren't guaranteed to be unique (at least across machines in this scenario), and that's a very good point to stress. In the old documentaion, you would see scenarios where people dumped data from disperate systems into a central BI database for analysis. The problem then becomes one of overlapping IDs. Enter GUID ID. But really, that only mitigates the problem to a certain degree since you still have to code for the occassional identifier collision.

GUIDs as IDs have two main drawbacks:

1) The size. They are four times the size of a normal INT. That may not seem like a lot for today's storage hardware, but on a table of 4 million rows, that's 12MB of difference. Multiply that by several tables and/or more rows, and you get the idea. Now, many tables may not get that big and you don't necessarily have to worry about it much.

2) (another reminder that Dan brought up) GUIDs do not index well, particularly if you are talking about clustered indexes (the default for primary keys in SQL server tooling). In this scenario, because they aren't sequential, GUIDs tend to fragment the index horribly. This both wastes space and can make index updates and relocation computationally expensive. In 2005, SQL Server introduced a new function - NEWSEQUENTIALID() - to help alleviate this problem. However, most people don't use it, and you still have to contend with the size issue.

I've seen people also argue that the set of operators for GUIDs are more limited than the set for INTs, but I don't think this argument carries a lot of weight. After all, you shouldn't be using arithematic operators on primary keys anyway. Comparison operators are perfectly valid for both though. However, if you don't have sequential IDs, then comparisons for ranking and sampling (for example, for paging) become a lot trickier.

At the end of the day, there's nothing particularly evil about using GUIDs for identifiers. However, I think people need to fit the solution to a specific problem and carefully weigh the pros and cons. Personally, I'd go with INT identifiers natrually unless there was a compelling reason to use GUIDs. And expected data size isn't one of those reasons. If you need more than 4 billion records, you can always upgrade to BIGINT.

posted @ 5/19/2009 11:38 AM by DevPrime

Install the Surface SDK SP1 Workstation Edition on x64

image_thumbThe Surface SDK SP1 Workstation Edition was released this week and while it will install (but is still unsupported) on Windows 7, it will not install on a 64-bit machine.  The installer has changed a bit, so my previous instructions will not work with this installer, but I have managed to get the new package to install and run.  And here’s how…

As before, this is a totally unsupported setup, so if official support from Microsoft is required, this is not for you.

Please note that you will still need to meet the other hardware and software requirements of the SDK.

To perform the actions in this guide you will need to install Orca, a tool for editing MSI files, included with the Windows SDK.  Unfortunately, this utility isn’t available separately and will require you to download the full SDK to get it.  You can download the Windows Vista or Windows 7 SDK here.

1) Extract the MSI to its individual files

This can be done with the following command performed in an elevated cmd window:

msiexec /a SurfaceSDKWE.msi /qb TARGETDIR=c:\surface (or some other TARGETDIR of your choosing)

When complete, you will have a new directory at TARGETDIR filled with a smaller MSI and all the files contained within the original MSI.

2) Remove the platform check from the MSI

Open the newly extracted SurfaceSDKWE.msi file in Orca.  Select LaunchCondition from the left pane.  In the right pane, select the row labeled Installed OR NOT VersionNT64, right-click, and select Drop Row.  This will remove the check for a 64-bit OS.

5-14-2009 5-52-27 AM

After the rows are dropped, save the MSI using the standard File –> Save menu option.

3) Patch the setupcustomaction.exe file

This executable is called during the SDK installation process.  Because the installer will launch as a 64-bit application, so will this executable, which will force it to write some registry values into the wrong location.  Therefore we have to patch this file using the corflags.exe utility included in Visual Studio and the .NET SDK. 

If you have the full Visual Studio installed, simply open an elevated Visual Studio Command Prompt from the Start Menu and the path to corflags.exe will automatically be loaded.  Otherwise, you should find this in the C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin directory and you can set your PATH environment variable appropriately.

With the path to corflags.exe in your PATH environment variable, change to the following directory:

<TARGETDIR from above>\Microsoft Surface\v1.0

Inside this directory, run the following command:

corflags setupcustomaction.exe /32bit+ /force

You will get a warning that the file is strong named signed.  You can safely ignore this.

Administrator Visual Studio 2008 Command Prompt (2)

4) Install the SDK

Now that the MSI and setupcustomaction.exe have been patched, run the extracted and patched SurfaceSDKWE.msi file from the TARGETDIR location, not the original MSI file.  As long as you have the other prerequisites installed, the SDK will install without issue.

5) Patch the executables / Build and fix the samples

These steps are identical to last time, so I will just link to the original blog post here.

And there we have it.  A patched and working Surface SDK SP1 running under Vista/Windows 7 x64.  As always, run this at your own risk, but let me know how it works out for you if you give it a try.

Cross Posted from www.brianpeek.com.

posted @ 5/14/2009 6:28 AM by Brian Peek

5 Firefox Add-Ons I Can't Live Without

Inspired by Martin over at gHacks, here's my list of Firefox browser add-ons that I consider essential:

  1. Mouse Gestures RedoxNavigate back and forward, close windows, and more with just the mouse. I turn on "mouse trails" to make it easier to see what I'm doing.
  2. Easy DragToGoDrag a link to open it in a new background or foreground tab.
  3. Adblock PlusBlocks ads, and is very configurable. Having a little "block" link I can click next to images and flash is extremely handy.
  4. FirebugIndispensable for web development, especially the ability to edit, "live", any part of a page. Also has some of its own add-ons available.
  5. SingletonFox, ChromaTabs PlusOK, that's two items at number 5, but I couldn't decide which one was more useful - making sure only a single instance of Firefox is open, or slight tab coloring depending on the site to make for easy identification of tabs.

These are fairly stock-standard add-ons, particularly numbers 1-3 which I've been using in some form or another since 2002 and MyIE. In addition, they're all very unintrusive - between the 6 add-ons, only 1 toolbar button is added (I like to keep my toolbars, menus and status bar lean).

Any browser add-ons that you couldn't live without?

Tags: , ,

posted @ 5/14/2009 12:31 PM by Thomas Williams

TUX: Wednesday May 13th, 2009 with Christopher Bennage

Just a quick reminder that at Tampa UX tomorrow night we’ll have Christopher Bennage presenting. Shawn Cady will also be continuing his What is UX series. Doors open at 6:30pm with the speaking starting at 7pm.

Check out the web site for more detail.

posted @ 5/12/2009 9:50 AM by Jay Kimble

.NET’s Most Influential People in 2009

[5/7/09 Small update to add a requested link]

My family subscribes to Time Magazine ©. This past week we received their annual 100  “The World’s Top Influential People” issue. One of the things I like is that there are always people in these lists that you never heard of. Some are kind of lame in my opinions and then there are those exceptions who you look at the article and say “cool!” The on thing I noticed was there weren’t any developers on the list…

I have been thinking about who I would throw in a list of DotNet influentials. Now the catch is that I’m avoiding any of the very visible MS employees. So in other words no Phill Haack (he’d be on my big list though), no ScottGu, no Scott Hanselman, no Nikhil Kothari (although that one hurts), and no Brad Abrams… I’m also not putting folks like Jesse Liberty or Tim Heuer (again very painful… I met Jesse and he would definitely be in my top tier list..) Ok, so you get the picture.. .NET Influentials that aren’t known for the their MS contributions..

Here’s my 5 (I’m trying to pick less common guys for my list)

1) Miguel de Icaza 
If you know who ScottGu is and you don’t know Miguel then shame on you! Seriously! Miguel is the guy who heads the mono project at Novell (that would be .NET on Linux, Mac, Sun Solaris, etc…) He’s more than important and wicked smart. I sat next to him at Mix and I swear my IQ jumps 5 points just from being near him (and keeping my mouth shut).. <grin /> Again, seriously very smart guy who does stuff that validates your choices as a VB/C# developers. (I suspect that Miguel might have been a bit obvious, but I can’t not mention him.. too important.. if you see him at a conference you should know who he is on sight… and I know that is not something that is not always true)

2) Bill Reiss, Chris Bennage, and Rob Eisenberg
If you want Silverlight to succeed as a platform then IMO the next installation point is games.. I installed WIndows XP on my son’s (crappy) PC because he wanted to play games and SL doesn’t run on Windows 98 (his old OS).. People install runtimes to play games.. Bill, Chris, and Rob set up a web site for Silverlight Games (silverlightarcade.com).. Bill is also the lead developer behind SilverSprite an XNA to Silverlight compatibility library for 2d XNA games.. (Rob and Chris are members of the team).

3) John Resig – JQuery Lead and JavaScript Guru
You may think this is a bit of a cheat, since John isn’t a .NET developer, but trust me his contribution to Ajax/Web 2.0 is HUGE. If you code in this space I really don’t need to say much more than this. JQuery is a deceptively simple solution to the problem of developing fancy ClientScript solutions. It is LINQ for JavaScript/DOM Scripting..

4) Rob Conery – the SubSonic guy
Ok, I know Rob is a bit of a cheat, but I’m not really interested in his ASP.NET MVC Contributions. I’ve recently reconnected with the SubSonic3 project. And let me tell you, it’s going to be huge. I think it’s better than both Entity Framework and Linq To SQL.. RIGHT NOW. All those years at CodeBetter.com I heard the ALT.NET guys talking about using the Repository pattern and I thought dang another layer… what’s wrong with these guys.. they overcomplicate everything (being transparent here…) So SubSonic has that pattern basically built in, and IT ROCKS! I love it.. I get it.. SubSonic was the project that converted me to ORM (I am a classic Stored Proc lover), and now to the repository pattern. Those wanted to improve the general quality of software should look at Rob’s example.. he’s projects make it easy to do.. AND then there’s his ASP/NET MVC contributions (did you hear Hanselman in his Nerd Dinner takl at MIX09 refer to the repository as a “Rob Conery Repository.” Rob’s the guy who built the html helper (whether you like or hate them).

5) Daniel Cazzulino – Moq and T4 Editor
Ok, I’m not entirely sure of Daniel’s involvement on the last one. I know he is huge in the Moq space. I know that Moq is my mocking library of choice (although I have that license of TypeMock I need to play with some more… and, yes, I do test and I do mock/double/isolate/etc.) Daniel always seems to have his head around something new (several years ago I saw him demo a project that he wrote while XML was alive that did XML Schema Validation… he’s definitely a mover and a shaker)..

Honorable mentions
I had trouble picking that last one.. Here’s the list of others that I thought about for that last spot.. Rory Becker (DxCore Community Plugins project.. I use CodeRush, so his work greatly affects me), Chad Myers (mainly for his work in the ALT.NET space and his ability to hold back his own zeal and be a really reasonable/truly evangelistic voice… he’s also involved with the BUFU MVC project), Billy Hollis (‘cause we like Billy around here at the runtime… ), Dave Hayden (of CodeBetter and numerous other fames), and Sean Chambers (whose blog and projects really do a good job of helping the recreational agilist).

The obvious ones not mentioned
There are a couple obvious names that didn’t get mentioned mainly because I don’t use their projects or just because the individual aren’t any less known than the MS guys I mentioned at the top of the article. Names like Ayende, Roy Osherove, Karl Franklin, Richard Campbell, Dino Esposito, Juval Loewy, and Rocky Lhotka just to name a few..

Did I miss anyone?
This was my list. you got your own you want to contribute.. Fire up your blog software and create a reply to this post on your blog.. we’ll compile a big list later on.. make sure there is a link back… if we get enough responses I’ll create a new post with links back to everyone’s blog (if someone with more readers than me posts then we’ll post the follow up on their blog)

So who do you think are the top 5 .NET Influencers for you, personally..

posted @ 5/6/2009 2:09 PM by Jay Kimble

Drools on Windows (Part 3 of 22) - Object Interop

In order to use the (amazingly cool) Drools rules engine in a .NET world, you've got to figure out how to pass your .NET business object over there to the land of Java.  There are a couple of ways to do this.  I wanted a straightforward way that didn't rely on any 3rd party tools.  Here's the gist of what we're trying to accomplish:

  • Instantiate a .NET object; populate with values.
  • Serialize the object and send it to a queue.
  • Java application monitors the queue; picks up the message text.
  • Java app unmarshals (i.e. deserializes) the text into a Java object.
  • Java app fires the rules, previously loaded, which may or may not modify the Java object's properties.
  • Java app marshals (i.e. serializes) the resulting object, and sends it to a queue.
  • .NET queue monitor picks up the message, deserializes it into a .NET object.
  • Excellent!

To achieve this type of scenario just takes a bit of setup with the objects you intend to pass back and forth.  Here's one way how to do that setup.

A.  Create your .NET object.

Create a class library in .NET.  Here's an example of something we can tinker with for the duration of this blog series.  Compile it into a dll.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Text;
   5:  using System.Xml.Serialization;
   6:   
   7:  namespace ZenDoodle.Common.Messaging.Models
   8:  {
   9:      [XmlRoot(Namespace = "http://zendoodle.com/messaging/XML-Schema/2009",
  10:               ElementName = "Customer")]
  11:      public class Customer
  12:      {
  13:          public string Name { get; set; }
  14:          public string Address { get; set; }
  15:          public string City { get; set; }
  16:          public string State { get; set; }
  17:          public string PostalCode { get; set; }
  18:          public CustomerType TypeOfCustomer { get; set; }
  19:          public List<string> Messages { get; set; }
  20:   
  21:          public enum CustomerType
  22:          {
  23:              Bronze,
  24:              Silver,
  25:              Gold,
  26:              Platinum,
  27:              Adamantium
  28:          }
  29:      }
  30:  }

 

B.  Get your Xsd on.

Use the Microsoft-provided xsd.exe utility to create your Xsd file. Or hey, roll your own if that's your thing. Whatever.

Sample command:

"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64\xsd.exe" C:\Zen\Zendoodle.dll /o:C:\Zen\Schemas

   1:  <?xml version="1.0" encoding="utf-8"?>
   2:  <xs:schema xmlns:tns="http://zendoodle.com/messaging/XML-Schema/2009" elementFormDefault="qualified" 
targetNamespace="http://zendoodle.com/messaging/XML-Schema/2009" xmlns:xs="http://www.w3.org/2001/XMLSchema">
   3:    <xs:element name="Customer" nillable="true" type="tns:Customer" />
   4:    <xs:complexType name="Customer">
   5:      <xs:sequence>
   6:        <xs:element minOccurs="0" maxOccurs="1" name="Name" type="xs:string" />
   7:        <xs:element minOccurs="0" maxOccurs="1" name="Address" type="xs:string" />
   8:        <xs:element minOccurs="0" maxOccurs="1" name="City" type="xs:string" />
   9:        <xs:element minOccurs="0" maxOccurs="1" name="State" type="xs:string" />
  10:        <xs:element minOccurs="0" maxOccurs="1" name="PostalCode" type="xs:string" />
  11:        <xs:element minOccurs="1" maxOccurs="1" name="TypeOfCustomer" type="tns:CustomerType" />
  12:        <xs:element minOccurs="0" maxOccurs="1" name="Messages" type="tns:ArrayOfString" />
  13:      </xs:sequence>
  14:    </xs:complexType>
  15:    <xs:simpleType name="CustomerType">
  16:      <xs:restriction base="xs:string">
  17:        <xs:enumeration value="Bronze" />
  18:        <xs:enumeration value="Silver" />
  19:        <xs:enumeration value="Gold" />
  20:        <xs:enumeration value="Platinum" />
  21:        <xs:enumeration value="Adamantium" />
  22:      </xs:restriction>
  23:    </xs:simpleType>
  24:    <xs:complexType name="ArrayOfString">
  25:      <xs:sequence>
  26:        <xs:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="xs:string" />
  27:      </xs:sequence>
  28:    </xs:complexType>
  29:  </xs:schema>

 

C.  From Xsd to .java - Into the Breach!

The Java utility for working with schemas is xjc.exe.  Actually, as with all things Java, there are at least 835,234 different ways of doing this.  This is just how I do it.  YMMV.

Sample command:

"C:\Program Files (x86)\Java\jdk1.6.0_12\bin\xjc.exe" -verbose C:\Zen\Schemas\schema0.xsd -p com.zendoodle.customer

This will generate .java source code classes.  Which is great, but you must make one modification! And that is to identify the XmlRootElement by name.  I've highlighted the two lines of code that you have to add below in bold red.

//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2009.05.04 at 08:59:01 PM EDT
//


package com.zendoodle.customer;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * <p>Java class for Customer complex type.
 *
 * <p>The following schema fragment specifies the expected content contained within this class.
 *
 * <pre>
 * &lt;complexType name="Customer">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="Name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="Address" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="City" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="State" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="PostalCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="TypeOfCustomer" type="{http://zendoodle.com/messaging/XML-Schema/2009}CustomerType"/>
 *         &lt;element name="Messages" type="{http://zendoodle.com/messaging/XML-Schema/2009}ArrayOfString" minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 *
 *
 */
@XmlRootElement(name="Customer")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Customer", propOrder = {
    "name",
    "address",
    "city",
    "state",
    "postalCode",
    "typeOfCustomer",
    "messages"
})
public class Customer {

    @XmlElement(name = "Name")
    protected String name;
    @XmlElement(name = "Address")
    protected String address;
    @XmlElement(name = "City")
    protected String city;
    @XmlElement(name = "State")
    protected String state;
    @XmlElement(name = "PostalCode")
    protected String postalCode;
    @XmlElement(name = "TypeOfCustomer", required = true)
    protected CustomerType typeOfCustomer;
    @XmlElement(name = "Messages")
    protected ArrayOfString messages;

    /**
     * Gets the value of the name property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *    
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the value of the name property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *    
     */
    public void setName(String value) {
        this.name = value;
    }

D.  Compile/JAR.

Last thing you have to do for the setup is to compile the .java classes into .class files, and then pack them into a .jar file.  This is so that your set of .class files can be easily referenced.  Include the .jar file in the Build Path of the Java application.

Sample command:

"C:\Program Files (x86)\Java\jdk1.6.0_12\bin\javac.exe" com\zendoodle\customer\*.java

"C:\Program Files (x86)\Java\jdk1.6.0_12\bin\jar.exe" cfv customer.jar com\zendoodle\customer\*.class

Pause

 

 After that, you should be able to move objects with their data back and forth between .NET and Java.  And for crying out oud, if you're ever going to do this more than once, automate it! 

Next time we'll take a look at the queue, and how all the pieces will fit together.  If you love weird and nifty stuff, see you then!

 

posted @ 5/5/2009 7:13 PM by Dana Stevens

Windows Virtual PC and the Microsoft Device Emulator

Windows 7 (as of RC1) now supports a pretty spiffy new feature known as Virtual Windows XP or Windows XP Mode based on what article you read.  At its core, it is a new version of the Virtual PC product, now named Windows Virtual PC, installed closer to the OS, combined with a Windows XP hard disk image which allow you to run legacy applications under Windows XP on your Windows 7 machine in a pretty seamless way.

If you install the Windows Virtual PC add-on to Windows 7, you must first uninstall Virtual PC 2007.  By doing that, you remove the special network driver that is also required to use the Microsoft Device Emulator on the network.  The device emulator is typically used for Smart Device development.

So the puzzle:  The Device Emulator doesn’t work with the new Windows Virtual PC driver, and you can’t install the old version of Virtual PC 2007 and expect the new Windows Virtual PC to keep working.  What to do?

The answer is to extract the Virtual PC 2007 network service drivers out of the MSI package and manually install them in Windows 7.  So far this has provided the expected result for me:  Windows Virtual PC runs happily, and the Device Emulator now connects to the network.  So how do we do this?  Thanks for asking.  Here is a step-by-step guide to make this go.  Note that this is very much a “works on my machine” experience.  If it burns your house down, don’t hold me responsible.  Note that you should have a valid and complete backup before attempting this on your machine just in case…

  • Download the Virtual PC 2007 SP1 installer executable
  • Rename the installer from setup.exe to something else, such as vpc.exe
  • Open a cmd prompt, navigate to the setup executable, and run (assuming you renamed the file to vpc.exe):
    • vpc.exe /c
  • This will extract the executable to an MSI file at located in the %temp% directory
  • Change to the temp directory by running:
    • cd %temp%
  • In this directory, extract the MSI by running:
    • msiexec /a Virtual_PC_2007_Install.msi /qb TARGETDIR=c:\vpc
    • Of course, feel free to replace that directory with one of your choosing
  • This will extract the MSI file to c:\vpc (or the one you entered)
  • Open the Network and Sharing Center and select Change adapter settings
    adapter
  • Right-click the network adapter you have connected to the internet and select Properties
  • Click the Install… button
    install
  • Make sure Service is selected and click Add…
    type
  • Click Have Disk…
    disk
  • For x86 machines, navigate to:
    • C:\vpc\Program Files\Microsoft Virtual PC\Utility\VMNetSrv\
  • For x64 machines, navigate to:
    • C:\vpc\Program Files\Microsoft Virtual PC\Utility\VMNetSrv\x64
  • Select Virtual Machine Network Services and click OK
    vmns

At this point the driver will be installed and attached to that network adapter.  If you have the need to attach this to multiple adapters, simply repeat the steps above to install the service on each adapter required.

Once the driver is installed, you can then link the Device Emulator to the chosen adapter and connect to the network as always, as well as connect to the network in the new version of Virtual PC.

Let me know how it works for you!

Cross Posted from www.brianpeek.com.

posted @ 5/2/2009 3:39 AM by Brian Peek

Ever wanted to turn off Windows Beep?

The other day my PC started beeping at me. Every "Are you sure?" message box was accompanied by a "beep". I don't know how or why this started...I only wanted to make it go away.

First check, Control Panel -> Sounds. I confirmed