Archive for April, 2008

Why I’m a better software developer than you

What makes one developer better than another? Shouldn’t we all be performing at the same level? Of course not, we’re not sewing buttons on an assembly line. We’re using every bit of our intelligence to create something that we can only begin to understand.

Software Geek

  • I think logically. Computers don’t care how you feel, and your opinion doesn’t matter. All that matters is if you write your code exactly the way the computer dictates.
  • I constantly look for better ways of doing things. I subscribe to a good number of development blogs. I alone cannot always come up with the best way to solve a problem, but somebody somewhere probably can.
  • I read books. Joel says that most programmers have stopped reading books. What a shame. Blogs are great for snippets, but it’s rare that they cover a topic well from start to finish. Blogs are the ADD version of books.
  • I don’t stop thinking about problems and how to solve them through automation. Sometimes I’ll wake up in the middle of the night, and I can’t get back to sleep until I write some code that I can’t get out of my head.
  • I have side projects that I think are interesting, and give me a chance to try things that I might not want to try on my production code at work. Yes, my side projects distract me at work, but the knowledge I gain pays back the time I lost.
  • I have a tech blog. I suggest all developers start a blog and give back to the community. If you solve a problem, we want to hear about it! At the very least, it will give you an opportunity to formalize your ideas, which will either reinforce them, or make you realize you were wrong. You might also get some great feedback.
  • I try to prove myself wrong (aka objective). Everyone wants to be right. I try to prove myself wrong when appropriate. One of the hardest things in the world for a developer to do is say that the code they just spent a week writing is useless. Maybe it is, don’t fight it, work with it.
  • I keep up with the latest technologies, and force myself to try them.
  • I have a relatively good understanding of how the computer hardware and software works. I’ve met too many developers that barely know how to turn on a computer.
  • I’m great at writing Google queries.
  • I’m not just in it for the money. I actually enjoy what I do. I had a job interview where the guy that would have been my boss told me a story about how he was brought in off the street and thrown into managing their software projects. When the software industry starts getting rough, who do you think is the first person to go?
  • I’m sympathetic to the users pain. If I can share their pain, I’ll want to fix it and prevent it.
  • I realize my code will never be perfect, so I try to make it testable and modular. I set up processes that try to minimize the effect of my human error.
  • I don’t think Microsoft is evil, and I don’t think they’re a saint. They’re a big company. Some of the stuff they write is crap, some is amazing. The same is true for any other company out there.
  • I learn from my mistakes. I try to put at least 2 checks in place to avoid any past mistakes. If one check fails, I’ll have the other.
  • When I’m asked to solve a problem, I think above the problem, and determine if it’s a problem that even needs solved.

Subtext blog platform feature requests

For this blog, I’m currently using WordPress. For my personal blog, I chose to use SubText. SubText is an ASP.NET based installable blogging platform that was originally based on the .Text source code. I initially tried to stay with a .NET based solution, so that I would be able to fix it if something went wrong.

It’s a great platform, and I have few complaints. It’s simple, and it does its job extremely well. I do however, have some suggestions (if they’re not already in there).

image

Output Caching – For low traffic sites, this doesn’t really make a difference. What I am concerned with is the chance that my site could end up on the front page of Slashdot or Digg. The only hope of survival is output caching. Even caching for 30 seconds could make a huge difference.

As an extra bonus, a SQL dependency cache could be used so that changes still show up immediately.

Meta Description – The keywords are not very important, but it would be nice to have a nice meta description. Google usually DOES use the meta description tag if you supply one.The all-in-one seo pack for Wordpress works pretty slick, because it gives you a place to change all of your SEO settings.

301 Redirects for non-standard URL’s – Many of the search spiders are not very intelligent. It would be nice if the URL’s were forced to be a certain pattern. For example, if someone links to superjason.com instead of www.superjason.com, it doesn’t get redirected. That means that the search engines will potentially index both. The same goes for the capitalization of the post names. I would like it to redirect to the all lower case version of the URL’s.

NoFollow, NoIndex – It would be nice if a lot of the architecture pages (categories, archives, tags), were marked as NoIndex. It would also be nice if links to those pages were marked as NoFollow for safety. There’s no reason to pass on your PageRank to pages without any unique content. There is also no reason for them to show up in the search engines.

HTML Cleanup – This feature is much less important to me. It would be neat to use HTML Tidy to clean up the HTML if it’s malformed. I used to write my post HTML by hand until Windows Live Writer matured.

I do, however, have lots of old posts that have potentially malformed HTML. My plan is to eventually write a utility that will clean them up.

I’ve been seriously contemplating converting it to Wordpress. It’s nice being on one of the most popular platform. The fact that I can use add-ons to make it exactly what I want is certainly a plus.

Let’s see what you can do Subtext!

LINQ, I’m not ready for you just yet

Today I was between features on the current project I’m working on, so I had some free time start researching some technologies I’ve been meaning to learn and start using. The topics at the top of my learning list are LINQ and MVC. I gave LINQ a few months to mature, so I figured it was a good time to investigate.

Boy Crying

(there is no emoticon to express my anger!)

The picture above shows how I felt when I started writing my first LINQ expression. The biggest problem was the fact that the latest version of ReSharper doesn’t support any .NET 3.0+ language features. Not only does it not support LINQ, it’s IntelliSense severely interrupts you while writing it. So much so that it makes it unusable.

I went ahead and downloaded the latest development build (Build 783). On their download page, it’s listed as "Works here". That wasn’t encouraging. It does work a little better with LINQ, but it’s still a steaming pile of you know what (dog poop for the not-so-smart). This further reinforces my love/hate relationship with ReSharper.

Anyway, I was eventually able to write some LINQ code. A great tool to get started is LinqPad, which is basically a query analyzer but with LINQ expressions. Writing LINQ is very difficult with a SQL background, because everything is backwards. You think you know what you’re doing, but you don’t.

Right now, we’re using NHibernate in the main project that I’ve been working on for the past couple of months. It’s amazing, but there are a couple of things that would be nice:

  • Better optimization of queries – It looks like LINQ does an amazing job with this.
  • Batched reads & writes – LINQ does batched writes, but lazy loading by default. Maybe not as big a deal as I think.
  • Cross session saving – I spent hours battling with some code that loaded a complex object with relationships in one session, and then saved them in another. It appears that LINQ solves this, but I’ll have to run some tests to be sure.
  • Less work generating mapping files and relationships.

One thing that is nice about LINQ to objects is the fact that it will generate all of the model classes, plus the glue that connects the model to the database. You can either use Visual Studio and drop the tables into a mapping file, or you can use SqlMetal to script the class generation.

One of the biggest questions I’m trying to answer write now, is how unit testing fits in with LINQ. We’re currently testing our data access layer by using an in memory SQLite database, which let’s us perform close to real world saves and loads. We also use interfaces for our data access methods, which makes it easy to create testable classes that can simply be supplied a database interface.

I’m also not sure if it even makes sense to put my LINQ queries in a data access layer. The code would almost seem trivial, and would just create a lack of flexibility. Ironically, it almost feels like you should use LINQ to query against your data access layer.

For now, there are more questions than answers. For now, I don’t plan on retrofitting my last project with LINQ, but I’m going to investigate if it will be a good foundation for the data access logic in my next project. Of course if I go that route, you’ll be sure to hear about it!

.NET XML DataSet Generator from a SQL Query

As promised, I’ve now made the .NET XML DataSet Generator available on Google Code.

.NET XML DataSet Generator

If anyone can think of a better name for the project, please let me know! It’s really hard to convey what it actually does. On the project page, I put these basic steps, which should help make it clear:

  1. Run this program to execute a SQL statement
  2. Copy the resulting XML into a file in your .NET unit test project
  3. Embed the XML file you created
  4. In your test code, load the embedded XML, deserialize it back into a DataSet (code coming soon)

As the project matures a little bit, I’ll have better documentation. I may even whip up a video demonstration. It’s not really a fancy tool, but it does come in handy.

For example, let’s say you have a database method that returns a DataSet containing a table of blog post items. You have another method that turns that DataSet into an array of post objects. I know that you’re thinking you should normally use an OR mapper, but this is just an example, so please don’t interrupt me!. This tool lets you create a serialized DataSet that you can use in a unit test, which will reconstitute the DataSet into the exact same thing your database method would have returned. You can now pass in a snapshot of real data into the method your testing. If you ARE using an OR mapper like NHibernate, this probably won’t happen much, but when it does, this tool will come in handy.

IIS 6 and Apache on the same server and port

This has been written about before, but I just ran into it, and hopefully I can save someone a headache.

Apache Feather 

I installed Apache on my dedicated server, which has 9 IP addresses. Since all my sites have a dedicated IP address, I figured I would just configure Apache to listen on some IP’s, and IIS listen on the others. They both would listen on port 80. I configured it correctly, only to find out that Apache wouldn’t start.

It turns out that IIS hogs port 80 on all IP addresses, whether IIS is configured to listen on them or not. Microsoft has a good knowledge base article on the subject, and of course it’s by design so it’s not going away.

The only thing to remember is that the instructions are for specifying the IP addresses that IIS should listen on. For some reason, I was thinking the opposite initially, which obviously caused some frustration.