Archive : May 2009

Comparing Ruby Mock Object Libraries

Continuing on the theme of comparing similar things that I started last week, this week I'll be taking on Mock Object libraries.

The purpose of a mock object library is to allow you to create "fake" objects that can take the place of the regular objects in your application during testing (you'll sometimes see them called "test doubles", by analogy with a stunt double, another kind of stand-in).

There are a several reasons why you might want to use a test double in your tests, the two most common are probably these:

  • To take the place of a hard to create or expensive to access object or method call, such as a web services call. Using the test double lets the test system pretend that the expensive object is there, but at a much lower time cost.
  • To isolate an object being tested from the details of the rest of the system. In Rails, for example, a controller test might create test doubles for methods in the model so that the controller test can pass or fail separately from whether the model implementation is correct.

Ruby's open object model and duck-typing makes creating test double objects relatively easy compared to stricter languages like Java. There are four major mock objects packages in Ruby:

  1. FlexMock is the original Ruby mock object package
  2. Mocha is quasi-official in that the Rails team uses it for their tests.
  3. RSpec defines its own mock package
  4. RRis the newest entry, with shorter syntax and a couple of new features

Here's a tour of what each package looks like, and when you might use each feature.

Self-promotion alert: More details about mocks, stubs, test doubles, and anything relating to Rails testing can be found at Rails Test Prescriptions, there's a free getting started tutorial, and a nearly 300 pages and counting full book for $9. Thanks.

Continue reading »

Flare vs. Axiis

flare-vs-axissAfter a long time of searching for the right data visualization framework for Flash Platform, some time ago I've put my money on Flare which is based on a Java framework called Prefuse. I have been very happy with it and haven't looked back until a new framework of same purpose crossed my way - Axiis.

Before anything else said, Axiis is a brand new framework so I have to give it some credit if all the bells and whistles are not there. What intrigued me about it in the first place is that Axiis is heavily relying on Degrafa, a well proven declarative graphics framework that I have a lot of good experience with.

After looking at Axiis examples, here are my first impressions of how it stands against Flare.

Continue reading »

What makes Ruby/Rails Development Fun

I have been a full-time Ruby programmer for about a year now. I used ruby/rails before then but I didn't really "get it". Considering that I was a Java/J2EE guy before and never worked with dynamic languages, it wasn't surprising. Now that it has been a transformation and a worthy evolution, it is about time to review what makes ruby development fun. Yes, Ruby is known for its dynamism, expressiveness, malleability. But today I hope to list a few tools, techniques, concepts that make my programming experience fun these days. Here they are:

Continue reading »

Factory tools for fixture replacement: a comparison

Continuing on the general theme of blog posts that people actually asked me to do... this week, I'll be taking a comparative look at fixture replacement tools. The general request was to have one place that compared the features of the various libraries so that a prospective fixture replacer might make a more informed choice.

So here goes, I'll try to keep the editorializing to a minimum, but no promises.

Fixture replacement or factory tools replace the global nature of Rails fixture data with the ability to easily create new objects based on sample valid data previously defined by the developer. Factory tools have several advantages, including keeping each test independent of other tests, since you are no longer using global fixtures, and allowing the important data for each test to be defined in that test.

Updated to correct some errors caught in the first few comments.

Self-promotion alert: A full description of why to use fixture replacements and an in-depth look at one of these tools is available in the full version of Rails Test Prescriptions available wherever fine PDF books are sold as long as you think the only place fine PDF books are sold is http://www.railsrx.com.
Continue reading »

Topics:

Safari’s Tabs on Top and Usability

picture-2Apple recently released a beta version of its Safari 4.  Naturally it has some really cool new features, including a helpful and slick start screen, and cover flow for your browsing history.  It's also much faster than any other browser currently out there.  However there is one substantial "new feature" to the Safari 4 user interface that's been generating lots of buzz (heat might be a better word).  Namely, in this new version of Safari, the tabs (which you use to browse multiple web pages simultaneously in one window) are physically located at the very top of the browser window.  The address bar, and all the other web page navigation controls are now situated underneath your tabs. Continue reading »

Catching Ajax Errors with Prototype and Rails

Prototype

In an exclusively Ajax application it can be difficult for a user to determine when their connection to the server has dropped. For example, we at Pathfinder use an excellent internal tool to keep track of our time, and the primary screen in it provides a lot of Ajax-y fields. But if, say, I disconnect my laptop, plug in at home, and forget to connect to our VPN, I can waste quite a lot of time and energy putting in information without realizing it isn't being sent to the server at all.

To fix this problem is a little less obvious than it might seem at first glance.

Continue reading »

Database Migration Tools for .NET

For the past several months, I was working on a Windows desktop application that didn't require any connection to a database, and now that this project is coming to an end and my next assignment is Web application with database connection. I wanted to see what my options are for database migration tools. In the past I've used dbsetup.vbs script, created by Alek Davis, and although it worked it did require some modification to the underline script. So I'm currently looking at several alternatives that could serve as a suitable replacement.

RikMigrations
Migrator.NET
Subsonic Migrations
dbDeploy.NET

Here are some useful links I've found to help determine which toy, I mean, tool, I plan to use next.

http://www.infoq.com/news/2009/01/migrations_dotnet
http://flux88.com/blog/net-database-migration-tool-roundup/
http://alekdavis.blogspot.com/2008/07/database-installer-revised.html

Ten Keys to Successful Software Development: #10: Tools and Infrastructure

precision_tools

After last month's post on the five deadly sins of software development, I thought it would be good to write about how you can overcome those sins (present in every project) to successfully develop software. The list we use internally roughly parallels that of the Standish Chaos reports, and I've illustrated it with the patterns we use, as well as some antipatterns we've seen and experienced.

#10 on the list is Tools and Infrastructure:

Pattern: We use standard tools for our software development process. For example, every project uses a source code repository, we do continuous integration (hudson) and enforce test coverage as part of every build. Every project uses our wiki for in process definition and documentation. The tools have the benefit of being easy to use, of making communication between team members and clients easy and transparent. They have the benefit of enforcing/reinforcing what we consider important in our method (like test driven development, continuous integration, just in time specification and continuous feedback) and getting out of the way where too much structure is a hindrance.

Continue reading »

Rails Testing Frequently Asked Questions — The Non-Code Version

Between my sessions at RailsConf, and the book promotion at Ruby Learning I've been fielding a lot of questions about Test-Driven Development and Rails. Here are five of the most common general questions.

Self promotional note: many of these questions and more are covered in detail in Rails Test Prescriptions, only $9 dollars for a book that covers all kinds of testing topics...
Continue reading »

Topics:

Web app security checklist (Braindump)

In Yesterday's post I said I'd put together a quick list of things to think about around web application security. This is by no means an exhaustive list, but its a set of categories and things I start to look at when doing a security assessment on an app.

Web Application Security Checklist
Account management

  • Password management (validation, expiration, previous passwords, etc)
  • Account lockout (number of tries, IP auditing, etc)
  • Role management

Data management

  • Don't Leak sensitive user info (SSNs, account numbers, other identity info) in URLs, cookies, sessions, logs, or printable pages.
  • User Auditing (who changed what, and when)

Browser hacks

  • Cross Site Scripting (XSS)
  • Cross Site Request Forgery (XSRF)

Encrypted transport (make sure Ajax calls are secure)
Encrypted storage (credit cards, ssns, etc)
Server configuration (firewalls, web/app server, db)

I actually have a longer list, but its not formatted/organized very well,  so this is my first cut at sharing it with others.

What other areas do you look at when doing security checks for your web apps?

What tools do you use?

Just mow the grass

After Mowing
Creative Commons License photo credit: great_sea

Gauging a client’s wants and needs is as much an art as it is a science. Oh sure, establishing the requirements and needed features and potential limitations (hello legacy system) is pretty much a straightforward scenario. It’s when we get into the layout and behavior of the application that negotiating the waters can begin to get a little tricky. Bump it to the redesign of an existing application that users are accustomed to, and the trickiness factor is raised exponentially.

I’ve been lucky with Pathfinder in that my last couple of projects have been to design and develop new software. The clients come in with an idea for a better mousetrap and we build it. They’re excited, we’re excited and we get to build something shiny and new that gives the client a good experience and helps build their business. A win-win in my book.

Not all projects have such a glorious life. In a previous job, I was part of a team that was tasked with porting a legacy system over to a new framework. Naturally, there were the usual levels of complexity all projects of this type always seem to encounter. However, the most difficult obstacle to overcome was the inability of the decision maker to see anything beyond the existing user interface.

Continue reading »

Topics:

Avoid the last minute security review

lock_med
Photo Credit:
Amagill under Creative Commons Attribution

Security is hard

Security is often an after thought, slated towards the end of a project, or after some big issue has been discovered, but the nature of security functionality, rules, roles, auditing, etc make it hard to layer in to an existing codebase effectively.

Oh, and if the code base isn't sufficiently tested, you're in for a world of hurt.

If you are a developer that was just asked to 'do a quick security check and plug any holes', you are now in the difficult position of managing the expectation that a two-week security review means "we're covered". Be realistic about what you can accomplish, setting out some short-term and long-term goals.

Do More With Less. Start with a research 'Spike'

Instead of pushing for more time to be able to 'cover it all' (even though you have no idea what 'it all' is yet), it might be better to start with a shorter analysis phase, where you detail your findings, identify any trends, and include recommendations for process change. I've found that even the most demanding manager is appreciative and understanding when you ask for a small amount of time in order to produce a better estimate, than to just immediately demand more time without any evidence as to why.

Plan for success

With your analysis and recommendations in hand,
Continue reading »

Code Coverage – Why?

I recently got into a debate with a coworker about my requirement on an internal project that the code coverage cannot fall below 100%, or the build will break.  He put up some very good points, but I'd like to spell out my thinking.

The project is an internal project we use for staffing, time entry and billing, so it is a production system, that is used for billing our clients, so I treat it as a very high priority.  Unfortunately, it's an internal project, so I work on it when I can, and I get bench resources when they are free.  This causes many developers to come on and off the project with no predictable pattern.  I kept encountering this experience:

Continue reading »

Summer Software Development Internship

We're starting a software development summer internship in our Chicago office this year. If you're a college junior, senior or recent graduate who want to learn the agile/OO development ropes while developing really cool products and services and earning $20/hr per hour (you should pay for the privilege, right?), give the internship posting a look here.

Launch: Pathfinder Newsletter

    Get a monthly update on best practices for delivering successful software.

    Subscribe via email


    Subscribe via RSS      RSS icon

Topics

Search

WordPress

Comments about this site: info@pathf.com