Oct 4, 2009

The Details of Javascript

I've recently been reading JavaScript: The Good Parts and have found it to be an excellent look at the details of the language itself while ignoring the DOM (which is exactly what I wanted). Then today I ran across this Google Tech Talk by the author, Doug Crockford.

Aug 22, 2009

Something Different

Moving forward I'm going to be focusing on the techniques necessary to develop AJAX rich client apps tied to RESTful rails backends for internal business use. In all likely hood I will be providing these applications to users as (single site browser) via Google Chromes application short cuts but my intention is to write code that works on any browser; IE8, Firefox, Safari and Chrome.

And now for something different....

May 10, 2009

Onion News Network Has Fun With Star Trek Movie

I haven't seen the movie but I stumbled across this and got a good laugh.


Trekkies Bash New Star Trek Film As 'Fun, Watchable'

Writing the Reader's Stories for the First BDD Blog Release

I continue with my plan to write user stories for my first release. In this post I'll cover features from the readers perspective.

  1. Must be able to Create, Edit and View posts.
  2. Must support per post permanent URLs
Here's the first draft of the readers browsing feature. We'll see where it evolves to in the future.

Feature: browsing
As a reader
I want to browse the site
So that I can read it's content


#
# scenarios that involve the reader navigating to the
# home page as the number of available posts vary
#
Scenario: 0 of 0
Given that 0 posts exist
When I go to the home page
Then I should be on the error page
And I should see "page not found"

Scenario: 1 of 1
Given that 1 post exists
When I go to the home page
Then I should be on post page 1
And I should not see a link to the next post
And I should not see a link to the previous post

Scenario: 2 of 2
Given that 2 posts exist
When I go to the home page
Then I should be on post page 2
And I should see a link to the previous post
And I should not see a link to the next post


#
# Scenarios that involve the reader navigating to a specific
# post; the first, middle and last. These primarily demonstrate
# the behavior of the navigation links to previous and next
# post pages
#
Scenario: 1 of 2
Given that 2 posts exist
When I go to post page 1
Then I should not see a link to the previous post
And I should see a lnk to the next post

Scenario: 2 of 3
Given that 3 posts exist
When I go to post page 2
Then I should see a link to the previous post
And I should see a link to the next post


#
# navigation to specific posts is done through post
# page permalinks. The permalinks are derived from
# the title of the post
#
Scenario: navigate to an non-existant post
Given that no posts have been created
When I go to the path /posts/get-rich-overnight
Then I should be on the error page
And I should see "page not found"
And I should see a link to the home page

Scenario: navigate to an existing post
Given that post 1 exists
And that post 1 has the title "Get Rich Overnight"
And that post 1 has the body lorem ispum
When I go to /posts/get-rich-overnight
Then I should see "Get Rich Overnight"
And I should see lorem ipsum

Writing User Stories for the First BDDBlog Release

In a previous post I shared the basics of my release plan, crude as it was. Next I'm going to create user stories for the entire first release once that's done I'll plan and execute regular weekly iterations to complete all the release stories. The one thing I'm going to do a bit different is that I'm going to rough out my user stories directly to cucumber features then I will maintain a list of uncompleted features that can be prioritized as I burn it down.

The first task at hand is to turn my first release's outline into Cucumber features. As I do this I'm not going to get overly concerned about the wording of my features. I expect that I'll be massaging them as I implement them.

With all that out of the way It's time to burn down the items on my release list and create some features. The first two items in the list is the most basic;

  1. Must be able to Create, Edit and View posts.
  2. Must support per post permanent URLs

Next I'll look at this from each type of users role; Reader, Author and Admin but I'm going to do that in seperate posts.

May 3, 2009

My First BDDBlog Design Decisions

Website navigation should just work from the users perspective. It should seem simple and intuitive they should never have to think about it. That of course means the burden to 'think about it' is on the developer. Today I spent some time trying to decide how I wanted navigation to work in my new blog. It wasn't as easy to make these decisions as I would have expected before hand.

Specifically I was trying to figure out exactly what a reader expects to see when they navigate to the home page and where they expect to find older posts. I spent a fair bit of time looking at other blogs and in the end I found two basic approaches.

In one case the blogs tend to provide some number of recent posts one below the next on the home page. Typically the posts are separated by dates as appropriate. This style seems to be more appropriate for blogs with frequent small posts.

The other common approach was to only display the most recent post on the homepage and to provide navigation links to previous posts. This style seems to be more appropriate for blogs with longer posts.

This left me a bit unsure at first. Quite a few of my posts are much to big for Blogger's format. On the other hand It's not entirely uncommon for me to do micro posts. What to do?

Well after spending quite a bit of time thinking about it, for now, my decision is that I'll use the latter style. My blog will feature a single post per page and provide links to older or newer posts as appropriate but this means I can't easily roll a twitter or delicious summary into my blog without it displacing the most recent post.

After spending some time pondering that problem I decided that I may not be able to roll those other feeds into my blog but it most certianly doesn't prevent me from splicing them into my feed.

So it looks like I've already stumbled on to another requirement; the ability to splice multiple RSS/Atom feeds into one. Feature creep already =(

On the other hand maybe I've stumbled on to a useful service? Atom/RSS Feed splicing with format conversion? Does anyone already offer that? Hmmm... I'll have to think about that one.

May 2, 2009

Planning Features for the First BDDBlog Release

In a previous post I talked a bit about my motivations and just what I was up to. In this post I'm going to start to define some specifics for the inner blog project.

I'm planning on making at least three releases. The first release is intended to replicate the basic functionality of Blogger. The second release will expand on the first, provide better tools for managing multi-part articles and some wiki like editing features. The third release, which is being developed for a different domain and not this blog, will incorporate the shopping cart functionality.

Here's my laundry list of functionality in the order I intend to implement it in the first release:


  1. Must be able to Create, Edit and View posts

  2. Must support per post permanent URLs

  3. Must allow posts to be tagged

  4. Must support monthly archiving

  5. Must support authenticated admin/author logins

  6. Must have admin editing of site title and description

  7. Must have admin editing of site CSS and HTML header/footers

  8. Must have admin editing of side panel html/javascript

  9. Must be able to import Blogger's exported content

  10. Must provide full text search functionality

  11. Must provide tag search functionality

  12. Must provide an Atom 1.0 full content feed

  13. Must be able to ping blog search engines


Now on to the coding....

May 1, 2009

Dissident Movments Of The Future

Anonymous' target may be Scientology but it's interesting to think about how these tactics maybe applied more broadly in the future by other interests.

How Long Before TV Programming Follows Print Media?

You'd pretty much have to be living under a rock not be aware of the changes the 21st century is imposing on the old media industries. Print news papers have been especially hard hit recently. Still, it really sunk in today, that television is next and when their financial problems start, it will happen just as rapidly and be just as significant.

What made this especially clear today was watching this:

I'm not entirely new to EPIC FU, I first ran across it quite a while back, but what what really struck me today was the high quality of the production. If this is what you can get for free and on demand why would I want to pay to have crap streamed to me?

Apr 26, 2009

Some Progress On My BDD Blog Project

I finally got around to doing some more work on my BDD Blog project over the weekend. Up to this point I had mostly been just experimenting (here, here and here), but this time I decided I was going to try and write and implement a real scenario.

My goal though is not so much to implement code. Instead I'm still trying to learn how to write features and specs. I want to get to the point where I'm comfortable enough with Cucumber, Webrat and RSpec that I'm confident I can express all the features for a release without wasting my time.

So lets start with the feature I'm going to try and implement. The feature it self is very straight forward. It walks through the process used by an author when creating a new post.

Scenario: save a draft post
Given I am logged in as John Doe
And I am on the post creation page
And I have filled in the title with "Get Rich Overnight"
And I have filled in the body with "lorem ipsum"
When I click the "Create" button
Then I should be on the post index page
And I should see "Post successfully created"
And I should see "1 to 1 of 1 posts"
And there should only be 1 post listed
And the first post's title should be "Get Rich Overnight"
And the first post's author should be "John Doe"
And the first post's status should be "draft"

I've already played around with AuthLogic and demonstrated it's use but there's a minor change here. I'm no longer testing authentication so I needed to reduce the login process to a single given statement.
Given I am logged in as John Doe

The code I used to do that is pretty straight foward.
Given /^I am logged in as (.+)$/ do |login|
Given "I am the registered user #{login}"
visit path_to("the login page")
fill_in('Login', :with => login)
fill_in('Password', :with => "password")
click_button("Login")
end

The only thing even remotely interesting here is that I'm calling one of my previously defined 'Given' statements from within this one.

The next few statements are very straight forward and were implemented entirely in cucumber with the existing scaffold for the Post resource.
And I am on the post creation page
And I have filled in the title with "Get Rich Overnight"
And I have filled in the body with "lorem ipsum"
When I click the "Create" button
Then I should be on the post index page
And I should see "Post successfully created"
The next line in this scenario:
And I should see "1 to 1 of 1 posts"
I now realize didn't belong in this scenario (I'll refactor that out later) but since I learned something while implementing it I'm going to share.

Specifically, what I learned was this statement has no real purpose. I wanted to make sure that only the new post was present but all this really does it check to see if the "1 to 1 of 1 posts" text is present. It doesn't provide any real validation of the number of posts on the page. In the future I'll move this out to a new feature that's specifically written to test the pagination summary.

This line was not originally in my feature:
And there should only be 1 post listed
I added it when I realized my mistake with the previous line. This statement directly tests the number of posts on the page by counting the table rows in the post index table. It's implementation is very straight forward:
Then /^there should only be (\d+) posts? listed$/ do |count|
response.should have_tag("tr" , :count =>(count.to_i + 1))
end

The next three lines:
And the first post's title should be "Get Rich Overnight"
And the first post's author should be "John Doe"
And the first post's status should be "draft"

These lines were all very similar. They are simply looking to make sure that the contents of specific columns in the post index table have the correct information. This statement is implemented with the following code:
Then /^the (.+) post's (.+) should be "([^\"]*)"$/ do |index, column, text|
response.should have_selector("table>tr:nth-child(#{position_to(index) + 1})") do |tr|
tr.should have_selector("td[class=
'#{column}']") do |td|
td.should contain(text)
end
end
end
There's not much special there but it was my first attempt at really trying to use the CSS selector notation. Maybe after I'm more comfortable with it I'll devote a post to just that but for now I'll just explain this method.

In a nutshell it simply looks to make sure that nth row in the post index table has a td tag with a class matching the column name and that it's content matches the text passed in.

You may also notice I have a poorly named method called position_to in this method that simply turns the english words; first, second, third, etc... into the appropriate fixnum. Hopefully down the road I can find a library that does this but if not maybe I'll expand my approach into a full fledged gem.

This pretty much covered what I did with Cucumber and Webrat to fully implement this scenario but I did dip down into some view, controller and model specs to get the job done. I'll save that for another post.