Mock objects at CITCON Paris 2009

The session on mock objects, mostly lead by Steve Freeman, was a bit messy but interesting. My colleague David got to show some of our code on the screen, which was scary and exciting (he felt the urge to fix some of the tests he had shown immediately after). Also, I think I finally understood the relation between mock objects and interfaces that Steve insists on.

See, I always thought that Steve was in favour in adding interfaces directly on top of concrete classes. For example, if you have a FileManager, you would also have a IFileManager.

Steve made more clear that the idea was to use interfaces to represent a role, or (more exactly) just one of the roles that a class has. That makes sense. But, to be honest, I still prefer to have a single role per class. So, no interfaces really needed.

I wish I had more time to talk with Steve. Maybe his coming book will have answers for me.

Mock objects

About Eric Lefevre-Ardant

Independent technical consultant.
This entry was posted in citcon, java. Bookmark the permalink.

5 Responses to Mock objects at CITCON Paris 2009

  1. For me an interface should be called Serializable, Comparable, FileFilter… when you start using the same name with a prefix (‘I’ for interface) or a suffix (‘Impl’ for the implementation), that is a code smell. I don’t like the idea of having interfaces when you only have one implementation. The more I code, the less I use interfaces… unless it’s needed (for implementation or testing reasons). I was at the talk with Steve but left the room without being conviced at all.

  2. Pingback: Faster tests, at CITCON Paris 2009 « Eric Lefevre-Ardant on Java & Agile

  3. @Antonio. Fair enough, although an hour (including time spent watching my laptop not work) isn’t a lot of time to make a point to a skeptic.

    There are also other reasons for using interfaces to do with naming, and dependency management I didn’t get to. I find that the effect of using interfaces to describe roles only really kicks in as the code scales up. And I’m sure that a good team can make things work with just classes–David’s examples looked pretty good to me. In the meantime, I really recommend the Wirfs-Brock book, if you haven’t read it yet. It has a long and respectable pedigree.

    At least we agree on not using the ‘I’ naming wart.

  4. Pingback: CITCON Paris 2009, a personal retrospective of the organization « Eric Lefevre-Ardant on Java & Agile

  5. Pingback: » CITCON Paris 2009: Mock objects

Comments are closed.