More servicesWindows Live
HomeHotmailSpacesOneCare
 
MSN
Sign in
 
 
Spaces home  Brownie PointsProfileFriendsBlogMore Tools Explore the Spaces community

Brownie Points

The Tale of a .NET Conv...Fanatic.
July 08

Shadow Copies Saved My Live

I'm a control freak...when I delete something, I want it gone like now. I don't want it to go to a recycle bin so I can retrieve it later. Get off my computer...NOW. So when I delete a file, I always use Shift+Delete to bypass the "send to recycle bin" phase. That has bitten me in the butt a few times in the past. Thanks to Vista's shadow copy service, I have been able to recover from over zealous deletion twice now. Once with a source tree with changes I hadn't committed to source control yet. And just now with the entire contents of my downloads folder.

I may sound like one of those commercials that you see where people give "real" testimonials about how good a product is. But believe me, if you've ever wished you could undo a delete, shadow copies are the next best thing to having a rewind button for life.

June 24

Returning to the Motherland

As I mentioned before (I think), my focus on UI development has been a recent phenomenon in my career. Prior to that, the majority of my efforts has been in back-end frameworks and integration. Even looking at what I've done in the WPF arena, most of my attention has been on creating utilities that do a lot of behind the scenes work: MVPoo, Commands, Attached Properties, and all that fun stuff. I guess it's only natural that I land back in the arena of back-end and framework development. I've got a few interesting classes and utilities to share from my recent excursions in the area. Hopefully, someone will find these useful.

First up are a couple of extension methods for range validation. Right now, they only work on IComparable<T> (which all value types derive from). Being extension methods, they only work with .NET 3.5 but it is an easy exercise to change them to standard static utility methods. The interesting bit I discovered writing these is that extension methods can be Generic. The unfortunate part is the redundancy required here...something that Jeff Atwood would probably frown upon. Here is how the method would be used:

int tmpInt=45;
bool isValid=tmpInt.ValidateRange<int>(25,50);

The ValidateRange methods (I overloaded the function so that a caller can specify whether the range should be inclusive) take the type of the object being validated as a type parameter so that it can pass it to IComparable<T> and strongly type the min and max parameters. I guess I could just use the non-generic IComparable interface instead of IComparable<T>, but then you'd lose the compile time verification.

Anyway, the code is attached below. Let me know what you think.

June 20

Prism Becomes Composite Application Guidance for WPF

Or CAPPG for short. I had the pleasure of participating on the advisory board over the past few months. I think the biggest boost to my ego came when I saw the Delegating Command captured as a best practice by the PnP team.

Prism (there was an acronym there but I forgot what it is) is a new guidance framework, in the vein of the CAB, SCSF , and WCSF, that captures best practices from the pioneers in the wild west of WPF development. (Remember WPF is still considered to be in the early-adopter phase.)A lot of the writings of Josh Smith, Dr. WPF, Dan Crevier , and others has been captured in this framework (which is still, according to the team, a work in progress). I have my own work that is soon to be in progress and will use Prism to take it through its paces.

If you will be doing any significant WPF development in the near future, it couldn't hurt to evaluate Prism. Here's the link.

June 02

The Best Part of Blogging

You get to look back at your old posts in astonishment at how far you've come from back then. Take Paul Stovell for example.

In March of 2006 he gave a presentation called "Why I hate Data Binding"

In July of 2007 he gave a presentation called "Binding Oriented Programming"

Talk about an about face! I don't have any drastic examples like that in my blog. But it's still fun to read through some of my old posts.

May 08

You ARE in the Software Business

I've spoken a lot about the potential that Team Foundation Server provides as a framework for creating very powerful software development process tools. I've also spoken a lot about supporting your software development department with a dedicated development team. These two ideas go hand in hand. Let me expand on that here.

When a company wants to support their business processes with software, they have two choices: buy a product off the shelf; or build a custom software solution. Actually, there are three choices, but the third is a hybrid of the first two: customize an off the shelf product.

The software your company creates for the sprocket order fulfillment system is an electronic manifestation of your company's business processes. You have significant amounts of money set aside every year to improve that software so that it better captures your business processes. You know that COTS software won't be an exact fit for what you are doing, your processes are what give you an edge over the sprocket factory down the road.

Why is it that companies are so quick to segregate software development from the rest of their business? "IT supports the business, it's not a core business process." "We're not in the software business, we're in the sprocket business."

Stop it! It's time to come to terms with reality that if you are spending money to develop your own software or to customize off the shelf software, YOU ARE IN THE SOFTWARE BUSINESS. Even if the only consumer of your software is you. Once you've accepted that fact, you'll realize that software development is a core business process. Do you see where I'm going here? We take it for granted that an off the shelf product is good enough for developers. You don't know how many times I've heard people complain "if only visual studio did this" or "I wish TFS was easier to work with." Sound familiar to the same complaints you hear about the CRM tool your company just bought? The big difference is that code gets written to address the shortcomings of the CRM solution. Whereas Visual Studio and TFS get to stay as they are and development teams are trained to "work with the system." When was the last time you've heard of a company (other than a software vendor) having a project dedicated to creating tools that improve the software development lifecycle?

Why spend so much money creating software that captures all of your business processes except the one that makes the rest possible? And if you don't think that improving your software development process isn't as important as your "core business", you'll quickly be left behind when that sprocket factory down the road figures it out.

May 06

Attached Properties for Max Column Width

Laurent Bugnion (a fellow WPF Disciple) just wrote a post showing one way to add MaxWidth capabilities to the WPF GridView. William Kempf (another disciple whom I had the pleasure of meeting when I gave my presentation at Indy Code Camp), suggested that Laurent use an attached property to allow the feature to be XAMLized.

I thought it would be a good idea. So I fired up VS and wrote a little bit of code. If you've read my posts on using the remora pattern then you know the gist of the setup (if not go see them here). Laurent jumped through a few hoops to hook into the drag event of the GridViewColumnHeader resize thumb control. I found out that GridViewColumn implements INotifyPropertyChanged so on a whim decided to check if I can catch a Property changed event when the Width is changed. Lo and behold I could. So I checked if I could do a poor man's CoerceValue and surely enough I was able to do that as well. I couldn't think of a better place to put it, so I checked the code into the WPF Toolbelt (along with a few other changes). This makes the first check-in since September of last year. I just reorganized some namespaces and stuff...it took me a while to get reacquainted with the code. But I will be performing more work on it in a while. Download the code from Skydrive (only have the MaxWidth attached property now...MinWidth isn't much harder though).

March 12

You'll Grow Out of It

albumcover I followed the instructions for an interesting meme that I found on Eric's blog and came up with the album cover you see to the left. Here are the original links if you're interested:

The Picture

The Quote

The Article

I took artistic license and named my band just Wyoming County, but it the recipe works pretty well. The funny thing is...the title is somewhat appropriate. I think I have grown out of my current space and have already taken up residence in a new environment. I will begin moving my old content over (someone remind me to keep local copies of my blog posts for the next time I want to do this), and adding new content to the main domain. In the interim, it will just host Brownie points. So what are you waiting for? My latest post is waiting for you right here

January 22

The Problem as I See It

I remember helping a developer who was attempting to transition from C to C++. Because valid C is valid C++, it was difficult to get the point across to him that -- even though it worked -- it wasn't necessarily the best way to do things. It takes a concentrated effort for someone to unlearn bad habits.

For an example look at Winforms programming. It is dead simple to drag a few controls onto a form and wire it up to perform business logic on a button click. I must confess I've done this myself, even as recently as last year (oh wait it's 2008 now make that the year before last). It took me struggling with WPF to realize that even though it "worked" that was not the best way to wire up my UI (in all but the simplest of cases). I decided to explore the benefits of the Model-View-Controller Pattern (or MVC for short) for my application development. I knew of this design pattern's existence but had never bothered to implement it explicitly in my development. As I got my feet wet with using MVC for my WPF UIs, I started noticing a lot of benefits.

Actually let me correct myself. I didn't consciously decide when I first started coding in this manner that I was going to use the MVC pattern. I just decided to remove the logic of deciding what controls were enabled, how to initialize the UI, and how to validate the data entered into the form (among other concerns) away from the Window/UserControl and into a helper class that worked with the UI while shielding it from the intricacies of how the system works.

Once I looked at what I had done, I finally realized that I had implemented a variation on the MVC pattern. I had read some of Dan Crevier's blog postings regarding what he called the Model - View - ViewModel, or MVVM, pattern (itself a refinement of the MVP pattern) prior to this so I guess it had laid dormant in my subconscious until I needed it.

I have come to realize that going from basic "Forms and Controls" (as Martin Fowler calls it) UI development to MVC is a paradigm shift on the magnitude of going from procedural development to object-oriented development (e.g. C to C++). Although the same development techniques that make Winforms (and VB before it) development so approachable still "work" with WPF, the framework really shines when you move to an MVC architecture for your UI. Once you grok this concept, you'll find that you'll hesitate to write even simple applications without using it.

January 02

Dynamic Dependency Properties

First things first. I'd like to wish everyone a Happy New Year. Here's hoping that 2008 brings with it happiness, excitement, joy, and wonder!

Recently I came across a blog post that discussed the use of Custom Type Descriptors to dynamically add properties to an object. We currently use this technique in our application, however there is a lot of hocus pocus going on behind the scenes that makes working with that particular piece of code precarious.

I was curious if it would be possible to dynamically declare dependency properties and bind to them using the WPF Binding system. The short answer is yes. The long answer is HELL YES! Believe me using dependency properties to dynamically add properties to your objects is orders of magnitude easier than using custom type descriptors. Something tells me that DPs are just an abstraction of custom type descriptors. Does that make me lazy? Probably. Then again, the less code I have to write to accomplish a task, the less likely I am to introduce bugs, and the quicker I can get to the next task. And as we all know, "programming  is fun, but shipping is our job." Besides, you want to trust me on this one...programming Custom Type Descriptors is not fun.

Of course you, my dear readers, are probably wondering, "Why would I want to dynamically register dependency properties?" Isn't the whole point of a dependency property to allow you to bind to it at design time? Well not only does Mabsterama give a great scenario with the role provider, but there is a well known data modeling pattern known as Entity Attribute Value. I just ran into a post in the forums (which are finally working properly again) where the poster appears to be in need of a similar solution. This encouraged me to finish this post.

My solution relies on a simple class that I call the DependencyPropertyRegistry. The DependencyPropertyRegistry is responsible for dynamically registering dependency properties against a DependencyObject descendant and keeping track of the properties so they can be manipulated. The second part of the solution is a class that wants to dynamically expose properties for binding. The final piece of the puzzle is a control that knows how to properly configure the bindings and display them.

This is easiest explained through code, but I have to do some scrubbing before I can share it with you guys. I promise it will be worth the wait.

December 19

How "Cider" Saved the Day

Or "My New Favorite Feature of the WPF Designer"

So I'm giving a quick presentation of my favorite new feature in VS 2008 at the Wisconsin .NET User Group Installfest, and because I hadn't actually prepared for the presentation in advance, Murphy's Law is in full effect. My normally snappy computer is crawling through the simplest of tasks (because I'm on battery power save mode). I'm floundering here and want to hurry and finish the demonstration (the "Cider" WPF designer). So now I'm standing in a pool of my sweat, I can't even see because the saline is dripping into my eyes. And I have to remember the syntax for importing a CLR namespace. I look to a familiar face "Quick what's the syntax for importing an assembly for reference in XAML?" Travis looks back at me with a blank stare. So I start typing hoping that something will pop in my head when I see:

image

At that very moment, I felt that Team Cider had put this feature in there for this very situation. I stated emphatically...well there you have my new favorite feature!

Overall the meeting was great. The turnout was HUGE. We had an assembly hall filled with people ready to install VS2008 (Professional this time as opposed to the 2005 launch when they gave out Standard). I forgot my full camera and for some reason, I can't email the pictures from my phone so I'll refer you to Larry Clarkin.

Hands down the best mini demo in my eyes was the demonstration of the code metrics capabilities of the VS 2008 Team Editions, the presenter of that feature won a copy of SceneIT! for the Xbox 360. Brennan won an 8 GB Zune for his presentation. There were a ton of toys donated in exchange for a raffle ticket. The winner got an Xbox 360 Elite with Halo 3 Limited Edition (not Legendary). And the food spread was fantastic. Especially the nacho toppings...chili and queso dip poured over tortillas is delicious! Overall, it looks like everyone enjoyed themselves. At the very least they got a free copy of VS 2008 Pro.

View more entries
 

Brownie

View spaceSend a message
Occupation:
Age:
Location:
I'm an "unofficial" Microsoft Tech Evangelist for Client Application Development.
"Unofficial" means that all of my observations are completely my own and I imply absolutely no endorsement by Microsoft, any of their agents, my employer, or any of their agents.

All code is provided "as is" with no warranty either expressed or implicit.