Developing For .NET

Real World .NET Methods, Tricks, and Examples

Archive for July, 2009

Rants and Raves #5

Back in form this week with both Rants and Raves…

Rants

CodeRush

I wrote last week about how much I love ReSharper and what a benefit it has been.  I also said that I was installing DevExpress’s CodeRush and would report back.  Unfortunately, my report is not good.

My biggest beef is that I just plain didn’t like it.  I especially disliked how it had a tendency to prevent IntelliSense from doing what I wanted.  In particular, it removed my ability to hit Tab to insert the highlighted element.  And when I tried to hit Enter, it inserted non-selected text.  I just couldn’t intuitively get the hang of it.

In fact, I had installed the entire DevExpress DXperience suite of products.  If you think loading the ToolBox in Visual Studio is bad natively, try doing it with a ton of third party controls along for the ride.  And it seemed my overall VS experience was significantly slowed down.  That plus my dislike of CodeRush meant it was actually more of a hindrance than a help, so I uninstalled it.

Enter my next issue.  When I went to uninstall it, the DevExpress software was listed in my programs as three separate products.  This was fine, because I really only wanted to uninstall CodeRush at the time because I hadn’t had a chance to try out any of the WPF Controls.  When I uninstalled the CodeRush part, it uninstalled the entire DXperience family of apps.  Uninstall Fail.  I have not reinstalled any of the software, and I don’t know if I will.

I only tried it for a few days.  I’m sure an experienced user may know how to work around my issues, most likely via configuration.  Perhaps I’ve been spoiled by ReSharper, but for productivity tools, I don’t think I should have to make a lot of effort to be productive.  Maybe I’m being unfair, but this is a Rant so I’m entitled.

Ravesoptical communications

Windows Live Writer

If you blog and are still using your blog software editor to add and edit posts, please hold your hand in your front of your face, palm facing you, and slap yourself in the forehead.  That’s what I did once I finally used Windows Live Writer: it is definitely a “coulda had a V8” moment (or a Homeresque “D’Oh!”).

Live Writer is an excellent desktop application that allows you to write posts and pages and submit them to your blog.  The great thing about it is that it downloads your theme and executes it in the editor so you can actually see what your post will look like once published.  There is also a full preview tab so you can view the entire page, and of course you can modify the HTML directly.

Live Writer stores drafts and posts locally, so you can also work on them whether or not you are connected to the Internet.  It also supports plug-ins such as Twitter Notify, which will automatically send a tweet when you publish something new.

Naturally, the editor is complete with all the WYSIWYG goodies, text editing tools, hyperlink and image inserters, spell checker and more.  And you can connect to multiple blogs.  This one is going in my list of “can’t do without” software.

2 comments

Site Updates and Issues

Howdy Reader,

I have made a few updates to the site.  Nothing big, but I wanted to go ahead and log them as a point of reference.

Issues

I’ve been having an issue recently with my MySQL server. It appears that on occasion it will shut down access because of too many failed login attempts.  Of course, it makes me wonder who or what is causing the problem, but for now I just have to catch it and clear the hosts file to reset it. 

Unfortunately, when it is happening the site is completely unavailable.  If you see the site having trouble in the future, like a database connection isn’t working, please DM or @ me on Twitter and I’ll fix it.

I’ve also been having some connection issues with Akismet. The plug-in is reporting that 2 of the servers will connect but 2 others won’t.  See updates below for more…

Updates

I updated today to WordPress 2.8.2.  The update seemed to hang for a log time on a blank screen, something that has not been an issue in previous updates.  I was getting nervous for a while but it finally flashed up and appears to have completed normally.

I found the WP-SpamFree plugin, which promises to eliminate Comment Spam.  Akismet has been doing fine, but I still have to moderate a few everyday.  We’ll see if this new plug-in fares any better.

On the same note, the plug-in also includes a spam free Contact page.  I’ve enabled it, so if you wish to send contact me through the site, go to the Contact Me page (listed on the right under ‘Pages’).

No comments

Rants and Raves #4

It is very difficult for me to come to terms with this, but I have nothing to Rant about.  I don’t know, maybe I’m sick or something, but nothing has really gotten under my skin this week.  Don’t worry, I’m sure I’ll be feeling better next time.  For now, I hope you enjoy this Rant-free entry.

Raves

More Pomodoro: GMail Tasks and an online Timer

I raved last week about Pomodoro, and I’m still raving.  This is quickly becoming a mainstay of my development, and so far with great results.  This week’s rave is about some of the tools I’m using to help me along.

I’m not sure when it happened, but sometime recently a new item showed up in my GMail: “Tasks”.  Now, obviously the idea of a task list is hardly revolutionary, but given my recent adventures with Pomodoro it was a very well timed discovery.

A Pomodoro purist would insist on Pencil and Paper to manage one’s daily tasks, but my desk has a tendency to get piled up with papers, among other things, and I’ve learned to essentially ignore the mess until I have no choice.  All arguments for a clean desk aside, this means that any system relying on me to regularly update anything on paper is destined for failure.

While I plan to tackle this shortcoming eventually, for now the GMail Task pane is my answer.  I can undock it and run it standalone, so I have it separated from my browser: this allows me to see it constantly.  For simple things like a daily task list, the service couldn’t be any easier, just add a task and check it off when complete.

The service supports more features, such as setting due dates and annotations.  For now, I plan to add a lot of specific tasks to my list: this seems best in keeping with the Pomodoro spirit.

My official Tomato Timer is on order ($5.99 + free shipping!), but thanks to reader Stephen Wrighton I have been using e.ggtimer.com/25minutes with some success.  It is a simple site that counts down from the number of minutes in the URL (you can change it as needed).  There is an audible beep when the timer is complete, and a popup message.  I have missed it a couple of times while busy with other tasks, but for the most part it has served me well.  Best of all it is free and easy to use: I just hit ‘Refresh’ at the beginning of each new Pomodoro.

I mentioned Pomodoro in our weekly Scrum (a topic for another time) and everyone thought it was cute – until I showed them what I was able to accomplish last week because of it.  My productivity is currently off the charts, so far a good justification for continuing the experiment.

ReSharper

I’ve certainly heard of productivity tools like ReSharper, but I’ve never really understood what the big deal was, until a couple of things happened recently to make me want to give it a go.  First, at the Charlottesville .NET User Group, Justin Etheredge gave a presentation and I got to see it in action for the first time.  I was very impressed by what I saw.  Then at CodeStock, Mike Wood had a great Open Spaces session, and one of the things said was that if you weren’t using a tool like this then you were shooting yourself in the foot.

Well, I certainly don’t want my foot shot, so I installed ReSharper and immediately began reaping the benefits.  I expected some kind of learning curve, but honestly it is all so intuitive that it just sort of happens.  My favorite feature so far is where you can begin to define a class and it will move the new class to a new file for you.  It’s small things like that, a whole slew of them, that make all the difference.  Above all else, this software helps keep my hands on the keyboard.

Coincidentally, I won a copy of DevExpress DXperience Enterprise, which includes a productivity tool called CodeRush.  I just installed it and will be experimenting with it in the near future, so more to come on that.

1 comment

‘Brush’ type does not have a public TypeConverter class.

I’ve been a big fan of Value Converters in WPF for some time now, but I was bitten today by something simple and thought it would be worth sharing.

Brush Converter

One of my favorite uses for Value Converters is to set colors of things based on object state.  In my current application, I have drawn a circle that I want to be filled in Red if the application is not connected to the database, and green if it is connected.  My binding engine has an “IsDatabaseConnected” boolean property that I can use for the binding, so what I need to do is bind the bool to a Brush. To do this, we create a simple converter:

using System.Windows.Data;
using System.Drawing;

namespace CamraSketchViewerWPF
{
    public class DatabaseConnectedColorConverter : IValueConverter
    {
        public Brush ConnectedBrush { get; set; }
        public Brush NotConnectedBrush { get; set; }

        #region IValueConverter Members

        public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is bool)
            {
                var isConnected = (bool) value;
                return isConnected ? ConnectedBrush : NotConnectedBrush;
            }

            return null;
        }

        public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new System.NotImplementedException();
        }

        #endregion
    }
}

In the XAML we need an instance of the Converter to bind to: I used Blend 3 to write the XAML, but whether you do it this way or write it by hand you should end up with something like this:

<local:DatabaseConnectedColorConverter x:Key="DatabaseConnectedColorConverter" />
 
 

This will create an instance of the Converter as a resource that can then be used for the actual binding:

<Ellipse Fill="{Binding IsDatabaseConnected, Converter={StaticResource DatabaseConnectedColorConverter}, Mode=Default}" Width="15" Height="15"/>
 
 

If you run the code like so, you will get a transparent circle.  What’s missing are the property value declarations for the Converter. In addition to declaring the instance in XAML, we can also set its properties in XAML like so:

<local:DatabaseConnectedColorConverter x:Key="DatabaseConnectedColorConverter" ConnectedBrush="{StaticResource GreenBrush}" NotConnectedBrush="Red" />
 
 

Note that for ConnectedBrush I have defined my own version of Green as a resource. Now, if you run this code, you’ll receive the same exception that bit me:

‘Brush’ type does not have a public TypeConverter class.

It’s always the simplest things…

I have run into this message and others like it, and it is always frustrating.  What it means is that the Type I am trying to descibe in XAML does not have TypeConverter behavior defined: this is what allows simple Strings in XAML to be properly transcribed into correct types at runtime.

In this case, the problem was a simple one but not an evident one.  Now I love code completion and refactoring tools as much as the next guy, so whenever Intellisense volunteers to help me out I am quick to accept the assistance.  In this case, however, it did more harm than good!

When I referenced the Brush in my Value Converter class code, I was prompted by Intellisense to resolve the missing namespace, which I did with the handy-dandy Shift-Alt-F10 keystoke.  Only I did it reflexively and did not actually read my options.  If you look at the code above, you will see that the Value Converter class is referencing the System.Drawing namespace instead of the System.Windows.Media namespace.  System.Drawing.Brush was not written for WPF and so does not have the TypeConverter code necessary for this to work.  The problem is easily corrected by changing the namespace appropriately.

Conclusion

I placed this in the “Read your options” file for future use. If you are interested in more TypeConverter details, check out this article by Rob Relyea at XAMLfied.

4 comments

Rants and Raves #3

Rants

Microsoft Certification Exam

I ranted in the last Rants and Raves about the Microsoft Certification exam, specifically about the format.  Well, this week I feel no better: I decided that since I was so close last time that I would push ahead and quickly retake the exam, so I scheduled the exam for 9 days after the initial fail.  After lots of studying, cramming, and practice tests, I was able to pass.  All the prep work is what really delivered in the end, and it was a good thing I had invested the time: this test was far more difficult than my first attempt.  It was an agonizing process.

My Rant is the same as last week: I just can’t believe the amount of memorization expected.  The exam does little to truly test your knowledge of .Net concepts: instead, it focuses on specific method signatures and return values.  But, I don’t want to just Rant and run, so I have a suggestion.

As this is an exam for coders, how about letting us code?  Split the exam into two parts: part 1 would be questions regarding general .Net concepts.  Part 2 would be a practical hands-on.  Develop the exam software to utilize or emulate Visual Studio.  Then have tasks to complete, where we write code to solve a particular problem.  The kicker is they could write Unit Tests to evaluate our “answers”.  Who cares about the specific implementation details?  If the Unit Test succeeds, you get credit for your solution.

I’m sure there are plenty of holes in this idea, and by all means I encourage you to point them out, but I’ve really been annoyed by this and would welcome almost any change.  I hope it’s not as bad when I go to take my next exam, 70-502 “Microsoft .NET Framework 3.5: Windows Presentation Foundation Applciation Development”.

Raves

Pomodoro

Pomodoro, short for The Pomodoro Technique, is a time-management method that has been picking up steam lately with the developer crowd.  I first heard of this a couple weeks ago at CodeStock 2009.  I initially dismissed it as gimicky, but out of curiosity I read up on it some more.  I was intrigued, so over the last week I’ve been testing the waters, and I must tell you: I’m officially hooked.

It’s an easy read, and the technique is very simple.  In a nutshell, you break all your work time into 25 minute increments, each followed by a 5 minute break.  This is called a “Pomodoro” (Italian for Tomato.)  After 4 consecutive Pomodoros you take an extended break.  At the beginning of the day you write down your priorities and tasks, and at the beginning of each Pomodoro you write down what you are going to work on.  Then, at the end of the Pomodoro you update your status on that task.

The most important rule is you never violate the Pomodoro.  Focus and work intensely on your task for those 25 minutes: not a minute more nor a minute less.  To keep you on track, you use a kitchen timer or other device.  When the bell goes off, no matter where you are in your task, you stop.

There is more, in fact there is a 40+ page PDF book on implementing the technique that answers all those questions I can hear you asking, like “what about interruptions”, “what about emergencies”, “what if I finish my task in ten minutes”, and so on.  Essentially, the whole thing comes down to prioritizing your work and focusing.

The results for me have been excellent.  I used the technique to carve out blocks of study time for my exam, time for practice tests, and managed to write a new application in only a few days. By focusing on one thing, intently, I’ve been surprised at how much I can get done in a short while.

I haven’t tried using an actual timer yet, but I soon will.  I find it too distracting to constantly check the time, and I frequently work too long when I don’t pay enough attention.  I’ll be working on perfecting my technique in the weeks to come.  Of course, managing distractions is another key, so things like Twitter are suffering, but I’ve been so productive that I can deal with that.

Silverlight 3 and Expression 3

This probably isn’t news, but today marks the official launch of Silverlight 3 and Expression Studio 3.  I’ve been using the Mix09 Preview of Blend 3 for a while now and I’m very happy with it.  I haven’t gotten my hands on SketchFlow yet, but I’ve seen it and I’m anxious to give it a whirl.  I’m downloading the RC with SketchFlow as I write this, so you can expect I’ll be writing about it soon.

Silverlight 3 is a superb upgrade to Silverlight 2 with tons of new features.  For the best news available, be sure to read Scott Guthrie’s announcement.

4 comments

Next Page »