Categories
Job

A Bit of a Change

For the past seven years, I’ve been happily employed at WebMD Health Services. But all good things must come to an end, and today is my last day there.

I’m moving to New Relic, a small company with an office here in Portland. They write application performance monitoring, and their product is seriously cool. I remember being floored when I first saw how much information they capture out of our web apps.

This is a big move for me–I’ve only worked two places in my career so far, and both have been Windows based. At New Relic I’m joining the Ruby team, and they don’t even officially support that part of the product on Windows. I’m excited to get the chance to dive in the deep end of a new language, platform and company.

I’m planning to blog a little during the transition, especially to try and capture the day-to-day hints that will help me transition from Microsoft’s loving embrace to the open source world. Watch this space.

Categories
Uncategorized

WP e-Commerce Plugin

A friend needed to start selling her products directly from her website. I’d previously set her up with a basic WordPress installation. It’s easy editing of pages and theme options were the big selling points.

Given that, I started off searching for WordPress plugins. I immediately ran across the WP e-Commerce plugin. “That seems too easy,” I thought. It had over a million downloads, though, so it didn’t seem half-baked. Could you really do e-Commerce from a blog with just a free plugin?

Out of the Box
I haven’t used WordPress much, but installing WP e-Commerce was pretty standard–search, click, install. Actually, I had to upgrade the blog’s software first, but that was also a button click away. Smooth and easy.

WP e-Commerce is well integrated into the WordPress Dashboard. A new Products section showed up, along with a ton of settings under Settings > Store. Sales are available on a menu right under the main Dashboard item.

It installed default pages which weren’t quite what I wanted. I also found the styling didn’t jive well with my current (somewhat customized) theme. Thankfully all the changes could be done in CSS, without having to actually futz the page templates.

Payments
My friend wanted to use an existing PayPal account for payments. This was among the simplest bits of the whole setup. On the Payments tab under Settings > Store, I marked PayPal, told it the username… done. Did a simple test in which I gave my friend $0.02, and it flowed through fine.

Shipping
The road got rockier, though, around shipping. WP e-Commerce comes with shipping calculator options–flat rate, USPS and UPS (among others). Flat rate’s features worked, but the whole concept didn’t. Overcharging locals and undercharging folks far away doesn’t seem like the best business choice.

The USPS settings in the plugin seemed clear, but correlating those to what keys and accounts the USPS site required was a nightmare of poor documentation. Never did get it to work.

UPS looked better, although it still wasn’t as clear as I’d have liked. I was partway through that when we noticed a FedEx add-on to purchase (which was actually my friend’s preference.)

FedEx ended up being the simplest option. With all the right keys, accounts and passwords, it just worked great. (Sidenote, though–why don’t the major shipping sites, when you search for “developer key” yield anything even vaguely like a page saying “Here’s how you get a developer key.” Seriously, it took half an hour on the best of them (FedEx) to find the right steps.)

Deployment
Finally the day came to go live. I upgrade WordPress on the live site, FTP’d the various plugins and theme changes across, activated the plugins, and imported an XML dump from the testing site. It worked… partially.

My pages came over (minus some edits to existing ones that didn’t quite take.) The products all came over just fine (with the exception of a couple images that chose the wrong sizing… huh.) Hurray for that.

The Settings, though, were nowhere to be seen. All the page after page of tweaking I’d done didn’t move. Now I realize some of the settings are sensitive (passwords and dev keys for instance). But if I export a site that says “Yes, please use shipping”, it’d be really nice if importing it on the other side, um, enabled shipping.

Only took about a half hour of screen-by-screen comparison to line things back up, but it’s annoying to have to do it.

And the Verdict…
If I had it to do again, I would definitely consider this plugin. It seems like a great fit for someone who’s already using WordPress as their main platform, and it covers all the basics without too much fuss.

Categories
ASP.NET

UserControl + Repeater = Pain

I tripped over a seriously annoying thing in ASP.NET late yesterday, and continued tripping much of this morning. I had a user control that contained a repeater. On initial load of the control, I did my DataBind() protected by an !IsPostBack. I didn’t disable ViewState (though it grates on me to leave that bloated beast in place). Everything rendered like you’d expect.

Then the postback came, my repeater’s Items were empty.

I beat my head against this. I validated my repeater wrote to ViewState. I changed where I was data binding. I debugged into the Framework code, but never managed found why I wasn’t getting my controls created again.

To make sure I wasn’t crazy, I pulled the Repeater to the page, out of my user control, and everything worked as expected–Repeater.Items was present on the postback.
I mentioned the struggle in stand-up, and a coworker kindly showed me the solution:


protected override void OnInit(EventArgs e)
{
base.OnInit(e);
EnsureChildControls();
}

Bing. Suddenly all of my repeater controls were there when I looked for them.

Why there’s this difference between repeaters in a Page or UserControl, I don’t know, but it did the trick.
Categories
Monitor Troubleshooting

How to fix a disabled monitor driver

My cousin called with an interesting problem. Someone in her office had a laptop that previously used multiple monitors. They started digging around in display properties trying to get rid of nn error message on startup (MultiMon, which I love, was just warning there wasn’t another monitor). Lo and behold, they disabled the driver for the primary monitor, and the second monitor support was already long gone. After a reboot, the screen was blank. It would show the BIOS and OS startup, but login was all black.

I had her bring over that and a similar laptop, and tried to step through by keystrokes to re-enable. That wasn’t getting anywhere. As I later determined, the buttons I was trying to access via the Display properties were disabled, so even when I nailed the sequence, it wouldn’t have helped.
Then I had a bright idea–Windows comes with a rudimentary screen reader. I figured out how to launch it via keystrokes, and after a long time listening to the terrible computerized voice, fixed the problem (sidenote: never thought I’d say something nice about JAWS, but it’s reading voice is much easier on the ears than Narrator)
This was on Windows XP, but something similar should be possible on Vista or Windows 7, although the interface will vary.
Here’s what I did:
  1. Log in (helps if you had a startup noise so you know you’ve actually made it)
  2. Type Win+R
  3. Type “narrator” and hit Enter. The computer should start reading off the Narrator introduction.
  4. Hit Start key, then move through list with arrows to My Computer
  5. Hit the right-click key, then use arrows to get to Manage
  6. In the Computer Management window, move through list to Device Manager.
  7. Tab should move you to the list of devices in a tree by type. Move with arrows to “Display adapters” and/or “Monitors” and hit the right arrow to open them, down to select the particular entry in the list.
  8. Use the right-click key on each entry under those categories, choosing Properties and pressing Enter.
  9. On the first page of the Properties, tabbing through should reach a dropdown that’ll read “Don’t use…” Change that to “Use this device (enabled)” with the up/down arrow keys.
  10. Tab again to the OK button, and hit Enter
  11. Reboot computer. At this point, the login screen was visible again.
First time I’ve actually gotten direct utility from a screen reader, but it sure was a life saver. Hope the write-up might help someone else too.
Categories
UnitTesting

Unit testing isn’t about bugs

For those already living the TDD lifestyle this will be old news. But a couple weeks back I overheard one of my coworkers say, “Unit testing doesn’t find bugs because they’re only checking what you already expect. That’s not where the bugs are”

As sold as I am on unit tests, I agree. No amount of automated dev testing can replace good QA. But this comment also misses the major wins for unit testing.
Unit tests force smaller classes and methods
The largest impact to my coding from TDD is that my classes and methods have shrunk. It’s well known that short and simple code is best, but it takes discipline to keep your code that way.
Unit tests backs you up on keeping things small. Tests get hard to write when things are large and complicated. You’ll start to feel an itch (or worse) when that method does too much, or that class requires onerous initialization.
Yes, you still have to recognize the smell and do something about it, but the unit tests gives some nice pressure in the right direction.
Unit tests highlight bad naming
A good test reads like a description of what a method does. Are there required actions in the midst of your test that don’t fit with the flow? Maybe you’ve got a bad name there.
Again, bad names crop up everywhere, but good, striped down unit test are often the first spot to highlight a name that needs work.
Unit tests give you confidence
With tests in place, I’m more likely to rename, extract methods, and otherwise clean things up. The more thorough the tests (and the simpler the code in question) the more comfortable I am with making changes.
Until you’ve got unit tests in place and make a large-scale change without breaking anything significant, I don’t think you can entirely understand how valuable that confidence is.
Unit tests do find bugs… later
The tests you write won’t find the bug you just checked in and didn’t write a test for. But it will save you six months from now when you violate that subtle condition in a hurry to fix some other bug. They’ll ensure over time that some aspects of the code haven’t changed, no matter what chaos is swirling around them.
So there it is. Even if unit tests don’t point out all your bugs straight off, they are still worth the effort.
Categories
UnitTesting

Spreading Straw

Last weekend, I did one of my “favorite” chores–cleaning up after our two retired greyhounds in the backyard. What does this have to do with programming? Well, shovel in hand, for some reason I started thinking about unit testing. An analogy bubbled and percolated, refusing to let me focus on spotting dog crap.

Our backyard isn’t large, and greyhounds like to run. They’ve devestated any semblence of grass back there, and during Oregon’s wet season (read “nine months of the year”), it’s muddy. Real muddy. To combat the mess, we get bails of straw from the local feed store and spread it all over. Ugly to look at perhaps, but it keeps life an order of magnitude cleaner.
How does this relate to testing? Well, a lot of people talk about getting good code coverage. But even if you get 100% coverage of every path, that doesn’t necessary mean you’ve tested everything.
Imagine each individual bit of straw is a test, while the mud is the codebase. I guess the dogs would be developers then, churning it up, while the rain would be product showering you with requests that threaten to ruin all your beautiful architecture. Hold on, went too far there. Back up to the straw and mud, that’s the important bit.
If I spread my entire yard with straw exactly one piece deep, how well do you think that’d work? We’d have a pit in seconds once the greys got going. Not all parts of the yard are equal. The pit at the corner where water comes down the sideyard and the dogs make a hard turn? That needs some extra covering. How about the main track the dogs have dug down below the walnut tree? The whole length gets more.
I see unit testing the same way. Yes, you should shoot to covering everything, but if you stop at “Tests hit every line of code,” you could be missing something. Where are the more complicated sections? Where should your tests be communicating more of the code’s purpose? Where have your bugs been coming in frequently?
Maybe those spots need a little extra straw.
Categories
ReSharper Tools

Tools: ReSharper

I’ve long been skeptical of Visual Studio add-ins. This goes back to the VS6 days when I fell in love with an add-in, but eventually removed it because it did such horrific things to my machine’s performance. I felt so betrayed, bereft and I’m sure some other suitable words that start with “b.”
Well, times change. WebMD’s been buzzing about ReSharper. It’s been quite a while since I took the plunge, but I’m never looking back.
Enumerating ReSharper features could keep someone blogging for months at the least, but I thought I’d call out a few of my favorites. Seems like half the time someone talks about ReSharper, I find some widget or keystroke I hadn’t noticed before. Maybe you’ll notice something new.
Go to Definition isn’t busted anymore
This one’s kind of a no-brainer, but sometime around VS 2005, I started finding that “Go to Definition” wasn’t working like it used to. It’d bring up strange files with “[from metadata]” in the title, and only give function signatures.
Turns out, as best we can tell, this is because VS doesn’t properly handle the pdb’s on our assembly references. For various reasons we don’t use project references, so for a long time I suffered without my beloved F12.
Well, ReSharper restores this functionality, and it actually works. Now if I could just persuade it to go to code files for projects I don’t have in the solution…
Run unit tests in-context
Prior to ReSharper, I used TestDriven.Net to run my NUnit tests directly from Visual Studio. I can’t tell you how much of a game-changer that was for my unit testing. Good habits often come from reducing the friction of doing the right thing, and having a single keystroke run tests was a massive step forward.
ReSharper provides the same abilities as TestDriven.Net and more. The only caveat is that sometimes it has trouble running large sets of heavy-weight tests (which we have quite a few of around here). For those, I’ll still crack open NUnit itself so I don’t take my IDE down on a long test run.
But for the small tests that drive my design? “Ctrl+R, O” baby, all the way.
Refactoring
I’ve got a confession to make–as big a fan of refactoring as I am, I never quite got up on Visual Studio’s refactoring support. I didn’t have enough time between using VS 2005 and when I started using ReSharper, so I really don’t know what ReSharper’s got that VS doesn’t.
But if you haven’t had the change to work with a refactoring IDE tool, get one, whatever it is. Just the basic rename is worth the price of entry. Again, it’s all about friction, and the refactoring tool makes it easy to revise names when I find later on (sometimes just minutes) that it isn’t quite right.
Move and renamespace are now dear friends of mine. While good naming is important, it doesn’t help if your namespaces are crap, or worse if they don’t align with where to find the code. Not that many years ago this was a difficult problem for us, but now there’s no excuse.
Find Dependent Code
A recent find for me is ReSharper’s brilliant “Find Dependent Code”. This works at a variety of different levels, from individual files, folders and class names, to referenced dlls.
That last one was a huge time-saver as I’ve been winnowing out dependencies from one of our projects before we start some major work on it. Previously, I’ve relied on the grep + break the local compile method to find where a particular assembly was used within a project. No longer. Now all that beautiful information is just a mouse-click away, with line-numbers and double-click-goto support right there.
What else can I say, I loves me some ReSharper!
Categories
Tools

Tools: CLCL

Copy-paste–savior of word processors, “advanced” feature of the masses, bane of software design. Ctrl+C/V is so burned into my fingers that it’s physically painful for me to watch someone clicking the toolbar or menu to copy a piece of text.
But real estate on the clipboard is scarce. Yes, certain applications like Office and Visual Studio provide you with a clipboard ring to save multiple things, but I’ve always found them clunky. Plus, my main use for copying is often bringing stuff from another app, so anything restricted to say, just Word is useless to me.
I’d read about apps that extend your clipboard, but didn’t really pay them much heed until one fateful day. I was writing a new chapter for my book in a web app (which shall remain nameless), and hitting problems. Whenever I’d submit, it was choking. I could click back, and the browser thankfully still had my text. Thinking, “I don’t want to lose what I’ve written,” I copied it into the clipboard. Then I set about trying to fix the app. I shut down the browser (no back anymore), and my speedy little fingers happened to copy another snippet of text–probably a URL or login name, I don’t remember. I’ve blocked it out.
Crap!
Several pages of original text floating in the ether of the clipboard were obliterated. Maybe those clipboard extenders were worth a look.
I’ve settled on CLCL, largely for its simplicity. There’s hardly anything to it, but it will save at least 30 items, crosses reboots, and provides a nice little “save to template” feature where I keep some common strings (login name + domain for instance, since I’m lazy and get tired of typing it into fifteen different apps on our network). Shortcut keys to bring up the saved items completes the picture.
Now I install CLCL anywhere I work frequently. I can’t imagine coding without it there in the background, lovingly gathering up whatever I saw fit to copy, holding it in reserve just in case I need it for later. Thank you CLCL, you’re a lifesaver!
Categories
Tools

Tools: Notepad++

Dealing with text is a huge part of a programmer’s job. While issues of proper design, working with the product requirements, and appropriately testing your code might be more difficult to master, simply navigating massive amounts of code day to day can be a challenge in itself.
Hence, text editors have sparked a million flame wars across the internet. My needs are more modest than the sort of flexibility in emacs or more costly proprietary editors like SlickEdit. I primarily use it for editing snippets of text, cleaning up lists, tracking check-in notes before pasting them into our bug tracking software.
My absolute needs:
  • Fast startup (as close to Notepad as possible)
  • Keystroke macros (learned in Brief on my Dad’s knee and still use those skills today)
  • Regex find/replace
Most of the rest is gravy.
Now why, you might ask, wouldn’t I just use Visual Studio? I’m constantly running it for my main code editing. Well, it clearly fails the first test. Especially when hitting “special” files such as XML and HTML, it bogs down loading up specialized editors I just don’t need. It does have a keystroke macro mode, but it also takes an absurd amount of time to start first time around. That just bugs me. Yeah, I use it, but never happily.
So what is the current winner for my random text editor/formatting/processing? The venerable Notepad++. As the name suggests, it’s a better replacement for Notepad, and it scores on all the points I listed above. Even better, the macro record has the same shortcut key as the same laggy feature in VS. Such symmetry makes my nerdy heart go pitter-patter.
Notepad++ has some other nice features too–some keystroke customization, syntax highlighting, viewing options. My only beefs are no multi-window support (it’s single instance) and the Open File dialog hitting the last opened directory rather than the directory of the current file (a minor detail I just love about VS, and wish was done everywhere).
I’ve also toyed with Notepad2, which was almost equivalent for my needs except the lack of keystroke macros. In any case, if you’re using Notepad still for minor text edits, stop it and give something a little better a try.
Categories
Uncategorized

Introduction

I’ve already got a blog (http://blog.jasonrclark.net), so what’s this doing here? Well, I’ve got an itch to write up some notes on technical issues, things that I encounter during my development days, tips and tricks I find interesting along the way. Given that most of my friends who read the blog are 1) not programmers and 2) have gotten used to not receiving bewildering doses of techie-speak, I decided to set up a separate blog.

I work as an application developer at WebMD, so the stuff I’ve got slated at the moment revolves largely around web development, databases and ASP.Net in particular.

So there you go. Yet another blog for no one to read but the author.