InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Test Driven Code Reuse

Posted by Amr Elssamadisy on Sep 18, 2007

Sections
Process & Practices,
Architecture & Design,
Development
Topics
Agile ,
Reuse ,
Java
Tags
JUnit ,
Eclipse
Code reuse has been the holy grail of software development for a long time. Historically we've tried to achieve code reuse through abstractions and frameworks, which came with their own technical debt. There is now a novel approach that leverages the power of search tools and automated developer tests to search open-source code for matches against interface and behavior.

Colin Atkinson and his research group, in the Software Engineering Department at the University of Mannheim, have created merobase, a tool that allows the user to search the internet for existing code that matches a given interface (structure).  That’s fine, but not really unique, there are other search engines that perform a similar service – such as Google Code Search.

What distinguishes Atkinson and his students, Oliver Hummel and  Monika Krug, is that they have have added an additional capability – the ability to search not only on structure, but also behavior.  This is accomplished by using tests written by the developer to be part of the search criteria.  All classes that match the required interface are then run against the tests provided.

Monika has written an Eclipse plug-in called FAST (Fully Automated Search and Test) that will automatically parse and query merobase based on tests that you’ve written.  So, you write your tests, right-click on the test class, and automatically retrieve all applicable classes from the internet that match your criteria.

Here is an example test written for a Die class:



This is FAST in action:



Here is an example of a Die class returned from FAST:



This is a research project currently, but it can easily be imagined how useful this approach can be for large organizations that have tens of millions of lines of code hanging around that can now be searched and reused without the cost of frameworks and abstractions that are difficult to understand, use, and maintain.
  • This article is part of a featured topic series on Agile
Cute by Steven Devijver Posted
Re: Cute by Luis Garcia Posted
  1. Back to top

    Cute

    by Steven Devijver

    Cute. I'm wondering though how it tests code on the effects of unspoken leaky abstractions.

  2. Back to top

    Re: Cute

    by Luis Garcia

    That's where AJAX voting stars come in.

Educational Content

New-age Transactional Systems - Not Your Grandpa's OLTP

John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.

Cool Code

Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.