Behavior-driven development is fun

You may have heard about test-driven development, or TDD. The idea is that you write all your tests, run them, watch them fail, and then write code that makes all the tests pass. There are many advantages to this approach. I have done projects with and without TDD, and the projects that used TDD came together more quickly and were more reliable. Yet myself and my teams still did not use TDD consitently. Why? Because it is a drag. Everyone knows that it is a better way to build a system, yet as you slog through the test writing, it is hard to convince yourself of that.

Along comes behavior-driven development, or BDD. Now instead of writing tests that fail (which is really pretty negative and depressing) you describe the desired behavior of your objects, and mark the implementation as pending. Since you probably have to document your objects anyway , it does not feel like a waste of time. And writing BDD tests is just more fun than traditional unit tests.

Some of the critics of BDD say it is just TDD with different terminologies and syntaxes. That’s more or less true. But anything that “tricks” developers into doing the right thing is worth paying attention to. Furthemore, you are likely to get better tests with more coverage, because the BDD frameworks make you want to write tests for everything.

Want to try out BDD? There are implementations for every major language. If you are using Ruby, check out the awesome RSpec framework. For other languages, see this page.

If you have tried TDD before and given up on it, give BDD a try. You will stick with it this time!

HTML and CSS are today’s assembly code

I used to think HTML and CSS were fine languages. Then I met Haml and Sass, and now I see the light. But first, a little perspective is in order.

Here is the assembly code and then the C code for a simple assignment and calculation:

Assembly C
MOVF id3, R2
MULF #60.0, R2
MOVF id2, R1
ADDF R2, R1
MOVF R1, id1
position = initial + rate ∗ 60

Compared to assembly language, C is operating at a much higher level, with benefits too obvious to enumerate here. But don’t forget that assembly language was a huge step up from hand-rolling machine code. And also recall that C++ took C to a new level of abstraction of by adding classes and templates. A language is “high-level” only in comparison to its brethren. Read More

RESTful Databases are finally here

The modern, SQL-driven relational databases arrived in the 80’s, before the Web had taken off. When developers started to build web-based applications, these databases were a natural choice for storing persistent data. Object-oriented databases (OODBs) were available, but they were not widely accepted due to performance and scalability issues. Here is the crucial point: relational databases were not chosen because they were a great fit for Web apps, they were chosen because that was the only realistic option available at the time.

With the arrival of Java and other object-oriented languages, the shortcomings of relational databases became more obvious. Developers now had to map their classes to tables in the database. Object-relational mappers like Hibernate made this process less painful, but it remained an awkward solution compared to using a real OODB. Read More

Pick a language already!

I have been telling myself this every single day that I have been doing software development. It seems that there will never be a shortage of zealots pushing the next big language. They will tell you that there are some great new features that you cannot live without and you’re missing the boat if you don’t change. These outside comments make it very difficult to select a language for any upcoming project that you plan on starting. No matter what the concept, whether it be a copy cat of an existing application or completely original and innovative, you will have a line out the door of people telling you why their language is the best for your application. I have one thing to say to those people that never miss an opportunity to plug their favorite language, “If you knew anything, you would realize that your language is not the best.”

Read More

Importance of caching your applications

This was not an easy lesson to learn. Our site is less than a few weeks old and I had figured that it would not receive any large traffic for a few months. I was wrong. As some of you noticed our site hit the viral level with our article about web terms. The amount of traffic that was sent our way crippled our server and taught me the importance of caching mechanisms.

Read More