Archive for August, 2008

Functional Tests

Thursday, August 14th, 2008

Here’s the first few functional tests that I’ve based off of the usecases for the new link aggregation website.

Index Page

When an anonymous user visits the main page, the user should see:

  • A Submit Link hyperlink.
  • A tag cloud.
  • A list of the top links from the past week. Each item in the list should have:
    • A hyperlinked title
    • A short description
    • A link to the user profile that submitted the link.
  • Links labeled month, day, year, all time. and a ghosted link labeled week in the upper corner of the list of links.
  • A login/create account link

When a known user visits the main page, the user should see:

  • Everything an anonymous user sees except that the links day, week, month, year, all time should be ghosted based on which date range the user had selected previously
  • A settings link.

Busy (Sleep)

Wednesday, August 13th, 2008

Well, been busy the past two days. Really tired now.

Went to RPG, company site picnic, worked hard at work, that’s about it…still tired, going to go to bed now.

Catcha later

Aggregated Design So Far (with more details)

Monday, August 11th, 2008

This is a continuation of this post and this post, showing how the examples gain more specifics as time goes on.

Use Cases

Submitting a Link

Bobby finds a neat link about plate tectonics. he goes to the website “tectonic-plate-o-matics.com” to enter the link to the community. He sees the current links ranked by rating. In a corner, he sees “Submit link”. He clicks it and and is given a form that has the following inputs:

  • Link URL
  • Link title
  • Link Description
  • Tags

He then submits the link and sees it show up on the front page. Note: Since Bobby isn’t logged in when he submits the link, it doesn’t show up for other anonymous users. Just the submitter and any users that have the “See anonymous links” set to true. For Bobby, It is also artificially floated to the top of the link list regardless of its current ranking, since Bobby submitted it.

Visiting A Link

Bobby now clicks on one of the links on the front page. He is taken, in a unobtrusive frame, to the link. The frame has a few buttons or inputs on it, including:

  • rank +1
  • rank -1
  • add tags
  • report link

When he clicks on any of these, he’s taken to a login page, the login page supports either open id or creating a user account on the web page itself. After he’s logged in, he is returned to the page he was on. It also contains a list of current tags for the link.

It also has a prominent “close X” button which cleanly closes the frame.

Ranking Links

Sally is an active member of the link ranking site. She goes there multiple times a day to check out new links about plate tectonics and moderate them, so she always has her login cookie set. When she goes to the homepage, she is presented the top links for the day (since this is the setting she has selected last time, the default is for one week).

She clicks on the link she finds most interesting, “Daffy Ducks view of plate tectonics”, and visits it. She then uses the upper frame to moderate the link with a score of +1, she hits back and is returned to the homepage, the link she moderated is closer to the top of the list because of her moderation.

Note: There needs to be some sort of trust metric (advogato style?) for reputation of moderators, and strength of their moderations. The interface must also be designed so it isn’t like reddit.com, it’s not a news site, just an index.

Reporting Dead Links

Sally then clicks on another link “Tectonic Plates of the ancient world” which brings her to a 404 page, she then clicks the “report bad link” button on the top frame and selects “page not there anymore” from the drop-down menu. When she clicks submit, a status message is displayed in the frame saying something like “Thank you for your attention to detail!”

Note: Other options could be “inappropriate link”, “link moved”, etc. We also need to handle tagging/incorrect tagging somehow…

Main Page

The main page has three main sections:

  • Header, including site logo, title, login, and settings link
  • Sidebar consisting of a Tag Cloud and other navigation links
  • Links, which is a list of links that have been rated in the past week with the highest Bayesian based ranking. Each link has a title and a short description and a link to the profile of the user who submitted it.
    • This also has links to display the links by rank from the last day, month, year and all time.
    • It also shows which, if any, tag is selected for the links.

More Usecases

Sunday, August 10th, 2008

Time for more usecases! (continued from this post)

Ranking Links

Sally is an active member of the link ranking site. She goes there multiple times a day to check out new links about plate tectonics and moderate them, so she always has her login cookie set. When she goes to the homepage, she is presented the top links for the day.There is also a tag cloud that has the most popular categories.

She clicks on  the most interesting link, “Daffy Ducks view of plate tectonics”, and visits it. She then uses the upper frame to moderate the link with a score of +1, she hits back and is returned to the homepage, the link she moderated is closer to the top of the list because of her moderation.

Note: There needs to be some sort of trust metric (advagato style?) for moderation of links. The interface must also be designed so it isn’t like reddit.com, it’s not a news site, just an index.

Reporting Dead Links

Sally then clicks on another link “Tectonic Plates of the ancient world” which brings her to a 404 page, shen then clicks the “report bad link” button on the top frame and selects “page not there anymore” from the dropdown menu.

Big Hike

Friday, August 8th, 2008

Well, we went farther up the reservoir this time and Mike joined us. It was threatening to rain but we made it through the entire hike without getting soaked, so that was good. I took a few photos as well, so it was all good.

We saw a chipmunk and went a bit farther on the loop. I definitely want to bring my telescope out there sometime during a new moon. I bet there is almost no light pollution in the valley after the second reservoir.

On the way back, we saw hundreds of crows apparantly flocking into the canyon for the night, it was very impressive and a little frightening.

So, we came up with two website ideas during the hike:

  • A RPG website that’s community based, something like a hybrid between ficlets and a wiki for back story material (including photos, maps and art), and then forms to create character sheets and a “chatroom” to play sessions in. it would also have a user database of items to use in campaigns.Once a user logged in, they could GM a new campaign. The campaign could be set to invite only or open to the public and would include snippets on backstory, grit, etc. Or it could be an “open game” that was decided by the players and the GM after they had gathered. The sessions would be recorded in a log format and then converted into back story, etc. It would also handle all the dice roll calculations based on the character sheets. The GMs and campaigns could then be rated by the players.
  • A music review/information blog website.

The RPG site sounds like a lot of fun, if albeit challenging. Building it on top of Pinax would work like a charm. The hardest part would be making either a COMET or AJAX interface for chat, and the rating/trust system, of course.

Design phase 1

Friday, August 8th, 2008

Alrighty, time for the spec writing to start!

drumroll

So, the basic goal is to create a link-repository application where people can submit links on a topic and they can be ranked, verified and deprecated as needed. E.g.

Submitting a Link

Bobby finds a neat link about plate tectonics. he goes to the website “tectonic-plate-o-matics.com” to enter the link to the community. He sees the current links ranked by rating. In a corner, he sees “Submit link”. He clicks and and is given a form that has the following inputs:

  • Link URL
  • Link title
  • Tags

He then submits the link and sees it show up on the front page. Note: Since Bobby isn’t logged in when he submits the link, it doesn’t show up for other anonymous users. Just the submitter and any users that have the “See anonymous links” set to true.

Ranking Links

Bobby now clicks on one of the links on the front page. He is taken, in a unobtrusive frame, to the link. The frame has a few buttons or inputs on it, including:

  • rank +1
  • rank -1
  • add tags
  • report link

When he clicks on any of these, he’s taken to a login page, the login page supports either open id or creating a user account on the web page itself. After he’s logged in, he is returned to the page he was on. It also contains a list of current tags for the link.

It also has a prominent “close X” button which cleanly closes the frame.

Just a few thoughts

Wednesday, August 6th, 2008

So a lot happened today. People find ways and excuses not to try things, or do things. They claim that they don’t want to fail, or that failure is not an option, but become paralyzed by their unwillingness to act. They lack confidence at the same time that they overflow with pride.

I don’t want either thing to happen to me. So I have to remind myself every day: just do it, it doesn’t have to be perfect, you’ll find how to make it better after you do it.

Today I got up late, worked late, but had a good evening reading a book. My ideal schedule needs some modifications…I tend to do mnemosyne cards right after work and need some to relax by reading novels or watching a scifi show. I also want to put some time aside to do drawings…I plan on doing a bunch of portraits of hands, the only way to get better is to try :) I’ll post them after I do them, as well.

I also figured out what I want out of my options of Y, M and N ( I feel like I’m L from deathnote, haha). Comparison can be so enlightening sometimes. Now if only my dreamspace was more straightforward. Or at least gave me a better point to action :)

Tools: Pinax and Inkscape

Sunday, August 3rd, 2008

Pinax is a big ‘ole collection of Django reusable apps packaged into a ‘portal’ or ‘cms’ type website. It supports OpenID, blog posts, twitter posts, messages, groups and profiles. It feels like the Django equivalent to Joomla!. Django has really, drastically matured in the few years that it’s been around. Reusable Django apps are multiplying and are of a general high quality, integration is cake, and templates are much easier to write than modifying PHP code. (Like the templates used in Joomla! or Wordpress)

I’ve really grown to love Inkscape as well. It’s excellent for technical drawings, page layout and logos. I just wish they’d release new versions more often. :)

Keeping At It

Sunday, August 3rd, 2008

I have a project I want to try over the next few weeks. I’m going to design a simple Django application for link submission and ranking and try to follow the pattern:

  • Write specification first
  • Write functional tests from specifications
  • Write out CRC cards
  • Write out code and unit tests

Now, this is quite a bit heavier wait than just “Hack away” but I’m trying to increase my analytical, writing and design skills. As such, I’m going to write the documents as pages on this blog, and have updates on posts.

The only way to get better is practice, practice, practice.

OSUG

Friday, August 1st, 2008

I went to the OSUG meeting tonight. The topics were Assimilator, a distributed computing toolkit, and agile development tools (focusing on Java and the JVM).

Assimilator

The creator and primary author, Kevin Hartig presented the Assimilator project. It’s basically a framework to run Java (or stuff on the JVM) on a cloud network. You put “services” in net containers and the net containers know how many resources are available, what type of processors they have, memory, etc. There is also the ability for a process to “split” and cluster if the interface to the software knows how to do that correctly (This is built in to the container for the Tomcat web server.)

It seemed very useful for creating parallel computing clouds or super redundant systems. Of course, it doesn’t offer a easy solution to the classic parallel stuff, you have to use algorithms that parallelize easily. It would be interesting to take some of the concepts (widely distributed, no single point of failure) and try to apply it to storage…That would make a good thesis project for someone interested :)

Tools for Agile Development

We covered a ton of different tools and concepts related to agile development.

What is Agile Development?

Goal: Write relevant and working software

Relevant to customer requirements (longer, day by day feedback cycles, demonstrations, acceptance and functional tests, manual testing and use of software)

Working, functional code (very small, minute by minute feedback cycles with unit tests, typechecking, compiling, etc.)

One of the biggest difficulties in software engineering is making software that is relevant to the customer. A lot of the feedback for the “working” part can be automated and made very tight-cycle. On the other hand, to make the feedback from customers tighter, you need to demo and exercise the software constantly.

Rhythm is really important to Agile. Rhythm is not doing tasks in big clumps, but a little bit at a time at a steady pace. This is true at the low-level of incrementally developing and testing code, to the macro level of quick iterations and rapid deployment.

Tip: Posting numbers (Coverage, code analysis metrics) publicly allows clear communication, motivation.

The other problem is if you only concentrate on meeting customer demands, code tends to suffer and backslide with functionality regressions. This is where automated unit tests come in. They keep you from backsliding even as you alter code.

Automate as much as you can

Testing For Developers

It’s better to have a limited number of tools that are run constantly through continuous integration than a bunch of tools you run once a month. It’s easy to fix metrics, code violations, etc. if it only changes a little bit at a time. This means if you are adding automated tools to an existing project, first start by making sure that the metrics don’t get any worse. You can then make the metrics stricter slowly over the iterations.

For example, let’s say you have a project that only has 15% test coverage. Start off by setting Cobertura to fail if test coverage falls below that point. Then over a period of several iterations, increase the amount of coverage and the Cobertura water mark.

There are three broad categories of unit tests:

  • Positive tests - these test that your code does what is expected when correct input is provided
  • Negative test - these test that your code does not do unexpected things. E.g. not raising an error during normal operation.
  • Exception Tests - these test that your code handles exceptional conditions correctly, e.g. throws correct exceptions.

You can also automate other types of testing, like performance testing. JUnitPerf and TestNG can do this. These tools also also support concurrency testing.

Mock Objects

Mock objects allow you to test dependent objects. They also allow you to easily test error conditions, for example, when a network connection goes down. Venkat recommended MockRunner is a framework to mock out containers for e.g. TomCat server stuff.

Tests for product owner/customers

easyb is a behavior driven-development  (BDD) framework using Groovy for Java. It’s straightforward enough that customers can write at least the skeleton, and if you are careful with your interfaces, can write the tests, as well.

An example:

scenario “accounting” {

given “a new user”

when “the user creates a new account”

then “the user should receive a confirmation email”

}

Creates a new scenario. A report is automatically generated based on the string literals, and if this test is run all of the tests are marked “pending” since they only have documentation. Groovy objects can then be used in closures attached to each of the statements. shouldBe methods are automatically added to all objects and the ensure function can test other conditions. It’s really quite slick.

Code Analysis

Cohesion and Coupling

Rigidity can be measured by determining how many classes depend on a specific class. The more dependents a class has, the more rigid it is.

Stability can be determined by measuring how abstract the class is. The more abstract a class is, the less likely it is to change.

Ideally you don’t want your classes too rigid or too unstable.

JDepend can measure these two characteristics automatically and quantitatively. You can even set up a unit test to run JDepend and fail if the rigidity is too high. A distance of 0.2 or 0.3 is a good maximum for JDepend from the “Main Sequence”.

The important thing with all these automated metrics is to do them consistently. You’ll get discouraged if you only do it at the end of the iteration and will end up not using them at all.

Static Analysis

FindBugs and JLint, JLint can do dataflow analysis. PMD for copy detection.

Code Coverage

Go for 100% combined test coverage when using:

  • Unit Tests
  • Integration Tests
  • System Tests
  • Manual Testing

Tools like cobertura can measure coverage when deployed, as well. This means you can get coverage results for manual testing!

Jester mutation testing — make sure tests are actually testing functionality. This is the slickest thing since sliced bread and I’m going to get it to work with TestNG.