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.

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.

Doing a 180 in a matter of months

Posted by Sergio on 2008-07-07

by: Darrell Mozingo

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

December 2006 was a low point. The company had lost some good developers, projects were stalling, morale was low, and the outlook simply wasn't good. It was the usual story, probably heard thousands of times before and still lived by thousands more: cowboy coding in continuous crunch mode. Page behind line counts were climbing into the mid four digits and the simplest changes had huge rippling effects across not only the current project, but other systems that were so tightly coupled together they were all fused at the hip. I was in the process of flirting with a few other companies at the time too, but after realizing I didn't want an almost hour drive each way every day, I decided to stay and try to help turn things around.

Coincidentally, something also changed in management around this time – perhaps they saw the sharp morale decline in recent months, or read an article that got them thinking, or who knows – and they too decided things had to change. So, the first step was talking them into getting us some quality training, and not just the ‘ol Advanced ASP.NET training, but some more basic and helpful training, like Object-Oriented Design & Analysis. They agreed, and everyone was thrilled afterwards. We saw all of our current pain points laid out with corresponding ways to counter them using solid OO designs and techniques over the week long course. Sure we all had our OO classes in college, but we'd never really seen how to properly apply them to business applications. First thing after the training, both management and all the developers sat down to lay some new ground work for our future course.

Books were ordered to rebuild our then defunct library, including plenty of juicy OOD books and some old McConnell classics. Online articles started getting sent around between developers for more reading. We started pushing back on clients (who were, in a way, internal clients) to give us time for development. Management loosened the budget for new hardware and software. Things started looking great, and it all happened in only a few months time. It was amazing. Sure, there were still things that needed to change, but we were definitely heading in the right direction.

Before "the transformation" had even began, several of our internal clients had been wanting complete new systems (some were still running classic ASP, some had completely changed their business model, etc), but they weren't quite ready yet. So we kept chewing on existing work that needed done. For almost a year afterwards we tried the various techniques we learned, along with some new ones, on existing projects and several smaller new ones. OR/M's, small scale unit testing, decoupling, CI, and more were all being tried and accepted within the teams. With these large, green field, development projects looming ever closer, though, we were still hitting pain points using these new techniques. Clients weren't completely happy, and there was still something just not sitting right with us developers.

One of the newer developers – not junior, just new- had been looking into adopting RUP at his old company. IBM agreed to come in for a quick one day assessment of our current lifecycle process, where they'd sit down and talk with our clients too, and give us suggestions for improvement (sales pitch, anyone?). When they gave their review, though, it hit me like a ton of bricks. We were using good development techniques, sure, but inside an almost pure waterfall structure. We all knew waterfall wasn't the way to go, but we were totally wearing blinders to the fact that we were even doing it. Whoops! Oddly enough, IBM pushed a very agile form of RUP on us afterwards, so we took a look.

Since then, some teams have adopted a more formal RUP framework, while others, like mine, have gone with styles leaning heavily towards agile. I'd done tons of reading for quite awhile, and a bit of playing in my off time, with test driven development, so I pitched it along with the new ASP.NET MVC framework, and they took it. The team I'm on is small, with only two other developers working on a large, green field payroll application, so acceptance is usually easier to get.

We're now on iteration 3, developing in a completely test-driven way (though we still catch ourselves doing some test-after-development, but we're working on it!), delivering functioning software to the users a little bit at a time using as "many practices" from the ALT.NET community as we can. We're not completely agile – we're not really doing user stories and planning as, say, an XP team would, but I'm sure we'll fall into that eventually. One piece at a time we're converting over. We're also very interested in BDD and DDD, too, and are looking into it while adopting some of those practice's lower hanging fruit.

So far our users are thrilled with the software, we're very happy with the design and testing being built around it, and I'm absolutely loving my job again. We've come a long way in a relatively short amount of time, and things continue to get better every day. To think, I almost quit.