Archive for February, 2009

Trailhead Estimate v0.2 Available

Friday, February 27th, 2009

The title pretty much says it all.? Head over to the download page and check it out.

This is an alpha version, about all I can say is it does work on my computer.? This was my initial interface prototype and now that I have a decent idea of how I want to improve it, I plan on throwing out most of the GUI code.

The first improvement is to make the task decomposition behave like the Outline mode in Word.? Essentially you would type the name of the task, hit enter, and it would create another task below it.? You could then use TAB/SHIFT-TAB to indent/outdent the task into a parent or child.? I also want to make the estimate time spans take actual times like “1 hour”, instead of the specific Timespan format.? Those 2 changes should make the interface much easier to use, and of course I also still have to implement alternatives, and I have been asked to add a few other features here and there (pretty exporting and actual time tracking being the 2 big ones).

All in all, still a lot of work to do, but it is nice to have something I can use in the meantime.

Download Tracker v1.0

Thursday, February 26th, 2009

I’ve been meaning to learn how to write extensions and widgets for BlogEngine.Net for a while now.? I’ve been using this website as an excuse to play around with web-development, which is part of the reason why

  1. The site is often broken.
  2. The site is often changed for no apparent reason.

In this case, the widget and extension I wrote covers functionality already built elsewhere, but let’s face it, what’s the fun in using their code?? Besides, implementing this gave me a chance to look at how other folks wrote their extension, and served as a good learning experience.

Essentially there are 3 parts to this widget/extension.? The first part is the extension.? This is required in order for the widget to work, and tracks the number of times a file is served via the FileHandler service.? It uses the settings provider and saves a count of the number of times the file was served.? No information about who, what, why, where the person came from is recorded, because frankly I don’t really care.? All I am really interested in is which files are popular and which aren’t.? The second part is the DownloadList control.? This simply renders an unordered list of the files and their download counts.? This control can be used anywhere if you have a pressing desire to do so.? The final part is the widget “Download Tracker”.? This hosts the DownloadList control as a widget.? The widget is only displayed to authenticated users.?

Eventually, I might throw together a “most-popular” widget that would display the top five most popular downloads or something like that, but for now I just wanted a way to count the number of times a file is downloaded.

I have 2 other widgets/extensions I plan to implement (in addition to my Trailhead Estimate development).? The first is an AddToAny widget to add the control and customize it.? The second is a “most-popular post” type widget, to help direct visitors to the posts most enjoyed by everyone else.

As always, visit the Download Page to grab the extension/widget.? It is organized according to the directory structure the files should be placed in:

  • The “Download Tracker” folder and its contents should be saved to the “widget” directory.
  • The “DownloadTracker.cs” file should be saved in “App_Code\Extensions”.
  • The “DownloadList.cs” file should be saved in “App_Code\Controls”.

That is all you need to do to install it.? From there, you should see “DownloadTracker” in the extensions, just enable that and add the “Download Tracker” widget to the widget collection and you are done.

Picking a Name and Creating an Icon.

Monday, February 23rd, 2009

Despite the many distractions along the way, I have finally put together a working version of my task estimation tool.? As is usually the case, the actual development was the easy part, the hard part was picking the name.? Since I am going to put out for download, I figured that “Task Estimation Tool” probably wasn't the catchiest name possible, so I changed it.

Of course, coming up with a decent name is always problematic for me, so I did what I always do when I have these types of problems.? I ask for help.? In this case I sent around a copy of the software to some folks I know and asked for help on a name.? After a large amount of amusing and ultimately not helpful suggestions (I'm looking at you “approxsoftimator”…), we basically decided on “Trailhead Estimate”.? While at first I wasn't crazy about it, it has grown on me, and having a decent name certainly helps move things along to the point where I can release it out for download, which is my ultimate goal (I've already started using it for my own needs).

Of course, having a name also means that its time to create an icon.? Being the software type, I don't usually have much need for the various graphic design packages that are available – most of them are overkill for the once-a-year type use I would put them through.? Traditionally, I have used a drawing program to create the icons.? I just started using Paint.Net – I'm not sold on the design, but it seems solid and is free.? I also have an old copy of Paintshop Pro from when it was awesome, that I like to use whenever possible.? Once I had the basic icon design, I would copy it over to Visual Studio's Icon Editor and tweak it to make it look right.? Unfortunately, it never looked right (mostly because of my own ineptitude).

This time around, I decided to see if there were any tools out there that could help ease the creation of the icons.? There seemed to be several to choose from, but they all wanted payment, which, as I mentioned, didn't seem like a good deal for the amount of use that I would put them through.? Fortunately though, I ran across this little gem.? Not only is this version free for users of VS2008 (which I am), but it is also the basic version of the package that I had ultimately decided on, but couldn't justify for a one-time need.

Hopefully, this tool should help me create some icons that don't look completely awful.? I have just begun playing with it, and I can tell you that it is definitely better than the original Visual Studio Icon editor, but I haven't quite decided if it beats my old method of using a regular drawing program and copying it over.? I'll let you know how it turns out.

Custom Event Best Practices, and Why I am Ignoring Them

Thursday, February 19th, 2009

I’m a firm believer in best practices.? They provide invaluable guidance about solutions that have worked and failed in the past.? Following them provides other developers an easy cue to understanding your code.? Whenever I see code that ignores these best-practices, I tend to treat it with more suspicion than I would code that follows the established practices.? This is why I decided that I should probably talk about a “best practice” that I do not like, and have after following it for a long time, have decided to forego for my latest project.

According to Microsoft, when creating a delegate for an event, they advise you to follow the same EventHandler pattern the .NET framework uses.? This pattern required you to create an event delegate with a return type of void and two parameters – a “sender” parameter of type Object, and an “e” parameter which should either be of type “EventArgs” or derived from it.? I have even propagated this pattern when I talked about the potential for a .NET memory leak based on the way the framework handles event subscriptions.

So what exactly is my problem with this pattern?? It has worked well for so long, it seems kind of silly to revisit it now, but to be honest it suffers from one major flaw in my opinion.? Essentially I do not believe that the “sender” parameter should be of type object.? I believe that it should in fact be strongly-typed, just as you would strongly-type any other parameter in your application.

After working in C# for a long time, I have encountered 2 methods of dealing with the “sender” parameter in events.?

The first method is to ignore it.? When a developer creates a custom event, he or she includes all the needed information, including the strongly typed instance of the event sender, in the derived EventArgs class.? In the handlers, the developers simply ignore the sender as if it was not a useful piece of information, even though they are frequently accessing the sender via the EventArgs class.

The second method is the old cast and test method.? In this method, the developer knows that the object sending the event is interesting, and so the first thing he or she does is cast it to the expected type and test if the cast succeeded (or catch any casting exceptions depending on the method used to cast it).? Once they have a strongly-typed version of the sender, they can continue with handling the event appropriately.

Having encountered these patterns too many times, I have decided in my latest project to use a pattern which makes more sense to me.? In this case, that means that I have strongly-typed my “sender” parameter to the appropriate type.? This way I can use this information directly in any handlers I create, instead of having to create a custom EventArgs class that wraps information I should already have access to.

I have done some searching but have been unable to find any good reason for the generic sender pattern other than the fact that anyone can raise events, leading to the possibility of needing different types for the same event.? However, in my case, the benefits of having a strongly typed sender seem to outweigh the possibility of my wanting to use a different type to raise the event later.? So far it has worked far better than I had hoped and has allowed me to write event handlers that are more explicit in what they are accessing (at least to me).

Task Estimator v0.1 Alpha Screenshot

Tuesday, February 17th, 2009

This is my alpha interface, designed to flesh out any problems in the underlying design.? So far, everything is working as expected, but there are still some issues to work out:

image

You might notice that there is not currently a mechanism to specify alternatives.? The underlying model supports this, but the interface was proving problematic because of some custom displays I would need in the tree.? I will eventually want to wrap my own control to display it the way I want, but for now I just wanted to get something put together.? I hope to put the alpha version up on the site this week, so stay tuned.

Integrating AddToAny in Website Theme

Wednesday, February 11th, 2009

It took a bit of effort and some experimenting, but I have successfully integrated the AddToAny widget into my website theme (v1.2.1).? The hardest part was figuring how to pass the information around so it would display how I wanted it to.? I also fixed the issue I was having with website titles (apparently you need to pass the title of the page in the URL back to AddToAny, setting it in script will not cause it to be displayed correctly).

The widget also has a nice feature that allows you to add service to it, so I added the Dotnet Kicks (Kick it!) service.? This has (I think) cleaned up the posts very nicely.? As it turns out, I really like the customizability.? I might even have to customize it further, there are some neat things other folks are doing with the menu and display that I may need to investigate further to get the site just the way I want it.

AddThis vs. AddToAny: A Comparison

Tuesday, February 10th, 2009

When I first started this website, I decided to utilize a sharing service
called AddThis which allowed me to easily
setup my content so that visitors could share and bookmark the site as they saw
fit.? I wanted to make this process as easy as possible, and since several other
sites I frequent had made use of this widget, I decided to include it on my
site.

This seemed to work very well, but after a while I
began to notice some odd behavior
.? After eventually tracing it to the
AddThis widget, I decided that a change was in order.? Initially, I thought I
might try to reproduce the widget myself, but given that I'm fairly lazy, I did
a bit of research before embarking on yet another project.? While I had been
investigating the cause of my AddThis problems, I remembered that someone had
mentioned a couple of alternatives in a comment on their blog.? I checked them
out, and decided that AddToAny?was a
suitable replacement.

After using
the AddToAny widget for a while
, I am very happy.? I got rid of the annoying
Flash code, and managed to maintain the desired functionality with a bare
minimum of work.? Since there seems to be a lot of interest in the difference
between the 2 services, I thought I would post both here for you to play
with.

AddThis

Bookmark and Share

Features

  • 49 different services available.
  • Displays full list of services in the same window using a CSS overlay.
    • Has a floating menu selection of most popular services
    • Claims to adjust the popular services based on usage
  • Email feature sends the email from the same page using their email servers.
  • Creates custom statistics on their website.
    • Uses Flash Cookies to track usage.
    • Must have an account to view statistics.
  • Customization options.
  • Provides plugins for several large blogging platforms.


AddToAny

Share/Save/Bookmark

Features

  • 120 Different Services.
  • Opens up service list in a new page.
    • Has a floating menu selection of most popular services.
    • Menu is tabbed based on content
  • Email service will compose an email in major webmail providers (GMail, Hotmail, Yahoo Mail, etc.)
    • Sends you to the actual webmail address, where you login and compose the email with the site link pre-populated for you.
    • Also provides a generic email form that will send email via their servers.
  • No custom statistics provided
    • Can use Google Analytics to access information about what pages are being saved/shared and in what services.
    • No tracking otherwise (that I am currently aware of)
  • Full customization options
  • Provides plugins for several large blogging platforms.

Impressions and Opinions

Obviously, for me the fact that AddThis requires the Flash plugin makes it a non-starter for me.? Based on some information on their website I had thought that perhaps there was a plan underway to provide an option for those of us that didn't want the Flash cookie.? Unfortunately, I never received a response affirming or denying that plan.? In contrast, when I made the switch to AddToAny, they contacted me to offer up any assistance or to answer any questions I might have.? It makes a big difference when people make you feel like they want you to use their code as opposed to making you feel like you are annoying them with your questions.

However, even if I ignore those annoyances, after having played with the AddToAny widget for about a month now, I don't think I would go back.? For what I want, it seems to have the most features, not to mention the fact that my general impression is that it is more customizable than the AddThis widget.? I do like the pretty way AddThis uses CSS overlays to display their full list of services, but to be perfectly honest the overlay clashes with my website anyway and I actually like the way AddToAny shows you exactly what it is you are sharing, despite it being on a different page. Of course, I have had a bit of trouble with getting AddToAny to recgnize my page titles, but I am working on it.? I have seen enough customization examples to know that you can do a lot with the AddToAny widget, so I am confident that I will eventually get it behave exactly like I want it to.

So there you have it, a quick comparison of the things I care about.? Feel free to play with both widgets and decide which one you like.

Task Estimator Design Iteration #3

Friday, February 6th, 2009

This is my final design for this version:

I changed some things around added some methods, changed types, added other types, but the basic concept is still the same.? The code for for everything behind this is complete, so I need to finish off the serialization component and then throw together an interface.? If I can avoid having to travel, I should finish up in the next couple of days.

Task Estimator Design Iteration #2

Monday, February 2nd, 2009

I've been trying to refine this design, and so here is the next iteration of the design.? I fleshed out some of the methods, fixed some of the connections, changed names of the items, etc., but the basic idea is still the same.? I don't like the way the Task and TaskItem classes are coupled together.? Ideally, I would like the TaskItem class to not need to know anything about the task class.? The problem that I am having right now is that TaskItem needs to account for the possibility of having subtasks that make up the item.? Since each of these subtasks might have an optional task item, they end up mapping back to Task:

I think at this point I'm just going to flesh out the underlying code and see how it turns out.? I should be able to stand up a prototype in a couple of hours, so I think it will be helpful to be able to see the design in action, and implementing it might jar some alternatives out of my current stupor.?

If you are curious, I separated out the UI and the storage code into different components from this one.? The idea here is that I'll be able to swap out either the Storage or UserInterface component independently.? This way I can iteratively refine specific aspects of the software without worrying about entangling myself in other components.? I will define specific public interfaces for the Storage component (and implement the factory pattern), so I can simply reference those interfaces instead of the specifics of a given implementation.? This Task component I am expecting to be pretty stable without any alternative implementations, so I don't see the need of making it easily interchangeable with a second implementation.