zobie's blog I create software, I like music, and I'm mildly(?) OCD.

27Feb/09

The Rest of My Development Environment

As a professional software developer the vast majority of my experience has been working on C#.NET WinForm applications. I started using .NET shortly before the 1.0 framework was released. I can't remember if I ever did .NET development under Windows 2000; I generally use Windows XP. If you're wondering why I don't use Vista I have to assume that you've never tried Vista yourself. It's not good. I'm waiting for Windows 7 and hoping for the best.

The tools that I use for C#.NET are pretty standard:

C# Development

The one thing that is sorta strange about how I do my C#.NET work is that I do everything on a Mac Pro with XP running in VMWare Fusion. I've had a similar setup at home for a couple of years but I've only had this setup at work since January.

There are definitely a few quirks that I had to get used to, working in Windows running in a VM on OS X. But the benefits of this setup far outweigh any inconvenience. The ability to take snapshots of the entire VM is awesome! If a program screws with my registry and Windows starts acting funky I just roll back to the last snapshot!

The other huge benefit to working in VMWare is memory. Unless you're using 64-bit Windows (which can be problematic for many reasons) you are limited to 2 GB of memory. Windows sucks at managing virtual memory so I always try to keep my open applications below that 2 GB limit. Since my Mac has 12 GB of memory, if I need to do something else, I can just boot up a second VM.

Most of the software that I've written for OS X has been personal projects. Nothing fancy, just various tools to scratch some itch. Since getting my iPhone I've been doing more work in Objective-C and Cocoa.

Because I've done so much work with managed and interpreted languages, it feels a little weird to work in unmanaged C/ObjC. But it is kinda cool too. Objective-C is a fairly simple language and Cocoa is a very nice framework. There are some things that I don't like about Obj-C (not having namespaces and gimpy string manipulation come immediately to mind) but I really appreciate being able to actually use Cocoa controls for UI work. It is almost unthinkable to do GUI development for Windows without buying a set of third-party controls.

My must-have software for writing Mac/iPhone applications:

Cocoa Development

And finally, a few additional pieces of software that are invaluable to me. These are helpful regardless of what type of software I am writing.

16Feb/09

Web Development Environment

During 2008 I spent most of my time doing web development. There was some Java, PHP and Python, but most of my time was spent working in Ruby on Rails. Rails is a lot of fun and (I know this sounds cheesy, but...) it helped me to enjoy doing web development again.

When I'm working in Java I always prefer to use JetBrains' excellent IntelliJ IDEA. However, this past year I didn't have a license for IntelliJ. I tried every free IDE I could find and wound up choosing Eclipse. I've used Eclipse periodically over the last several years. I don't really like it but I dislike it less than the other free alternatives.

My work was completely server-side and didn't involve developing a database component. Most of my development was done on OS X but I was deploying to Ubuntu so I did work there also. I used maven to build, test and deploy. I'm not a unit-test fanatic but, in this case unit testing was invaluable.

Java Development

My setup for both PHP and Python is the same. When I'm working on Mac I use either TextMate or vim. I haven't done a great deal of Python work but over the past several years I've tried to find a PHP IDE that I like... I'm still looking.

PHP Development

I started out doing my Ruby work using TextMate and Terminal.app. I didn't have any major complaints. There are some nice plugins and various tricks that are handy. But personally, I prefer an IDE. I've heard some people say that IDEs make us lazy. Ok, I'm lazy. But I'm also far more productive when I have a good IDE. When JetBrains started issung beta releases of RubyMine, TextMate was history!

RubyMine's GUI for easily stepping through code in the debugger is great. The inline code analysis is nice for quickly catching typos and the code completion can be useful too. But for me, the best part about having RubyMine is the navigation and documentation.

When I'm working with other developers (or even with frameworks that I didn't write), I don't always know exactly what a method does. Being able to instantly bring up documentation is awesome! If I need more information, I hate wasting time trying to hunt down a method buried in code that I am not familiar with. With one key-stroke RubyMine takes me to the code I'm looking for.

Rails Development

I am definitely a fan of JetBrains' production. IntelliJ is awesome, RubyMine is awesome, and VisualStudio is just broken without ReSharper. There is certainly a learning curve to these tools but once you've memorized the key strokes, the code you need is always right in front of you. And the best part part is that the key bindings are the same across each of JetBrain's products!

One last application that deserves to be mentioned is Navicat. Navicat is by far the best application that I've found for working with MySQL or PostgreSQL. Unfortunately, that's not saying much. I have spent a lot of time using SQL Server and Microsoft's related tools and, as far as I can tell, there is nothing for MySQL that is even in the same league.

Don't misunderstand me. Navicat is a great tool. Allowing me to save connections to different servers with many different login credentials is a lifesaver, especially the ability to tunnel the connections over ssh. Being able to do basic server management via a GUI is nice too. But when I need to design a database, I always turn back to SQL Server Management Studio.

28Jan/09

My Development Environment

Last month I found something new on Facebook, it's called Puzzle Master. I don't know for certain, but Puzzle Master seems to be run by Facebook (the corporation) as a way to find new development talent.

When I first discovered Puzzle Master the running contest was:

To enter the contest, upload to our fan photo album, a screenshot of your desktop and development environment (including as many editors and tools as you can, and your desktop wallpaper) along with a short essay of 250 words or less explaining why and how you use it.

I don't generally participate in this type of contest but I always find it interesting to see how other developers work. There were some cool prizes available and not many entrants so I decided to upload a screenshot of my desktop.

I was disappointed because the picture was scaled down so much that the apps were indistinguishable. So, I decided that it might be fun to do a few posts on my development environments.

First up... my physical setup!

My Desk
The picture is a link to flickr where I've attached some notes to the image.

  • MacPro (2 x 2.66GHz Dual-core Xeon) with 8 GB and ~2.5 TB
  • Two 24" Dell monitors, both at 1920x1200
  • Mac OS X 10.5
  • VMWare Fusion running XP SP3

This is my home office but my work setup is similar. At work my MacPro is 2 x 2.8 GHz Quad-core. It has 12 GB memory and a single 500 GB disk. Maybe I'll try to update this post later with a picture of my desk at work.


Update:
Here's my desk at work!

My Desk at Work

1Jan/09

Read-only Models in ActiveRecord

I recently worked on a project that was built around several hundred GB of data. Several large databases were populated by one team and then consumed by several other applications.

The project I was working on needed to access that data but would never need to modify it. Perhaps I was being overly paranoid, but I wanted to specify that everything from those databases was read-only to make sure nothing was accidently changed.

ActiveRecord is one of the coolest things about rails. With almost no work I get data models, including dead-simple CRUD, in my applications. But the inability to designate a model as being read-only is really frustrating to me.

I know that rails can mark individual instances with :readonly, but I wanted to ensure that every instance of these objects was read-only. Here's what I came up with:

class FooBar < ActiveRecord::Base
  # Prevent creation of new records and modification to existing records
  def readonly?
    return true
  end
 
  # Prevent objects from being destroyed
  def before_destroy
    raise ActiveRecord::ReadOnlyRecord
  end
end

And that's all there is to it! FooBar objects are now read-only.

# You will not be able to create new records
>> fb = FooBar.create(:name => "zork")
ActiveRecord::ReadOnlyRecord: ActiveRecord::ReadOnlyRecord
 
# You will not be able to save modified records
>> fb = FooBar.find(:first)
>> fb.name = "plugh"
>> fb.save
ActiveRecord::ReadOnlyRecord: ActiveRecord::ReadOnlyRecord
 
# You will not be able to destroy existing records
>> fb = FooBar.find(:first)
>> fb.destroy
ActiveRecord::ReadOnlyRecord: ActiveRecord::ReadOnlyRecord

For the sake of simplicity the code here is in a regular rails model. But if you're working with a large number of models like I was, you might consider extracting these methods into a new class "ReadOnlyActiveRecord" which can then used as the parent for the other models. DRY, right?

Depending on your situation, you may need to lock down the record more tightly. With this code you could still create and manipulate new FooBar objects in your code. The exception isn't thrown until you try to persist to the database.

I certainly don't consider myself an expert on rails. If anyone knows a better solution to this problem I'd love to hear it.

27Dec/08

I’m not an idiot… I promise!

I hate new jobs. I like getting to work on new projects, I like learning new things and I like meeting new people, but I hate the actual "new job" stuff. I don't like looking for jobs, I don't like interviewing, I don't like being the new guy who doesn't know anything. Due to circumstances related to the recent economic turmoil, I decided that regardless of my aversion, it would be a good idea to start searching for new employment.

I started looking and, on one of my first phone interviews, was asked, "What is an interface?"

I know what an interface is. I've written new interfaces; I can create a class that implements IComparable, IDisposable and IMakeMillionsFromCrazyIdeas without breaking a sweat. I can talk at length about why multiple-inheritance is pure evil and how single-inheritance, combined with interfaces, will solve every problem known to man. If you would prefer, I can argue the inverse. But, when asked, "What is an interface?" I babble like an idiot:

Oh, an interface is a thing that classes have and they start with an 'I' in C# anyway but it's by convention not a requirement and they come after the class name and a colon and they help us to do things so that when other classes want to do something they know that our class can be used to do that thing because our class implements the interface.

I's a rel gud programur. I got teh 1337 h@X0r skillz. yeah...

I knew the answer, but on the spot, I couldn't figure out how to intelligently convey that knowledge. I hadn't been asked to verbalize that knowledge for a long time. Since I don't like feeling like an idiot, I spent some time googling "interview questions." I don't remember which site recommended the book, but I ended up buying Programming Interviews Exposed: Secrets to Landing Your Next Job, 2nd Edition.

Programming Interviews Exposed was a good purchase. If you you're not already familiar with some basic concepts of computer science I doubt this book would be very useful. But for me it was a great refresher on concepts I use regularly, but hadn't consciously thought about for a while. Who thinks about the nuts and bolts of programming when you're in the zone, and it's just flowing?

As you would expect from a job hunting book, there are chapters on the basics of job hunting: how to decide what companies you want to work for, how to find job opportunities, how to work with headhunters, how to negotiate offers, etc. I wouldn't necessarily consider myself an interview-pro but, many of these tips just seemed like common sense.

The book describes methods for solving riddles and how to answer questions. It doesn't just provide a bunch answers to memorize but discusses ways to convey your knowledge and experience to the interviewer (hint: keep talking and explain what you are thinking). The chapters that I found most useful were the computer science topics: linked lists, trees and graphs, arrays and strings, concurrency, etc. The book gives questions that might be presented in an interview then explains the answers.

To date, I haven't been asked any of the questions presented in Programming Interviews Exposed. Reading examples of various ways to traverse trees and reverse strings was useful. The interviewer does not want return new string (Array.Reverse ("xyzzy".ToCharArray()));. It was useful enough that, when asked to calculate the weight of tree nodes and return a specific node in O(n) time, I felt confident in my answer.

Programming Interviews Exposed will most likely benefit those who are already familiar with basic computer science concepts. It's a quick read and quite effective. Good luck with your next interview!