Contract4J5 Is Available through GitHub and Maven
March 11th, 2010
This is looong overdue, but you can now manage dependencies on Contract4J5 using Maven. The details are here. Also, I moved the code from a private subversion repository to GitHub.
Contract4J5 is my Design by Contract library for Java. I haven’t worked on it in a while, but I hope to return to it sometime this year to solve the one issue that keeps it from being practical for many teams: performance. Currently, the runtime overhead slows down tests considerably. It is already feature complete and stable.
The Maven bundle includes the all the sources and javadocs, as well as the runtime jar file. However, it is still built with Ant. If you want to work with the source code, clone or fork the GitHub repo.
Slides from My QCon Talk
November 20th, 2008
I posted an extended version of the slides from my QCon San Francisco talk, Radical Simplification Through Polyglot and Poly-Paradigm Programming (PDF). The PDF includes some slides I skipped in the actual talk, for time’s sake.
InfoQ.com may offer a video of this talk. Stay tuned.
Announcement: Polyglot Programming Site
August 24th, 2008
Raising a different exception in "after" or "after_raising" advice
April 26th, 2008
An Aquarium user asked recently if you can use after_raising advice to raise a different exception, e.g., to wrap the original exception. Now you can, with the commits I did today. (This change will appear in the forthcoming V0.4.2 release.) Actually, this feature was partially implemented already, but never finished (OOPS!)
The following made-up example illustrates what you can do. Imagine you are one of the handful of Ruby programmers who aren't using ActiveRecord ;) and you have an OracleDriver class that handles Oracle database transactions.
class OracleDriver
class OracleDriverException < StandardException; ...; end
class ConnectionError < OracleDriverException; ...; end
def connect
if try_to_connect == false
raise ConnectionError
end
...
end
def find query_parameters
...
end
end
In the application code that uses the OracleDriver you ignore any exceptions raised (because we will implement an exception handling strategy elsewhere...).
...
def load_object oracle_driver, query_parameters
oracle_driver.connect
oracle_driver.find query_parameters
end
...
Finally, you implement an application-wide exception handling strategy for any exceptions raised by the driver.
Aspect.new :after_raising => OracleDriverException,
:in_types => ... do |jp, object, *args|
# Ruby needs a standard way to wrap one exception in another.
original = jp.context.raised_exception
app_exception = ApplicationException.new(original.message)
app_exception.set_backtrace(original.backtrace)
jp.context.raised_exception = app_exception
end
In other words, any exceptions raised by calls to OracleDriver are wrapped in an ApplicationException, which will be thrown by Aquarium when the advice block finishes.
This technique can also be used when handling exceptions in after advice.
By the way, in a similar way, you can also change the return value in after and after_returning advice. In this case, you assign a new value to jp.context.returned_value.
ANN: Aquarium V0.4.0 Released with Initial Support for Java Aspects in Aquarium
February 26th, 2008
ANN: Aquarium V0.3.0 released
January 21st, 2008
I released V0.3.0 of Aquarium today. The most visible change is a new set of synonyms for many of the parameters passed to API methods, providing a more "English-like" feel. For example, previously, you might declare an aspect like this:
around :methods => :all, :types => [Foo, Bar], :advice => advice_proc
Now you can write the same aspect as follows:
around :calls_to => :all_methods, :within_types => [Foo, Bar], :use_advice => advice_proc
which reads more like English.
Similarly, attribute matching is simpler.
after :attribute => name, :attribute_options => [:readers], :objects => [foo, bar] ...
becomes
after :reading => name, :on_objects => [foo, bar] ...
There are many internal improvements to improve DRY'ness, robustness, and performance.
There should be no upgrade issues, so give it a try!
CJUG Downtown 12/18/07: Aspect-Oriented Programming and Software Design
December 8th, 2007
Presentation on AOP in Academia and Industry
October 20th, 2007
Presentation on Aquarium with Exercises
October 2nd, 2007
ANN: Aquarium v0.1.5 released
September 17th, 2007
Object, due to collisions with Rails. This means that users of the "DSL methods" will need to require a new file or include a new module.
See the "CHANGES" file in the distribution of "here":http://aquarium.rubyforge.org/changes.html for more information.



