How coding to Interface and Inheritance helped me reuse code

Before going into the details I will state the requirement:

  • I need to fetch certain records from 3 different tables into 3 ArrayLists.
  • I have 3 Classes which store the information: Lets name it- Class1, Class2, Class3.
  • All the above 3 classes implement the Interface, lets name it Interface1. The interface has a method called init(). The main task of init() is to initiate the values of the instance variables with the values obtained from the ResultSet (database). This instance is then added to one of the 3 lists define above depending on the type of the reference.

Read more