Sunday, March 8, 2009

Don't Just the Write Code, Solve the Problem

Curse of the 18 Inch Stonehenge
In the classic mockumentary "This is Spinal Tap", a designer is asked to build one of the Stonehenge triptychs based on designs drawn on a napkin. She builds the triptych according to the specifications and delivers the replica - but the result wasn't what the client wanted: (language warning)

As a web developer for a medium-sized software company, I get requests to build all kinds of things. Sometimes it's simply a process to move data from one place to another, other times it may be a full-blown application. It's easy to fall into the trap of fulfilling requests as they come in, but I've learned over the years that it will save me time and effort as well as please my internal clients if I ask an important question first - what is the problem you're trying to solve or the outcome you're trying to achieve?

The Doctor is In
When I go to the doctor, I don't tell her what medicine to prescribe or action to perform. I describe the symptoms, answer her questions and possibly submit myself to some tests. Developers should see themselves in the same role as the doctor - we help solve problems. Before you write that first line of code, take a step back and think about what the client is trying to accomplish. You may be surprised to find that code can't actually solve the underlying problem. You may also come to the conclusion that the original request is exactly what is needed. Regardless of the decision, the process will help you consider why it is you code what you code.

Code Can't Solve Everything
It's great to feel like an MVP but, let's face it, some problems just can't be coded around. As we look at the problems we're trying to solve we may discover that the problem is actually a bad business process or an outmoded way of doing things. Sometimes we are able to code around those things, but perpetuating bad business habits is in nobody's best interest. Get to the root cause and solve that problem first. Code may help, but often it's a combination of business processes, business logic and even UI inefficiencies.

Sometimes, though, code is the answer. It's certainly part of many solutions. Well designed code can help automate manual processes, ensure data consistency and integrity and make the entire operation more efficient. Like any good machine, code should help the users be more efficient and make their work easier. If you've done that then it's a job well done.

Solve Tomorrow's Problems Today
It's one thing to solve an immediate problem and move on with the next project. Sometimes, that's what we have to do. But it's even better to solve tomorrow's problems before they occur. I try to make my code as future-proof and extensible as possible to avoid having to revisit it six months down the road because business needs changed. By thinking ahead we will save ourselves headaches and make our code more reusable and maintainable. A few things I've done to this end are:

  1. Be a Detective
    When a request comes in ask questions to understand what you're being asked to do. Not only will that help you code the right solution, it will give you understand business processes outside your core domain. It's amazing how much you can learn about marketing, sales and finance if only you take the time to understand the purpose behind the process.
  2. Offer Solutions
    When you see a problem, offer a solution. It's easy to wait for a client to come to you, but you make yourself more valuable by identifying problems early and solving them when you can. It may not be possible to implement a solution right away, but if you have identified a problem and have a potential solution, it will help you code for the future as well as the present.
  3. Solve a common problem
    Things you do over and over again should be a library or class. It may entail adopting a framework from which to build or simply having snippets of code to refer back to. You shouldn't write the same code over and over, though. Reduce, Reuse, Recycle
  4. Know your systems
    Strive to understand the APIs for your CRM, financial and reporting software or the marketing systems that may be in place. Often the coder has more intimate knowledge of what CAN be done than anybody else. You also know the idiosyncrasies and pitfalls of those systems. Use that knowledge to make things better.
  5. Maintain Your Code
    Just like any machine, web code needs to be maintained. It's the most difficult part of coding for me, especially when the code is working just fine. The problem is that new technologies, design patterns and needs come along. The code you built last year may work until it needs to be extended to do one more thing. Constant refinement makes updates quicker and easier and ensures that new requirements don't cause a complete system overhaul.
These are some of the ways I end up avoiding the Curse of the 18 Inch Stonehenge. What are your strategies for delivering what the client wants, not just what they ask for? Share them here, I'd love to know what works for you!

Friday, February 27, 2009

Quick Tip: Apache, mod_deflast and JavaScript

We've been compressing the content we serve with Apache's mod_deflate for a while, but we weren't seeing the performance gain we would like and recently found out why - our JavaScript wasn't being compressed.

I was sure I had told Apache to compress JavaScript and sure enough there was the line in our httpd.conf file:

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

So why wasn't it compressing? It turns out there is some (very understandable) confusion around the MIME type. In our HTML declaration we use <script type="text/javascript"> but that's html. The MIME specification for JavaScript - and this is what is defined in /etc/mime.types - is application/x-javascript.

We modified our AddOutputFilterByType declaration and saw a noticeable increase in load times:

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript

Any Other Optimization Tips?
If you have any other optimization tips or gotchas please share them here. I'd love to hear how you've increased site performance.

Further Reading
JavaScript MIME Type:

Apache Docs on mod_deflate:

How To for mod_deflate:

Thursday, February 5, 2009

The Power of Constraint: Why Twitter Works (For Me)

I admit it - I didn't get Twitter at first. I don't really update my Facebook status all that often and I couldn't figure out why anyone cared what I was doing at any given time. The truth is most people don't. So I ignored Twitter, letting all the cool kids have their fun telling each other what they were doing that weekend.

Then it happened.

My coworker, who did the bulk of the work on The Virtual Black Hole, was in China and the writers wanted to add Twitter icons and "Follow me on Twitter" links to the blog. So I dug in and got the templates updated and in the process ended up with a Twitter account of my own ( - You can see the feed on the right.) I followed a few people, began posting and suddenly I began to see why Twitter was so interesting:

It's not about what I ate for breakfast.

Twitter lies. It says right at the top of the page "What are you doing?" but people don't want to know what I'm doing. They want to know if I have any interesting ideas, links or insights. They may be interested in my response to their ideas or blog posts or simply to inform me of events that interest me. The point is that it's about bringing together like-minded people to share their interests and interact. It's about following a wide range of people and finding out what others think. And it's about interacting with those ideas and people.

The Power of Constraint

Twitter isn't a forum, a blog or a massive social networking application like Facebook, MySpace or LinkedIn - all of which bring people together and allow interaction. But they do so in a noisy, chaotic and unbounded fashion. Which brings me to the key point of why Twitter works for me - It is constrained. It's constrained in two ways:

1) It does one thing and does it well
2) Each post is limited to 140 characters

Twitter doesn't have hundreds of applications you can add to your profile and it isn't cluttered with things all over the page. It is simply a feed of posts ("tweets") There are an increasing number of applications that use the Twitter API and expand its functionality, but Twitter itself is a simple, elegant application. It's easy to use and it's easy to understand - I read tweets and I write tweets. Advanced users may direct message, reply or retweet, but even the advanced functions are simple to use. Ease of use and application focus aren't the things that make it really useful, however.

The thing that makes Twitter really useful for me is the character limitation. With a blog post there is this great unbounded white space waiting to be filled. It can be rather daunting. There is the pressure to not only write meaningful posts, but write them with some regularity. It takes time, planning and discipline to keep up a blog.

Twitter has none of that. In fact, I don't have to write at all if I don't want to. However, when I do write, I can simply post a statement, link or question and not worry too much about spelling or grammar or even a general theme. I'm just myself and there is a great deal of freedom in that. I can reply to a tweet or even ask a question and anyone who is following me may answer. It's also a connection I may never have made otherwise. That's powerful.

But Wait, There's Less

From a reader's perspective, the brevity of the posts in Twitter also make it work very well. I know that I'm going to dedicate about 30 seconds to a tweet. If it contains a useful link (many do) I can follow it. I've actually seen a huge amount of useful information come from Twitter in the form of references. Using a tool like TweetDeck I can mark tweets as favorites, categorize people I follow and filter tweets to easily find what I'm looking for.

It's also interesting to note trends among the people you follow, find out what they're interested in and begin to make links between topics I never would have made before. And it's all (for the most part) personal. It's actual people posting actual thoughts. Yes, there are ways to automate posts, "retweet" and become simply a marketing machine. That has its place as well. But it's not what makes Twitter work (for me). It's the less is more principle and it's working pretty well so far.

Oh, and I often eat corn flakes for breakfast.

What About You?
So that's (some of) why Twitter works for me. Why do you use it? Or don't use it, for that matter? How do you use it and what are your favorite tools? I use TweetDeck almost exclusively and the mobile site on my Q. Below are some other people's reason why Twitter works.

Further Reading

Five Things I've Learned About Twitter - Karen over at posted a similar article. More reasons why Twitter works.

Isn't Twitter Just Too Much Information - Twitter's own succinct reasons why less is more.