Archive for January, 2009

Tip for success – Track your accomplishments

When it’s time for your yearly performance reviews, how do you convey all of the great ideas you’ve had, the money you’ve saved the company, and the customers you’ve delighted? My suggestion is to start keeping track of your accomplishments. I think this is especially important in the software business where you may be seen as the guy that sits around at a computer all day.

Accomplishment-Target

I used to work for an incredibly huge (read: bureaucratic) company that required everyone to fill out a form every year, which was basically a resume. You were essentially going through the process of re-applying for your own job to determine your performance, and subsequently, your raise. Everyone hated doing it, but in hindsight I believe it was a good exercise. If I had been keeping a running list of my accomplishments, the process would have been much less painful.

In an ideal world, your boss would really understand your job and would know exactly how great you are. In fact, if you’re a development manager reading this, I suggest you start keeping track of those types of things somewhere other than your head. It will help you evaluate your employees that don’t listen to me!

If you’re not keeping track of all of the amazing things you’re doing throughout the year, there are a couple of obvious problems. First, there is usually a “dead” period right after a review in which your accomplishments are so distant from your next review that they slowly fade from everyone’s mind. Second, you’re just one of many employees that your boss has to manage. How likely is he or she to notice everything that you make look so easy? Not only that, but your career is more than just the accomplishments you had from the last year.

What should this list look like? Each line should be in the same format as an accomplishment on your resume. After all, you’re trying to sell yourself just as you would when applying for a job.

Feb 09

  • Implemented a new CMS system for the finance department saving $5300 annually.

  • Shortened the project planning process by removing duplicate steps, allowing projects to be delivered an average of 10% faster.

Personally, I’ve already starting tracking my accomplishments. The next time I have a performance review coming up, I can send my boss the highlights for the past year, keeping them fresh in his mind. I hope I can motivate as least one other person to do the same. If I ever want to make a career move, I believe the list will also be very useful when updating my resume.

Do you already keep a list of your accomplishments? How have you found it useful?

Vista x64 Frequent Stuttering – Dell M6400

I recently got a new laptop at work (the details of which I’m saving for another day). It’s a Dell Precision M6400. With a fresh install of Vista Enterprise x64, the whole machine would stutter/pause/stall every few seconds. It wasn’t just the mouse, it was the display, the sound, everything. It was unbearably annoying, and I eventually fixed it.

When the stuttering started, I frantically searched Google for other people having the same issue. Apparently it’s a frequent issue, and is often caused by NVidia drivers. In other cases, it’s caused by hard drive issues. It was even occurring on all the other laptops we ordered with the same configuration.

I spent hours trying to fix it, including the following:

  • Updated BIOS
  • Switched the hard drives to performance mode
  • Enabled VT extensions (needed to do this anyway)
  • Forced all of the graphics options in the NVidia control panel to off.
  • Uninstalled NVidia drivers, reinstalled them. I also hacked some of the official NVidia drivers and installed them instead of using the ones that Dell supplies.
  • Turned off superfetch
  • Turned on readyboost and used a USB thumb drive
  • Full scandisk checking for bad sectors
  • Defrag
  • Disabled touchpad and eraser head
  • Turned off just about every service, and killed almost every process
  • Installed chipset drivers (SM Bus)

I had just about given up, when a colleague suggested a few things, including installing new SATA drivers for my RAID array (I’m running RAID 0). I grabbed the latest copy from Dell, instead of using the ones that came on the original CD. Sure enough, that fixed it.

Storage Manager Drivers (Middle One)

The irony is that I usually set up my own machines (I’m pretty specific about how I like it set up), but this time I let our IT guy set it up to save me some time. When I set up machines, I’m obsessive about getting the latest drivers from the web, because I’ve been through this type of problem before. From now on, I’m going back to setting up my own machines.

I get the feeling this will help someone out there!

Extension Methods & Single Responsibility Principle

Extension methods were a new feature in .NET 3.0 (they are also supported by the 2.0 CLR). The single responsibility principle (SRP) is a strategy for structuring our code to make it more maintainable and testable. In this post, I’m going to discuss how we can use extension methods to make our code easier to read and satisfy the idea behind SRP.

As I mentioned, extension methods were a new feature in .NET 3.0, and they’re compatible with the 2.0 CLR. They’re backwards compatible because they’re simply a compiler trick. In fact, you may already have methods that are only one step away from being considered extension methods.

Here is a method that is not an extension method (we’ll come back to those in a bit):

public static Report GenerateReport(ReportData data)
{
	//Create a report from the report data
}

A method like this is useful because it avoids cluttering another class with unrelated functionality. Imagine the opposite situation in which case the report data class is responsible for the data in the report, as well as the formatting of the report. The single responsibility principle tells us that we should separate the operations so that each class has only one reason to change. In practice, I have personally seen the advantages in code maintainability, readability, and testability. I won’t delve deeply into the supporting information in this post.

So how do extension methods come into play? As I mentioned, they’re simply a compiler trick. If we wanted to convert the aforementioned static method into an extension method, we simply add the “this” keyword before the first parameter, which is the type that our method is acting on:

public static Report GenerateReport(this ReportData data)
{
	//Create a report from the report data
}

Now we’ve added an additional way to call our method:

var reportData = new ReportData();

//Old way of calling - still works in either case
var r = GenerateReport(reportData);
//New way of calling with extension method
var r = reportData.GenerateReport();

Our method still works the way it always did when it was static, but now we have an additional way to call it. It’s also important to note that the extension method doesn’t have any extra permissions in regards to accessing the other class. It has to use its publicly exposed interface. In fact, if we wanted to rely simply on the interface instead of the implementation, we could modify our extension data to work on an interface such as IReportData.

The entire reason that extension methods exist is to make the calling syntax easier to read. The driving force was the new LINQ functionality. In particular, chaining the old static method syntax quickly becomes cumbersome.

The new extension method syntax allows us to make the calling code more elegant, and yet organize our methods so that there are clear boundaries between the pieces of functionality that we’re wiring together. Extension methods are obviously not always the best way to follow SRP, but they certainly give you a new tool in your toolbox.

Entity framework designer "entityset" naming bug

I ran into a curious bug in the Visual Studio Entity Framework Designer (edmx editor). There is an inconsistency in how entity sets are named when importing in a database compared to when their created or edited in the designer.

I have the following model for some basic Entity Framework testing:

Database Model

To generate the model, I use the standard wizard that you use when you initially add an item of type “ADO.NET Entity Data Model” to your project.

Model Import Wizard

Using this wizard, my model is created perfectly as one would expect. However, it appears that the code that generates the model from the database, and the code that is generated by the model editor are different.

Now, I edit my model by renaming “TestTable” to “TestTables”, save the model, then simply rename it back to its previous name (“TestTables” to “TestTable”). When I compare the code, the names assigned to my entity sets have now changed:

edmx Comparison

The names of the entity sets went from being named after the tables, to being the name of the table with the “Set” suffix.

Because of how I implement the standard repository pattern with Entity Framework, the naming must be consistent. This issue means that whenever I generate a new model, I have to edit it in some way, and then save it. However, future updates to the model from the database do not cause the names to revert back.

Be aware that if you’re importing your database model, you may see some inconsistencies between the import and the future data generated by the entity editor.

Don’t lose your code – 3 methods that can help

Inevitably, you’ll lose power to your computer, have a hard drive crash, have lightening strike, accidentally delete code that hasn’t been checked in, or encounter some other crazy scenario that I can’t even imagine. What is your plan? Read on if you want some solutions that may just save your ass code.

Did I just delete that code?

I’ve had it happen to me, I accidentally deleted hours of work and had to spend the time to rewrite the code. I even remember a time while working at my first job that the power went out to our whole building. At the time, most computers were desktop machines without a UPS. It was seconds after the lights went out that I heard an agonizing moan from one of the offices. Another developer hadn’t saved often enough and lost everything he was working on.

Use a automated screenshot tool

For the past few months, I’ve been using a product called TimeSnapper. Basically, it takes a screenshot of your desktop every few seconds. I have mine set up to the default of taking a snapshot every 10 seconds.

TimeSnapper Options TimeSnapper Day View

You can store the screenshots as standard image files such as PNG or JPG. You can optionally encrypt the images so that they can only be viewed with the correct encryption key.

Usually one of the first concerns with this backup method is that the image files take up a fair amount of space. Luckily, there are a few ways to optimize the screenshots. Below are the options that I use personally. I use a high level of compression for the images, and only capture the window that has focus. These settings work well with my goal of being able to read the code that was displayed on my screen at any given time.

Image Quality Options

I honestly can’t recommend this product enough. It’s well worth the $25 price tag. Its not only saved me from losing valuable code, but I’ve even used it to lookup information that I found on the web but can’t relocate.

Here is partial list of features to get you salivating:

  • Play your day back like a movie – Watch your entire day in minutes, or quickly scan a time range to find code that may have been deleted.
  • Track productivity by telling it which programs should count as “productive”.
  • View reports on how long each type of application is used. Not necessarily useful, but interesting nonetheless.
  • Flag sections to associate them with other items such as work items in a bug tracking system.
  • Filter by application – You can configure it to track only Visual Studio for example.

Use a keylogger

The next option has the advantage of being a little more lightweight, but may not offer the same level of code protection as using a screenshot tool. Basically, you install a keylogger that will record every keystroke that you make.

When I first had the idea to use a keylogger, I discovered that there are a number of legitimate keyloggers out there. Apparently, book authors frequently use keyloggers to save their work.

You have two options for the type of keylogger you can use. You can use a hardware solution that plugs into your computer on one end, and the mouse plugs into the other. The other option is to use a software keylogger such as PyKeylogger (open source, free).

The biggest problem with keyloggers is that they store the information as you originally typed it, not as it is in your code files. That means that if you’re jumping between files, or making a lot of edits or corrections, the key log won’t be of much use to you.

Most keyloggers do allow you to encrypt the recorded information so that your passwords and other sensitive information are fairly safe.

Automate code backups

There are a number of automated backup tools that will run scheduled backups of your local files. Personally, I like offsite backups for smaller files because they’re portable. I use a product called JungleDisk, which I’ve mentioned before. I have it set up to backup my code every 15 minutes. It minimizes my potential loss of work to 15 minutes at most.

JungleDisk Backup Selection

If you frequently work on a specific network with access to a secure file share, you can also automate network backups. Windows Vista actually comes with a sophisticated file copy tool that supports quick differential copies. Keep in mind that if you’re not connected to the network, you won’t have any protection against lost code at all.

Conclusion

I’ve given you a few ways that you can protect your precious code (in addition to your source control system of course). Personally, I use a combination of JungleDisk and TimeSnapper. Between the two, I could potentially lose a maximum of 15 minutes of work, and in most cases, I won’t lose ANY work. Can you say the same thing?