Archive for May, 2008

Who is YOUR customer? It may not be who you think

No matter what your position is, one of the most important responsibilities is to know who your customer is, because they’re the one that you need to make happy. If you think it’s the where the money comes from, you’re probably wrong.

As a developer for a medium size company, I admit having made the mistake in thinking that sales were my primary measure of success. After all, I’m working on an e-commerce site for customers. I was wrong. My customer is actually the person making decisions about the features that go into the product. In a traditional software company, if you’re a developer, your customer is your immediate manager.

Here is a map of the value stream for a typical software company:

Who is your customer?

We can only be measured based on what we have control over. As a developer, you’re not talking to the customer, and you’re probably not picking the features that should be developed. What makes you think you can affect sales?

The development value stream is a hierarchy of levels designed to create focus. As a developer, you need to create features that exhibit quality, and you need to maintain a reasonable velocity. Each level in the hierarchy needs to be doing their job well, or the level above them will fail. Ultimately you do affect sales, but it is with an indirectly. Keep in mind that it doesn’t make you any less important.

Do yourself a favor today. Take a few moment to figure out who your immediate customer is. Then ask yourself what they expect. If you focus on that, you’ll be doing your part to make the company successful.

Stored procedure reporting & scalability

Today’s post is a case study of sorts, about my former employer, who had an interesting architecture. It’s roots were VB6 and SQL server (version 6 I believe). They decided to put as much logic in their stored procedures as possible. The arguments being:

  • Easy to update (fix, improve) on-the-fly.
  • Hard to work with data (multiple tables, arrays, etc) in VB6 and ASP, at least compared to .NET.

Given the circumstances, I don’t think that I would go back and change history if given the chance.

The problem is that the world has changed, and their architecture just doesn’t scale well. The biggest problem is in the area of reporting (which is now primarily .NET). Since all the data manipulation and logic is in the stored procedures, the database is forced to do all the work. In a small application with not a lot of data, this probably isn’t a big deal. The report runs for a few seconds and no one really experiences a slow down.

The problem arises when there is a lot of data. Easily millions of rows in dozens of tables. The current fix is to scale vertically, meaning that they throw more hardware (AKA money) at the problem.

The real solution to the problem is to scale horizontally. There are two main ways of doing this. The first is to add more database servers. The problem is that this isn’t really all that easy. The software to do this is getting better, but the fact remains that two different systems now have to stay synchronized. I’ve read articles about businesses that have scaled their business, and a common theme is that databases are one of the hardest parts of your architecture to scale.

The second aspect of scaling is to reallocate where your work is being done. You need to start thinking of the database as a…well….a database! The first and foremost purpose of a database is to store massive amounts of data, and allow you to quickly retrieve that data.

Databases are amazingly fast when you use them simply as a place to store data. If you design your database correctly, and set up indexes that are optimized for the ways you want to retrieve your data, there should be no reason to wait for your data. SQL Server can easily handles millions or even billions of rows, and query any of them almost instantaneously. Even with multiple queries being executed concurrently or in succession.

Consider the following diagrams:

Architecture

The existing architecture is on the left, and the proposed structure is on the right. It’s not a big change, I’m simply suggesting that the business logic be moved from the stored procedures, into the code.

The first reaction that I usually receive from this suggestion is that the code is going to be ugly compared to the corresponding SQL. The reality is that the SQL is ridiculously complicated (at least in my experience). SQL is great for set based logic, but really starts to break down when trying to do object oriented or procedural operations.

The fact is that .NET is great at processing massive amounts of data. First of all, it’s incredibly fast. If you’re writing your code correctly, you’ll be amazed at how fast it can process data.

More importantly, if you’re using a programming language to manipulate your data instead of T-SQL, you can really start to break down the problem at hand. Databases are traditionally very bad at breaking a large problem into smaller problems. Sure, you can call other functions and stored procedures, but you can tell that it’s not the strongest feature of the database. A programming language like .NET lets you pass data around in any structure that you can conceive.

The other major advantage of processing the data in your code, is that you can now easily build testable code. Any code that you can easily test will have less bugs, and should be easier to maintain in the long run.

If your data is now being processed and organized in your code and not the database, you are probably ready to scale horizontally. It’s relatively easy to add more front end servers. Since they all hit a common database, there aren’t really any synchronization issues.

So does this really work? Of course. I’m not the first to think of it by any means. Take any of the largest websites on the Internet, and look at how they have designed a scalable architecture. Digg.com has always had database scalability issues with their MySql servers, so they try to minimize them as much as possible. Twitter uses ONE database server to handle thousands of requests per second. eBay.com doesn’t even do joins in their database. They would never be able to scale if they put that burden on a database that handles 26 billion SQL queries each day.

Microsoft has made matters worse by integrating the .NET CLR into SQL Server. You can now write .NET code that gets executed on your database server. This is a great tool, but it must be used with great care. This isn’t an excuse to write more code in your database.

In summary, databases are an expensive commodity, don’t abuse them! Be careful how much you do in the database, and ask yourself if you can move some processing into code, where it is more easily scaleable.

Just recently, Scott Hanselman came out with a podcast about website scaling. If you’re looking for more site scaling concepts, it’s worth a listen.

Software is hard!

Not too long ago, I was telling my uncle about an e-commerce site that a coworker and I were able to develop in about 4 months. I was shocked at his next query:

What is so hard about that? Why did it take so long?

What??? I write thousands of lines of code over dozens of pages, and you don’t get it? In a way, that means the software was successful. Often, the simpler the end result, the more code it takes to achieve that simplicity. Most users are completely oblivious to what it takes to create something that actually works.

 Frustrated Developer

Windows has over 50 million lines of code, which was written by over 5000 developers. I’ve heard that NASA spends over $10,000 per line of production code.

So why IS software so hard? It usually requires the entire mental ability of a software developer. In a given day, one would surely exercise their entire brain.

To write a feature, here is just a fraction of what must be considered:

  • Software creation is art and science. You must be creative, imaginative, logical, talented, and knowledgeable.
  • Layer synchronization - Data gets passed up and down between layers, and they all need to agree on how they will call other functionality, as well as how they need to be called. Decisions need also be made to determine if and where data will be validated.
  • Failure modes must be considered - For every line of code, there needs to plan to handle that failure.
  • Affected code needs to be evaluated - Ever heard the line "this is a small change, it won’t break anything". I’m not falling for that one again. It’s like changing out a block at the base of a pyramid.
  • A testing strategy needs to be formulated - Unit tests need to test the new code, and acceptance tests need to test the new functionality
  • More code must be maintained - Every line of code you write counts toward the theoretical maximum number of lines of code that you can realistically maintain.
  • Consider performance and memory - The questions in this area are virtually endless, and the answers might not come easy. Compromise is inevitable.
  • Technology considerations - How much does the target platform vary? What technologies will work, and which ones are the best?
  • Balance modularity and simplicity - Sometimes they go hand in hand, sometimes they’re a tradeoff.
  • Balance the needs of the present with the needs of the future - Try not to play the "What If?" game, but at the same time, don’t be ignorant of the future.
  • Many companies have cross functional teams that developers must report to. Instead of having a manager that feeds a developer their work, now you have multiple sources that are asking for conflicting information. So much for a developer abstraction layer.
  • You’re not the only developer - You need to be cooperative and collaborative to simplify the integration of your code.

Nothing is ever as simple as it seems. You’re not going to piece together code snippets from the web and create a great product.

Code Snippets in Windows Live Writer

I was asked how I insert code snippets with Windows Live Writer. I actually did it the hard way. I wrote a Windows Live Writer plug-in, and then I found out someone had already done the same thing.

I originally got scared away from it because when I switch to the HTML view in Live Writer, it shows up like this:

<div class="wlWriterEditableSmartContent" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:19d17d14-ac74-45e7-9276-5c6a3031b09d" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><DIV class=dp-highlighter>
<DIV class=bar>
<DIV class=tools><A onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="about:blank#">view plain</A><A onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="about:blank#">copy to clipboard</A><A onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" href="about:blank#">print</A><A onclick="dp.sh.Toolbar.Command('About',this);return false;" href="about:blank#">?</A></DIV></DIV>
<OL class=dp-xml>
<LI class=alt><SPAN><SPAN>test&nbsp;&nbsp;</SPAN></SPAN></LI></OL></DIV><PRE class=xml style="DISPLAY: none" name="code">test</PRE>

That is just unacceptable. Fortunately, I realized that it just renders that temporarily, so that you can see a better preview of what it will actually look like on your site.

When you post it, it still has the annoying div above the pre, but I can live with that. All of the other added tags are not there, and you just get your code wrapped in a nice pre. I’m assuming it’s there so that it recognizes that as a code block if you want to edit it later.

I like the SyntaxHighlighter code because it uses JavaScript to parse apart the code and add in the appropriate styles. It’s a nice separation between content and presentation.

I do recommend that if you use the SyntaxHighlighter, that you combine the JavaScript files into one, and then run it through a JavaScript compressor. That will minimize file sizes and page requests.

For example, in this blog, I simply include this in each page:

<link href='http://www.young-technologies.com/sh/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>
<script src='http://www.young-technologies.com/sh/sh.js' type='text/javascript'></script>

Before the body tag, I then use this code:

<script type='text/javascript'>
	dp.SyntaxHighlighter.ClipboardSwf = 'http://www.young-technologies.com/sh/clipboard.swf';
	dp.SyntaxHighlighter.HighlightAll('code');
</script>

This has been working great on my site. Hope that helps you out!

Free Software! - Visual Studio 2008, Windows 2008 Enterprise and Windows Vista Ultimate

I have some free software that I’d like to give away! Here is your chance to win one of the following:

  • Visual Studio 2008 Standard Edition AND Windows 2008 Enterprise (64-bit and 32-bit) - Including the virtual keys.
  • Windows Vista Ultimate with SP1

These copies are fully functional, unused full versions. Microsoft asks that you stop using them after a year, but they have stated that there is no technical limitation that would keep you from using them past that date.

Free Software - Vista, Visual Studio, and Windows Server

There is no purchase necessary to enter. There are 3 ways to enter:

If you add this site to your blogroll, or subscribe, make sure you post a comment or send me an email so I can enter you.

The site that sends me the most unique visitors according to my logs will get first pick at which one they want. The other winner will be chosen randomly. That will give everyone a chance at winning, but gives some incentive to link to our site.

The good news is that this isn’t the most popular site on the Internet, so you might actually have a shot at winning!

The contest ends May 31st, and I’ll pick and announce the winners in a blog post on June 1st.