Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Fear and Loathing

Gonzo blogging from the Annie Leibovitz of the software development world.

  • Keith, not Dennis

    Ritchie. It's a name in the geek world that has deep rooted meaning for those of us old enough. Dennis Ritchie, along with Brian Kernighan created the C programming language way back when.

    Anyways, long time SharePoint guy Keith Richie, not to be confused with Dennis (but it can be confusing because Keith; Kernighan; Ritchie; Richie; get it?)  announced he would be leaving Microsoft and heading over to the Mindsharp world. Wow, that group just keeps getting bigger and better with Todd, Bill, AC, and now Keith.

    Keith is the most excellent author of the SharePoint Utility Suite which I'm sure all of you use on a daily basis (I do).

    Congrats to Keith. Microsoft is losing a great resource, but there's balance in the SharePoint universe as he's still out there and will hopefully be producing great tools as usual.

    You can find his new blog here with his announcment of his old busted MS departure and new hotness MS arrival here.

  • Stats, stats, stats and more stats

    What else would you do on a blog in the new year than to post stats? Here's what this blogs 2006 roundup looked like:

    Number of posts in 2006: 262
    Number of views on all posts: 1,184,018

    Over a million views for the year. Not too shabby. 

    Note: Views are both aggregate views (RSS readers, etc.) and web page views so there might be some duplication but I'm not posting stats for correctness here, just popularity of posts.

    Top 10 Posts:

    1. Folders bad, metadata good! (24,112 views)
    2. DotNetNuke vs. SharePoint, the big showdown (20,544 views)
    3. The Big Dummies Guide to setting your SharePoint Virtual Environment (17,560 views)
    4. Tired of SharePoint Discussions? (announcement of SharePoint Forums Web Part - 11,253 views)
    5. SharePoint Forums, go get 'em (the release of the Forums Web Part - 8,751 views)
    6. 3-tier Architecture with ASP.NET 2.0 (8,509 views)
    7. Composite UI Application Block - Soup to Nuts - Getting Started (8,293 views)
    8. SharePoint Forums Web Part (8,141 views)
    9. The Lighter Side of being an Architect (8,051 views)
    10. SharePoint Forums Language Pack (7,342 views)

    While I'm not versed in the fine art of statistical analysis, it doesn't take an Acme anvil to fall on my head and show me the SharePoint Forums Web Part was quite a popular topic. Something (along with other SharePoint Web Parts) that I need to focus on early in the year to finish off the remaining work on it (that 2006 baggage I was talking about earlier).

    So not a bad year for me anyways. I'm no Oren Eini (aka Ayende, this guy is a blogging engine unto himself), Hanselman, or Osherove who post like gangbusters and every post is a gem, but I'm happy with the activity I've had and I hope you've had fun reading it all. Here's to a new year of posts that will hopefully enlighten, entertain, and enrage you to no end.

  • Anonymous delegates for event handling

    Let's start off the new year with a question. Traditionally here’s how you would code up an event handler for say a button on a Windows form (ignore the fact there are presenters and such and how they got initialized). 

       56         protected override void OnLoad(EventArgs e)

       57         {

       58             btnClose.Click += new EventHandler(btnClose_Click);

       64             _presenter.OnViewReady();

       65         }

       67         void btnClose_Click(object sender, EventArgs e)

       68         {

       69             _presenter.OnCloseView();

       70         }

    That's all well and fine. The form loads, the event handlers are registered and the view is called. There's a method for each event setup (by default in the form of ControlName_EventName) so you might have dozens of additional methods in your view code depending on how complex the form is.With .NET 2.0 we can use anonymous delegates so the code above can become this:

       56         protected override void OnLoad(EventArgs e)

       57         {

       61             btnClose.Click += delegate { _presenter.OnCloseView(); };

       64             _presenter.OnViewReady();

       65         }

    Just setup the delegate in the load method for the form. Same rules apply as in the presenter method will get called when the button is clicked.I like the second method as in it's cleaner and I don't have to clutter up my view code with lots of methods that only pass thru to a presenter. Even with dozens of events on dozens of controls I would only have one line for each in my OnLoad method. It's not just reducing the number of lines of code but readiblity that's key here.

    So any thoughts on these two approaches? Preferences? Ideas? Comments? Small unregistered marsupials?

  • First Post!

    It's officially 2007 here in Calgary so here's my first post for the year. Kind of weird as I've been thinking it was 2007 for the last few weeks but then at the end of the year it always slows down and becomes a Christmas, shopping, family, and partying focus. No partying for me this year (maybe I've been too many times around the Sun for that) and I'm starting off the year already with a backlog of things I need to get done from last year. On top of that I'm headed to the office this morning so I don't get slammed tomorrow and have everyone sitting on their hands waiting for the ScrumMaster to finish up organizing the tasks as I have 3 Scrums on the go, 2 projects that I'm serving as lead Architect, and the plethora of other tasks in my inbox.

    I'm looking at it as a challenge and something that I'm going to share with you guys every step of the way by moaning and complaining about every little thing. It'll be fun, they'll be a lot of great discoveries along the way, and there's plenty of awesome technologies, tools, and projects that are coming from yours truly so sit back, relax, and watch the screen.

    Yeah, it's going to be a busy year.

  • Rethinking your business validation rules

    Last night Tom Hollander and co. announced the release of the December CTP of Enterprise Libraries 3.0 (on CodePlex no less!). I've been watching and waiting for this (even bugging Tom to get a "sneak peek") but it's reality now and something you can play with. After all, opening Christmas presents isn't the only thing geeks do over the holidays. Don't use this for production apps, but if you've got something going into production in the next 6 months, its something to consider.

    One of the main features they wanted to deliver (based on user feedback) was a validation engine. Something that would allow you to validate business entities with little effort. Last night I gave the validators a whirl to see how they worked. It's pretty slick and ends up being a nice cleanup of your domain from clutter (which is always a good thing).

    Let's say I have an Account class and the name of the account has some rules around it. Names are required and can only be between 5 and 8 characters. This is a simple example, but one you should get the idea from.

    First I'll write a set of quick tests for my Account class. Four tests, one creates a valid Account, two test the length bounds, and one creates an Account with a null name.

        6 [TestClass]

        7 public class AccountTests

        8 {

        9     private Account _account;

       10 

       11     [TestInitialize]

       12     public void SetUp()

       13     {

       14         _account = new Account();   

       15     }

       16 

       17     [TestMethod]

       18     public void CanCreateValidAccountWithName()

       19     {

       20         _account.AccountName = "C123456";

       21         Assert.AreEqual(true, _account.IsValid);

       22     }

       23 

       24     [TestMethod]

       25     public void AccountNameMustCannotBeLessThanFiveCharacters()

       26     {

       27         _account.AccountName = "A";

       28         Assert.AreEqual(false, _account.IsValid);

       29     }

       30 

       31     [TestMethod]

       32     public void AccountNameCannotExceedEightCharacters()

       33     {

       34         _account.AccountName = "123456789";

       35         Assert.AreEqual(false, _account.IsValid);

       36     }

       37 

       38     [TestMethod]

       39     public void AccountNameIsRequired()

       40     {

       41         Account account = new Account();

       42         account.AccountName = null;

       43         Assert.AreEqual(false, account.IsValid);

       44     }

       45 }

    Now we'll create the Account class in a more "traditional" sense, checking for business rules validation during the setter and setting a flag called IsValid along the way.

        3 public class Account

        4 {

        5     private string _accountName;

        6     private bool _isValid;

        7 

        8     public string AccountName

        9     {

       10         set

       11         {

       12             if(string.IsNullOrEmpty(value))

       13                 _isValid = false;

       14             else if(value.Length < 5)

       15                 _isValid = false;

       16             else if(value.Length > 8)

       17                 _isValid = false;

       18             else

       19             {

       20                 _accountName = value;

       21                 _isValid = true;

       22             }

       23         }

       24         get { return _accountName; }

       25     }

       26 

       27     public bool IsValid

       28     {

       29         get

       30         {

       31             return _isValid;

       32         }

       33     }

       34 }

    Great, our tests pass and all is good in the world. However our setter looks kind of ugly and could be improved. Maybe we could create some private methods called from our setter, or you could throw a BusinessRulesException but it's still ugly no matter how you refactor this.

    Enter the new hotness of the Validation Application Block of Enterprise Library 3.0. Rather than writing all those "if" statements and conditional checking, we can specify our validation through attributes decorated on the property. And our IsValid property can be changed to use the new ValidationFactory classes:

        6 public class Account

        7 {

        8     private string _accountName;

        9 

       10     [NullValidator]

       11     [StringLengthValidator(5, 8)]

       12     public string AccountName

       13     {

       14         set { _accountName = value; }

       15         get { return _accountName; }

       16     }

       17 

       18     public bool IsValid

       19     {

       20         get

       21         {

       22             IValidator<Account> validator = ValidationFactory.CreateValidator<Account>();

       23             ValidationResults results = validator.Validate(this);

       24             return results.IsValid;

       25         }

       26     }

       27 }

    Makes for reading your domain code much easier and it's a breeze to write. Also (at least IMHO) it makes for reading the intent of the business rules much easier. You can also create your own validators and there are a set of built-in ones in the December CTP drop (String Length, String Range, Date Range, Valid Number, etc. more coming later) so there's much more to it than this simple example but I find it all very slick and easy to use.

  • Ribbon UI Control Roundup for Developers

    After yesterdays post about my babbling about the Ribbon UI and Office 2007, I decided to go out and hunt down all the libraries and controls I could find that provide that UI experience for you, the developer. I've taken out a few hours, downloaded all the samples and demos I could and gave everything a test drive. For the demos and criteria (I'm very picky about having to do silly things like RTFM) I looked at how easy it was to add the control and apply the look and feel of Office 2007 to a simple Windows Form. Was there a designer? Documentation? Demos? How much code did I have to write? Any extra stuff that came easy or for free (like built-in icons, reading in menu structure from XML, etc.) added some brownie points, but not much as the focus was just getting an Office 2007 look and feel.

    For my trial samplings, I went completely commando and took a solution, added a WinForm project for each control, and went to town. If there wasn't anything obvious about how to add controls or get the Ribbon going, I would crack open the demo and, barring that, resort to actually reading something. I also had Word up and running and built a small sample with each library to mimic the Word UI by creating a tab for each section (Home, Insert, Page Layout, References, Mailings, Review, and View), groups for the first tab (Clipboard, Font, Paragraph, Styles, Editing) and button/menus for the first group (Paste, Cut, Copy, Format Painter). Building each demo should only take 10 minutes (no graphics, just setting properties and adding controls).

    Here's a rundown of the toolkits available out there.

    Elegant Ribbon

    A good looking control, implements all the requirements for the Ribbon and is 100% managed C# code. Install was simple and it came with a toolbox entry with some controls you can drop onto your forms. Very simple and intuitive. You could probably get up to speed on this very easily and it appears to implement all the features the real Ribbon does. Demo was quick to build and I didn't have to refer to the help or samples. You can add tabs and groups from the built-in context menu so it's pretty intuitive. Adding the Ribbon to the form also added their own FormFrameSkinner so the entire form took shape with the Office 2007 UI look and feel automatically. Very nice. Beta version only right now.

    SandRibbon

    A nice control and one of the more lightweight but compatible and powerful ones out there. Install couldn't add controls to Visual Studio (but Elegant Ribbon could?) so you have to add them manually. Once you do this you can add a Ribbon to the form. This was fine and I could right-click on a group (they call it a "Chunk") and add controls or new chunks. Overall not bad, but it didn't create the Jewel which Elegant did. If I did some more digging I could probably find out how to do this but it didn't look obvious to the controls that I could add or properties I could set. The only problem I saw was when I reloaded my sample, it couldn't figure out how to build the designer and crashed not understanding a variable called "ChunkStrip". Creating a new form and adding the Ribbon didn't have any problems. Commercial and available for purchase. Eval version is available.

    TAdvToolBar

    Nice implementation. Only for Delphi and C++ Builder. Since I don't have either installed, I couldn't try it out the library but the demo looked like it could do the job and I gave a quick once-over on the SDK documentation and it looks pretty simple.

    XtraBars Suite

    Part of the big gigantic entity known as DevExpress. I do have XtraBars (or DevExpress or something) laying around here but I haven't installed it. If it's anything like the XtraGrid then this is probably the cadillac of Ribbon controls but it comes at a price. I've been working with the XtraGrid for months and I still don't know how to do much with it other than replace a DataGrid. There are just a billion options, designers, editors, skins, themes, and all that so I'm sure that's been packaged into the XtraBars as well. I did run the demo and it looks good so if you're serious about building apps using the Office UI and have lots of time to kill learning something, this would be your best bet.

    BCG Control Bar Pro

    I've used BCG before and their suite is nice. It's all written in C++ but I'm not sure if they've moved over to the managed world yet for this control. They have a (ugh) MFC demo version that looked and behaved well exceptionally well. The thing I've always found about BCG is that their demos are not only the look and feel of the app, but some functionality. For example their Ribbon demo is Word and comes with all the icons, buttons, and graphics as the real deal but also when you click on things like the File Open button or Save toolbar, it brings up a dialog. It's a nice touch that they take more time than just building a Hello World sample but an actual demo (even if it is a shell). As for the library itself, after installing this library there were no Ribbon controls avaialble so I'm assuming they haven't released that part yet but only the demo.

    Janus UI Controls

    These guys claim to have a Ribbon component, but unless I'm missing something obvious, I can't find it on the site.

    DevComponents Ribbon Control

    Simple install and worked first time. Added it's own toolbox with a variety of controls (including a bunch that were not Ribbon related but things like Visual Studio 2005 style tabs, nice). Dropped a Ribbon control on a new form and then added some additional controls. Not completely intuitive about adding groups. The other controls like Elegant and SandRibbon would add tab groups, here you drag the group onto the tab which means you have to dock it and do some alignment (or maybe there's some container control you have to add first). No Jewel added automatically and I didn't see a control for it, so not sure if that's supported. Lots of really annoying nag screens everytime you add a control to your form so negative points for that.

    Toolkit Pro 2006

    This is from the CodeJock guys and they usually produce good stuff. The library is listed as C++/MFC (like BCG Control Bar) so it's MFC only and not a WYSIWYG type environment. Like BCG, you have to build a MFC app (using the template they provide or modifying your own MFC app) and hook in the Ribbon through resource files and source code. Sorry but I stopped doing that development years ago when C# let me focus on my domain rather than writing code to wire up UI events (and MFC is bloatware to begin with). Anyways, again the demos look good but if you're not familiar with MFC or C++, be afraid, be very afraid. If you do like to hurt yourself, this toolkit or the BCG one (if I could find the Ribbon functionality) are fine.

    Bottom line

    If you're serious about the Office UI and want power (as in BullDog hover-board power) then check out DevExpress. I don't think you'll be disappointed. If you're building a small app or something freeware, give Elegant UI a whirl. Even as a beta, it's quite good, easy to use, and looks just as powerful as most of the other offerings. Best of all, it's the quickest to get up and running with a Ribbon from the libraries I tried out. Most of the other ones, if you gave it an hour with any one of them, you would probably "discover" all the ways to manipulate the Ribbon (except DevExpress which would probably require a week). I'm impatient so only gave it the 10-minute litmus test but if I had to make a corporate decision rather than personal one, I would probably spend a day with a few of my favorites.

    Please feel free to add any I've missed.

  • Being a responsible open source developer

    First off, let's start this post by saying I think there are a few key points in computer history where things turned. The introduction of the GUI (even though both Apple and Microsoft just build on what Xerox did); the Internet; Object Oriented Languages; Microsoft Bob. Well, maybe not the last one but the others are valid and there are lots of others gems out there.

    I've been following the Office 2007 UI for quite some time, ever since I got my hands on early dog food alphas from the Office team. While some might not call it innovation, it just makes sense to me and I think it's a well designed and thought out piece of work. Yes, there are those that are not going to get it and require gobs of training and scream and kick and moan and want their beloved File menu and toolbar back. There is the other group where we embrace it and actually like it. I'll be the first to bitch and complain when I'm building presentations where the freakin' buttons are as I'm still getting used to it, but in the end that's it. I'll get used to it, just give it time. I like the look and think it's a good way to go and frankly, Microsoft made that decision long ago and like or not, we have to adapt and live with it (or not, but that's a different blog post).

    Skip ahead a few hundred blog posts and I came across Jensen Harris' entry about licensing the Office 2007 UI. Yes, a 120+ document about how to build the UI is a bit much and frankly I want to see component developers build controls that help me adhere to that standard. As an application developer, I really don't want to build an Office 2007 UI any more than I want to build my own implementation of the Windows Menu System or Toolbar. After all, that's what component developers do and that's why we buy their stuff. So awesome move on Microsoft's part to publish this, make it royalty free for those that want to build stuff. There is a lot of controversy over Jensen's blog post though, as people are questioning what exactly Microsoft is licensing (a concept? that didn't work for the recycle bin did it now) with some people calling Microsoft arrogant and others say they're brilliant. It'll be interesting how that conversation shapes out (and the comments on the post are quite in-depth, I expect this to hit Slashdot any minute now if it hasn't already).

    The licensing does bring up a bit of a pickle. The royalty-free license is restricted to products that directly compete with Word, Excel, Powerpoint, etc. So what does a product like Open Office, that cannot obtain the royalty-free license? And more importantly what if they purchase a copy of an Office 2007 UI component, say from Infragistics, and use it in the product? Is that a violation of the license or not. Licensing is always messy so I'll leave that to those guys to figure out.

    Anyways, back to some of the converging elements of what brings me to write this post.

    A long time ago on a computer far, far, away I gave RSS Bandit a try for reading my RSS feeds. It was a nice product and worked well but after some time, I abandoned RSS Bandit. It was a huge memory hog (which may be fixed these days) but more importantly, the developer kept revamping the UI by using free copies of commercial UI libraries. Three times he flipped out the UI and I thought (as did others) that getting burnt 3 times would be enough and you would stick to something free, open source, or native. Sorry, but if you're providing a free, open source tool, you can't force your users to be bound to a commercial library.

    As I understand it (and this view may be flawed) Dare Obasanjo, the author of RSS Bandit, received a free copy of the UI component for use in the project. Not unheard of on an open source project. Vendors see it as free advertising and it is. However doing this is tying the open source communities hands. We don't have a free copy of the software like Dare does and even if we did (if the UI component was say licensed for RSS Bandit) having the title heavily dependent on a tool that may or may not be there in the future isn't the open source thinking mentality. Imagine if DasBlog built it's foundation on some proprietary messaging system or database you had to buy in order to make modifications for? Where would it be today? Anyways, Dare and his recent post about what he was proposing for the next RSS UI is something that caught the attention of Mike Dimmick. His comment was what Mike called a misuse of the Ribbon concept, and I agree. I looked at the screenshots Dare posted and while they are prototype, they're far from what I think the Office UI is but rather a rather poor emulation of them. In addition, as some of the comments on Dares blog show, RSS Bandit might not be an appropriate application for the Ribbon concept.

    It is confusing as Dare posts later that Microsoft is releasing several new applications this year, all with varying user interface concepts. IE7, Office 2007, Windows Media Player 11. All from Microsoft, all with different interfaces. Even in the Office space, Word; Excel; and Powerpoint; share the Ribbon but other tools like Publisher, InfoPath, or SharePoint Designer do not. What gives? I think Jensen answered this as those products were not the "core" Office products so would not use the concept of the Ribbon. In any case, how do you go from one interface (File Menu, toolbars) to something like the choices we have now? Not an easy switch. If we as developers think the users are going to push back on Office 2007, then we'll be staying far away from that UI as much as we can if we want to keep our users happy. I don't believe in the concept that just because there's new hotness out there, that we should all flock to it, no matter how cool it may be.

    As application developers, we make choices. Sometimes bright, sometimes not so bright. However if we consider ourselves professional, we have a commitment to that professionalism and that's one of providing our customers (yes, even free open source weekend projects have customers) a product worth of its download. If we're dependent on a library or another tool, make sure that you have some plan to abstract yourself away from change. Sure, maybe the cool 2007 UI is the new hotness today but we as developers can, with a bit of forethought, build systems where the UI is swappable or at least "easier" to replace (I've done it many times). Patterns like Model-View-Presenter help with this and think about you can shift gears should you need or want to. What's cool today is cold tomorrow and painting yourself in a corner isn't going to win you any prizes.

    I for one welcome our Microsoft UI overlords and will be looking to incorporate the Ribbon concept in WinForm apps I build where appropriate, hopefully with the help of some free libraries out there but if not, and where I can, I'll use what commercial tools there are to present what I think will be a better user experience for you. I hope other open source and free tool developers out there follow suit.

  • It's not me, its you

    Yes, you as in you and not me. It's you, kind and gentle reader, that's been named Times person of the year. Every year around this time, Time magazine picks out some influential person or persons to be the "Person of the Year". Someone (or something) that has made a difference.

    This year brings about the community thinking so Time copped out and picked "You" as the person of the year. "You" being a collective term that refers to basically anyone with a computer and an Internet connection. Someone who visits sites, reads blogs, uploads videos to YouTube, crushes Elves by bashing their skulls in an online game, and generally carries on like we all do in our online world of knowledge, sharing, and camaraderie.

    Congrats to everyone reading this blog because you're You (according to Time magazine). You are now in the hallowed halls of such dignitaries as Adolf Hitler and the Ayatollah Khomeini. Amazing what happens to you on a Sunday afternoon reading some geeks blog huh?

  • The install that lasted a lifetime

    I don't know what the softies are smoking these days, but the guys (or gals) that put together the service packs need some serious optimization lessons. I downloaded Visual Studio Service Pack 1 yesterday, all 400+ megabytes of it. Sure, it says it fixes over 2200 problems so it has to be big right? Then came the install which involved the proverbial double-clicking on the file and the subsequent waiting. And waiting. And waiting. And waiting.

    Okay, I'm not running the WOPR here but it's a fairly good system. 2Ghz Core 2 Duo processor, 2GB RAM, etc. so I expect at least a little skip to my step. No so when running this crazy installer. First it had to "optimize" and "configure" my install experience, which took about 15 minutes. Then it had to install the actual update. All the time there was little disk activity, the biggest bottleneck on any system, so it's anyones guess what the system is doing.

    Finally after it ran through multiple "configurations" and updated my install of Team Suite, it was done. 1 1/2 hours later. That's just plain insane for a service pack. Even SP2 for Windows XP installed quicker than that. The Visual Studio guys (and Microsoft in general) need to take some lessons from iterative development and release little patches along the way. This big bang approach really sucks as I dread the day I have repave my machine and install VS2005 again.

    A couple of tips to try to keep the time down (as I've heard some people taking upwards of 3 hours for the process). Turn off everything, and I do mean "everything". If you're running a local SQL server shut down those services. Turn off any utilities that's frivolous like FolderShare and whatnot as you won't need them during the update. Shutdown messenger and kill off any extras you have running in your system tray. Also I recommend just running the service pack and nothing else. Don't try to read email or blogs during the update and maybe it'll go a little quicker for you.

  • SharePoint Security Webcast followup

    Thanks to everyone who turned out for the security webcast today on SharePoint. We had about 60-70 people on the webcast and I had a fun time giving it. A large part of the webcast was around the plugin authentication framework and leveraging the ASP.NET membership providers for using forms based authentication with SharePoint 2007. Unfortunately I didn't get to all the slides (40+ slides in 60 minutes) so if there's anything you're looking for more clarification or depth on, just yell.

    As a followup, here's the additional resource links I mentioned during the webcast or will be useful for you with regards to security and SharePoint:

    The webcast recording should be online in 24-48 hours so I'll post the link once it's available.

    And as I mentioned feel fee to bug me via email if you have any specific questions or scenarios you're trying to figure out. I have a few emails already from the webcast today that I'm following up on so watch for some replies to those and possibly some additional fallout blog postings that I'll share.

    kick it on SharePointKicks.com