![]() |
|
Spaces home Brownie PointsProfileFriendsBlogMore ![]() | ![]() |
|
August 30 What I'm Working OnAugust 27 PnP Design for OperationsSo while I was testing out "Flow", I came across a link to a Patterns and Practices project that I hadn't seen before called Design for Operations. Basically, this project provides guidance and tools for placing instrumentation and management hooks into your application so that it can work with System Center and other management tools. There have been a number of times where I thought it would be nice to add this kind of functionality into an enterprise app and leverage the capabilities of SCOM (formerly MOM) to provide rich management and metrics; but I didn't have a clue where to start. This package looks like it would give a huge jumpstart into doing just that. August 26 Turn Off Vista AutotuningIf you have an older router, Vista's network auto tuning feature will cause it to get confused. Some suggest turning off Stateful Packet Inspection (or SPI) on the router will fix the issue. Others say updating the firmware will work. If your router does not have an option to turn off SPI or you do not want to do so, or if your router manufacturer no longer provides firmware updates, the last option is to turn off autotuning. Here's the magic command line to do so: c:\>netsh interface tcp set global autotuninglevel=disabled I recently rebuilt a laptop and had a hard time finding this solution again. Now it's documented in a well known place for me (and you as well). August 14 NDependRecently, Patrick Smacchia dropped by and left a note showing how he used NDepend to see numerically what has changed between 3.5 and 3.5 SP! This prompted me to look a little closer at the tool. If you want to capture metrics on your .NET code, NDepend does a great job at doing it. Similar to the capabilities that TestDriven.NET gives to the lower entries in the Visual Studio product line in the arena of Unit Testing, NDepend provides code metrics for those who aren't using Team System. I would argue it goes a bit beyond the built-in Team System code metrics tools. NDepend has a query language called CQL that allows you to specify what metrics are important to you and what your alert levels are for those metrics. There is a lot to explore in this area, especially when looking at continuous integration and build verification. Before I even spend my time looking at code for a review, I can have NDepend look over the code and tell me what's missing. Once I've made the queries, NDepend will consistently catch code that breaks my rules. Giving me more time to focus on building another O/RM. August 08 VS2008/.NET Framework 3.5 SP1 Coming SoonAccording to this blurb on MSDN Subscriber Downloads the VS2008/.NET 3.5 SP1 download will be available on the 11th. Some people have noticed that SQL Server 08 installs .NET 3.5 SP1. So it's almost here. I played around with the SP1 beta and liked what I saw. So it's going to a tough weekend for me. August 07 SQL Server 08 Get It While It's HotThe final piece of the 2008 Launch, SQL Server 2008 (formerly known as Katmai), has finally gone Gold. For those with an MSDN subscription, you can download the bits now on subscriber downloads. I'm not the person to ask for a full-blown tour of Katmai, but some of the features that have had my radar pinging include:
There are a number of other new features in SQL Server 2008 and we haven't even left the realm of the database engine itself. Reporting Services (including a server that does not rely on IIS), Analysis Services, and Integration Services have all received significant upgrades. I guess this gives me a nice toy to play with while waiting for the release of .NET 3.5/VS 2008 SP1. July 25 Fixing WPF Command RoutingBill Kempf, a fellow WPF Disciple, was lamenting the fact that by default a CommandBinding can only refer to a handler defined in the code behind of the Window/Page/UserControl in which it's defined. He wished that a syntax similar to the following was possible
<Window> <Window.CommandBindings> <CommandBinding Command="foo:MyCommands.FooCommand" Executed="{Event Target={StaticResource MyPresenter}, Handler=OnFooCommand}"/> </Window.CommandBindings> </Window> I took that scenario as my starting point. The first issue I saw was that I needed a markup extension that let's you specify a Target Object and the name of a handler on that Target returning a ExecutedRoutedEventHandler. So I made one. The Markup Extension exposes two properties: Target (of type object) and Handler of Type String. The ProvideValue override (shown below) uses reflection to get a handle on the function and creates a lambda that invokes it for the result. (I love lambdas as much as I loved anon functions before them.) public override object ProvideValue(IServiceProvider serviceProvider) { ExecutedRoutedEventHandler retval=null; if (Target == null) { throw new Exception("Target cannot be Null."); } var type = Target.GetType(); var function = type.GetMethod( Handler, new[]{typeof (Object),typeof (ExecutedRoutedEventArgs)}); if (function != null) { retval = ((obj, args) => function.Invoke(Target, new[] {obj, args})); } return retval; } So I plug my new markup extension into a sample window, anticipating some good command routing lovin'. Of course it's never as easy as it looks at first. The Executed property on CommandBinding, although an event, expects a string in markup (the XAML compiler does some trickery to turn the string into an event handler). Well I know, I'll create an Attached Property to do my magic... (To be continued...) July 20 Generic Extension MethodsI've discovered that if an extension method is generic and the generic type is used as the "this" parameter, you do not have to write out the generic discriminator. The compiler is smart enough to infer it for you. For example, the range validation function I shared a few weeks ago can be called like so: int myInt=5;
myInt.ValidateRange(2,20);Jeff would be happy. July 18 Frameworks! Frameworks! Frameworks!If I haven't blogged about t before, I meant to but have been extremely busy. The first release of Prism or Composite App Guidance for WPF is available. Oh wait...I've blogged about it already (Did I mention how much I love Live Writer?). If you're looking at WPF for enterprise "Line of Business" applications, you should really look at it, not just for the framework but for the guidance assets themselves. I participated in the advisory board for the guidance and had a blast giving feedback to the PnP team and seeing that feedback integrated into the package. I even got my name on the MSDN page for the package It's the little things that make me smile :P Anyway, this post isn't about me. It's about some cool announcements coming from Microsoft. (Slow down guys or there won't be much left to announce by the time PDC arrives.) First up is the Managed Extensibility Framework or MEF for short. The short explanation for it is native Dependency Injection in the .NET Framework. There is a CTP available for it, which I'm downloading as we speak. Next on the list is the upcoming second edition of Framework Design Guidelines. The first edition is a book that I recommend that anyone doing significant .NET development have on their shelf...within easy reach. Krzysztof Cwalina, Brad Abrams, and others on the Framework team have continued to provide addenda for the book. But there has been a major release of the framework since the first edition was published, and there is enough new stuff to talk about to merit a new edition. I've already got it pre-ordered. Speaking of the MEF and the PnP team, Glenn Block recently announced his move from PM for PnP to PM on the MEF team. I can't think of a better person to provide leadership for this initiative. July 17 I'm Going to PDC
With guaranteed coverage of "Rosario", I'm pretty sure they'll be talking about .NET 4.0 (and hopefully Acropolis). The initial previews were very promising. To have it become a native part of the .NET framework is exciting. I'm also hoping to get a sneak peek at Windows 7. Server 2008 and Vista are major advances in the Windows platform. I know there is a lot of groaning about the UAC, and drivers, and blah, blah, blah. Personally I like Vista a lot (and love Server 2008 even more). I can't wait to see what's in the pipe for the next revision. I definitely want to see what's in store for Team Edition for Architects and the new TFS/Team Explorer functionality. Full UML support will be huge for me. Hierarchical work items is a plus as well. Live Mesh looks very captivating to me, and I can't wait to get my hands on some programmable bits. I'm also looking forward to meeting some of the names that I know in the .NET community. And of course watching Charles Petzold's presentation at the pre-conference. What are you excited about? July 08 Shadow Copies Saved My LifeI'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 MotherlandAs 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 WPFOr 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 BloggingYou 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 BusinessI'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 WidthLaurent 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
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 ItI 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 PropertiesFirst 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. |
|
|