Sergio and the sigil

Looking Beyond Visual Studio

Posted by Sergio on 2008-08-04

by: Grant Palin

This post was originally submitted to The Great Devlicio.us Giveaway.

Up until about a year ago, I was programming in .NET using just Visual Studio. I was used to the tedium of manually compiling, testing, backing up projects, writing documentation, and so on. There was no awareness of tools and techniques, just much manual work.

My curiosity piqued by various writings on the web, I read an article about source control with Subversion. And in a flash, I realized that I was missing out on numerous tools and techniques. So I proceeded to learn about Subversion, and set up repositories for my projects.

And that was just the beginning. I set out to read about other practices and tools. I read, I experimented, I wrote, I revised, and I learned.

And now I feel I am much more knowledgeable than I was a year ago. Over that time, I have started using source control, build automation, code analysis and metrics, design patterns, and unit testing. I have applied these concepts to ongoing projects, and it has been quite an adventure.

I now know that when next I start a new project, I will have knowledge of tools and techniques to simplify and guide my programming efforts, both in getting started and in the long run. And these can be applied to other languages and platforms outside of .NET and Windows. I have also been applying these ideas to one of my PHP projects. The concepts are the same.

All of this learning has been done on my own time, for my own purposes. I now realize that many of these practices could be useful at my day job. I have helped to set up a Subversion server, and move one of our bigger projects into source control. I have also initiated discussions on unit testing, build automation, and code metrics. There is interest among my coworkers on the subject, and it is my hope to be able to apply my new knowledge for the benefit of our projects.

Just think: if I had not read that first article on Subversion, I might have carried on with my projects in the manual tedious way. I might not have learned anything new. But I did, and I started moving beyond my boundaries.

And after all of this, I can see that there is still much more to be learned. I shall continue to read about and explore the tools and practices, and apply them if I find them useful. My main lesson here is that it is important to be aware of what information is out there, and how it can be used to one’s benefit. Thanks to some initial exploration, I am now a better programmer, and will continue to better myself and my skills.

Software I can't work without

Posted by Sergio on 2008-07-31

I'm about to configure a new development machine this week. It's going to be my 3rd install from scratch in the last 12 months, which I know is not all that much, but certainly more than I wish I had to.

Besides the common software development tools, like Visual Studio, SQL Server, Ruby, Office, Firefox, SVN, etc, over the years I've collected a number of small tools that I make sure are installed before I start doing anything else.

The list is volatile but some utilities have been there for years. Here's my current list in no particular order:

  • Taskbar Shuffle - I'm sort of a neat freak and this little wonder does only one thing. It lets you rearrange the application buttons in the taskbar. I don't understand how this is still not enabled in Windows out of the box. UPDATE: We have been heard. Windows 7 finally allows you to rearrange the taskbar buttons.
  • Slickrun - I need a command/app launcher and I've settled on Slickrun for some time now. I don't need much from it but I definitely need it. On my mac, as you can imagine, I use Quicksilver.
  • EditPlus - Every serious developer has his favorite text editor. Mine is EditPlus, at least on Windows. It's simple, extensible, has most of the features you'd expect from a text artisan's toolbox. Again, on the mac I'm more obvious and use TextMate, which is quickly becoming my new favorite if I can work on the mac.
  • Truecrypt - In case you aren't familiar with it, Truecrypt is a data encryption software that creates encrypted file systems that that you can mount in Windows, Mac OS X, and Linux. Truecrypt makes encryption a piece of cake and I have been using it since when it's non-Windows support was laughable.
  • Timesnapper - This tool has a very simple premise, it takes screenshots of your desktop on a regular interval. You can later relive your day just like a movie. This application is like my backup memory when I'm preparing my timesheets. It works great with Truecrypt in case you are concerned with having your whereabouts "caught on camera."
  • Lutz Red Gate's .NET Reflector - There's no .NET development without Reflector, I should not even need to mention that I use it. Let's start a campaign to have Reflector bundled with Visual Studio. Update: Reflector was acquired by Red Gate shortly after I wrote this post. I guess they moved quicker than Microsoft and our campaing to have that tool be part of the SDK or Visual Studio is severely at risk.
  • Daemon Tools - Mount ISO images as CD/DVD ROM drives. Update: Apparently I was using a much older version of Daemon Tools and that tool now install spyware even if opt out of installing the stupid toolbar. I'm starting to use Virtual Clone Drive now and it has been alright.
  • Hamachi - VPN made easy as pie. 'Nuff said.
  • Foxit Reader - I can't stand Adobe Acrobloat. Foxit isn't the greatest thing on earth but is good enough and very lightweight.
  • Filezilla - Sooner or later I'll need a FTP client. Filezilla has been good to me.
  • Firebug for Firefox - If there's no .NET development without Reflector, then Firebug is like Reflector for Web development. But I'm sure you already know that.
  • YSlow for Firebug - This nice add-on helps me by suggesting possible ways to improve page loading performance. While you're at it take a look at these other Firebug extensions.
  • 7-zip - Because we all need a shell-integrated compression tool.
  • Tabbed Console - I'm not exactly a command line ninja, but I find myself at the black screen very often. Often enough that it's not rare that I have more than one of those open. The tabbed Console utility allows me to have all my command prompt sessions in the same window. And more than that, I can have flavored command windows tabs, like one for the regular cmd.exe, one for IRb (the Ruby console), one for PowerShell, one for Cygwin, VS Command Prompt, and on, and on.
  • Sysinternals stuff - Sometimes you need to bring the big guns.

What about you? Do you have tools that you feel naked without?

It's obvious, use TimeSpans to measure time

Posted by Sergio on 2008-07-24

I know, this is probably not news to anyone. TimeSpan is the native .NET type to represent time intervals. But answer quickly, SqlCommand.CommandTimeout represents the interval in milliseconds, seconds, or minutes? What about System.Timers.Timer.Interval ?

To circumvent this situation we see all sorts of API design contortions, like trying to standardize all time units to the same unit, which sometimes is not viable, or using unnatural affixes when naming the class members, for example.

class CalendarEvent
{
	public string Name { get; set; }
	public int DurationMinutes { get; set; }
}
//or..
class EquipmentError
{
	public int ErrorCode { get; set; }
	public double MillisecondsTotal { get; set; }
}
//or...
class ProjectPhase
{
	public int ProjectID { get; set; }
	public string PhaseName { get; set; }
	public int PhaseWeeksDuration { get; set; }
}

I think this stinks. Why do we constantly ignore the TimeSpan structure? I know it's kind of the bastard child of the System namespace. It lacks for example string formats. It's larger than a simple Int32. But the complete annihilation of any doubt as to what time unit we are using is worth all that.

The previous examples could be made clearer with TimeSpans.

class CalendarEvent
{
	public string Name { get; set; }
	public TimeSpan Duration { get; set; }
}
//or..
class EquipmentError
{
	public int ErrorCode { get; set; }
	public TimeSpan TotalTime { get; set; }
}
//or...
class ProjectPhase
{
	public int ProjectID { get; set; }
	public string PhaseName { get; set; }
	public TimeSpan PhaseDuration { get; set; }
}

But let's not stop there. We can simplify our lives by, for example, creating some extension methods to deal with time interval tasks. I don't show below, but we could very well write an extension method to fix the lack of a TimeSpan.ToString(string format) method.

using System;
namespace Utils.Extensions.Time
{
	public static class TimespanExt
	{
		public static TimeSpan Minutes(this int interval)
		{
			return Minutes((double)interval);
		}
		
		public static TimeSpan Minutes(this double interval)
		{
			return TimeSpan.FromMinutes(interval);
		}

		public static TimeSpan Seconds(this int interval)
		{
			return Seconds((double)interval);
		}

		public static TimeSpan Seconds(this double interval)
		{
			return TimeSpan.FromSeconds(interval);
		}

		//.. a metric ton more utility methods like these...
	}
}

With these extension methods, we get some handy syntax to ease the creation of TimeSpans.

TimeSpan interval = 5.Seconds();
TimeSpan elapsedTime = 0.7.Minutes();

And don't forget to use the Nulalble<TimeSpan>, a.k.a. TimeSpan? when the interval is optional. I think the nullable is clearer than using TimeSpan.Zero (or TimeSpan.MinValue — argh!!!) to represent unknown or missing values.

Design Patterns in Ruby - book review

Posted by Sergio on 2008-07-22

I have a friend that is very much into Design Patterns and wanted to learn Ruby with a more applied perspective of the language.

I went the exact opposite direction. I know a little bit of Ruby already and I wanted to improve my limited patterns knowledge.

What we had in common is that we both picked up Design Patterns in Ruby by Russ Olsen. The title can be a little deceiving in that you might think it assumes Ruby knowledge, but no, it actually covers the Ruby language at a level that doesn't bore the reader with programming basics. The book assumes you know how to program already but you're new to Ruby.

After an introductory chapter about Ruby basics, the book delves into Design Patterns, their formal definitions, how they look like in Ruby, how to leverage Ruby features to tweak the patterns, and examples of the pattern being used in examples extracted from the Ruby class library or popular components (gems). As the examples and tweaks are being presented, any new Rubyism being applied is explained.

I found this book to be a great way to learn more about the Design Patterns and the proper way to implement them in Ruby. I also learned a little more Ruby and some language features that I did not know how to use yet.

The new crop of .NET Screencasts

Posted by Sergio on 2008-07-20

I finally carved up some time and watched the first episode of Steve Bohlen's Summer of NHibernate. These are sessions that Steve recorded for his team's Dine and Discuss events and he was kind enough to share with the entire community.

Steve undoubtfully knows his stuff and how to explain the topic with the right amount of details and sprinkled with lots of insightful comments. I'm looking forward to watching the other sessions soon.

It takes a lot of effort to put a screencast like that together and I admire the people that create and make them available to us. I think screencasts are quickly becoming the best way to learn a new technology or tool. Imagine the number of hours I would have to spend reading a NHibernate book, 20 or 30 hours for a slow reader like myself? The amount of information you can get from videos, especially screencasts where you feel like you're in a coding session with the author, just can't be matched by a book.

Screencasts aren't without problems either. They're expensive to host, stream, and download. They're typically not searchable. You need a computer so you can't just have them on your side table (no, I'm not gonna watch them on an iPod, sorry.) They don't substitute reference material, which is not really a problem, just not the role of this medium. I can't watch them during my commute because I'm a responsible driver.

I'm happy to see a lot of new sources of .Net screencasts and I wish I had time to watch them all. Here's a list of screencast series that I watch/watched/will watch.

.NET Screencasts

Non-.NET

  • Railscasts: Great way to get familiar with Ruby on Rails development.
  • Peepcode: Commercial, inexpensive videos. At $9.00, they're a steal.
  • Pragmatic Programmer's screencasts: Since I'm big fan of these guys, I'm sure I'll buy at least a few of these very soon.