Removing copy/pasted code without an interface
<p>I have two data access objects that are reverse generated and jar'ed up for use by my application. They represent tables that are very similar. One table has a few additional columns than the other. This is out of my control due to business oriented database ownership concerns.</p>

<p>The application currently has two implementations of a repository that operates on these DAOs. The implementations are very similar. One has a few extra operations that correspond to the extra columns on the second DAO. However with only a few exceptions, one implementation is a copy and paste of the other. The implementations are hundreds of lines long.</p>

<p>So I wanted to remove the copy/paste job. Ideally I could just stick an interface in front of the DAOs, and then maybe use an abstract class to hold the shared code (nearly all of it). However, I cannot put an interface in front of the DAOs. Remember they are reverse generated, and without upgrading our ORM software I don't think this is a reasonable choice (Kodo 3.x I believe, changing this is not in scope). </p>

<p>The only thing I can think of that would even work is some nastiness with reflection but that results in something much worse than I have now. </p>

<p>Any clever solutions?</p>

<p>edit: Here is very watered down code example</p>

<pre><code>package one.dao
//reverse generated
class UserDao {
    getFirstName(..);
    setFirstName(..);
    getLastName(..);
    .... 50 more just like this
}

package two.dao
//reverse generated
class UserDao {
    getFirstName(..);
    setFirstName(..);
    getLastName(..);
    .... the same 50 more as above

    getSomethingElse(..); //doesn't exist in one.dao.UserDao
    setSomethingElse(..); //doesn't exist in one.dao.UserDao
}

class RepositoryOne(one.dao.UserDao userDao) {
    //insert code here. perform operations on nearly all methods, lots of code
}

class RepositoryTwo(two.dao.UserDao userDao) {  
    //insert code here. same as Repository one

    //some extra code that isn't above, maybe 10 lines
}
</code></pre>
