<?xml version="1.0" encoding="UTF-8"?>
<response>
  <status>success</status>
  <result>
    <project>
      <id>81045</id>
      <name>excepgen</name>
      <created_at>2008-12-20T08:19:55Z</created_at>
      <updated_at>2009-11-12T18:07:53Z</updated_at>
      <description>ExcepGen generates Java source code for exception types specified in an XML configuration file. 

The primary goal of this project is to create a domain specific language (DSL) for specifying Java exception types. The ExcepGen DSL compiler translates DSL programs (written with XML syntax) into Java code. 

Exception type implementations tend to be pretty rote. Here's a typical template: 

/*
 * Some copyright and licensing notice.
 */

package some.pkg;

/**
 * Some exception type description.
 */
public class SomeException extends SomeExceptionBaseType {
    static final long serialVersionUID = 123L;

    /**
     * Copy and pasted method description.
     *
     * @param msg Copy and pasted parameter description.
     */
    public SomeException(String msg) {
        super(msg);
    }

    /**
     * Copy and pasted method description.
     *
     * @param cause Copy and pasted parameter description.
     */
    public SomeException(Throwable cause) {
        super(cause);
    }

    /**
     * Copy and pasted method description.
     *
     * @param msg Copy and pasted parameter description.
     * @param cause Copy and pasted parameter description.
     */
    public SomeException(String msg, Throwable cause) {
        super(msg, cause);
    }
}It's certainly not difficult to write this code, but it's a lot of copy and pasting. A large system with many exception types can have a lot of duplicated code like this. 

&quot;Copy and paste programming&quot; is an anti-pattern. In addition to simply creating more code to maintain, duplicated code leads to duplicated bugs. To see this, suppose that there are three copies of some section of code in your system, then suppose that you update two copies. The third copy will have a bug if you don't synchronize it with the change. 

Put simply, eliminating duplicated code tends to reduce software development and maintenance costs by eliminating the need to synchronize changes. Further cost reduction can be realized by adding automated tool support for finding and eliminating duplicated code. 

In general, there are two &quot;high-level&quot; approaches to eliminating duplicated code: reactive and proactive. A reactive approach identifies and eliminates existing duplicated code. Tools like PMD's Copy and Paste Detector CPD are designed to identify duplicated Java code. Automated refactoring tools found in modern software development environments extract duplicated constructs and replace them with a single centrally located implementation. 

A proactive approach avoids creating duplicated code in the first place. The seasoned developer recognizes and immediately refactors code rather than duplicating it. 

In addition to a well-trained eye, an expressive tool can help to avoid duplication proactively. Tools like ExcepGen are designed to provide developers with a domain specific language that alleviates the need to write and maintain a particular type of duplicated code. Rather than duplicating the exception template shown above, ExcepGen allows developers to specify exception types succintly. Additionally, ExcepGen enables the &quot;exception type aspect&quot; to be factored into a single location. 

Here's an example that replaces the template from above: 

&lt;?xml version=&quot;1.0&quot;?&gt;

    
An additional exception can be added with a very small change: 

&lt;?xml version=&quot;1.0&quot;?&gt;

    
    
A domain specific language program like this is then translated into Java source code by the ExcepGen DSL compiler to produce Java code similar to the template shown above. 

ExcepGen's simple domain specific language allows clear, succinct exception type expression and reduces the amount Java code that your project must maintain. 

Copyright &#169; 2008-2009, Iparelan Solutions, LLC. All rights reserved.</description>
      <homepage_url>http://code.google.com/p/excepgen</homepage_url>
      <download_url></download_url>
      <url_name>excepgen</url_name>
      <user_count>0</user_count>
      <average_rating></average_rating>
      <rating_count>0</rating_count>
      <analysis_id>528865</analysis_id>
      <analysis>
        <id>528865</id>
        <project_id>81045</project_id>
        <updated_at>2009-12-25T05:03:48Z</updated_at>
        <logged_at>2009-12-25T05:03:45Z</logged_at>
        <min_month>2009-02-01T00:00:00Z</min_month>
        <max_month>2009-02-01T00:00:00Z</max_month>
        <twelve_month_contributor_count>1</twelve_month_contributor_count>
        <total_code_lines>2354</total_code_lines>
        <main_language_id>5</main_language_id>
        <main_language_name>Java</main_language_name>
      </analysis>
      <licenses>
        <license>
          <name>lgpl</name>
          <nice_name>GNU Lesser General Public License 2.1</nice_name>
        </license>
      </licenses>
    </project>
  </result>
</response>
