I am trying to understand a Java code that I received (I am a C# programmer)
public interface BaseDA {
...
}
public class BaseDAImp extends HibernateDaoSupport implements BaseDA {
...
}
public interface TxnDA extends BaseDA {
public Txn getTxn(long id);
}
public class TxnDAImp extends BaseDAImp implements TxnDA {
public Txn getTxn(long id) {
....
}
}
And in another class it is used this way
protected void ShowTxn(long int) {
TxnDA txnda = (TxnDA) appContext.getBean("txnDA");
txnda.getTxn(id)
}
All classes extend a base class and implements an interface. This is almost done for every single class in the java code.
Question 1 - Can someone please explain this code to me? I already know we use interfaces (in C#) when we might want to couple software, plugin, hide implementation details.
2 - As none of above conditions are true for this java library, is it safe to modify the code like below?
public class BaseDA extends HibernateDaoSupport {
...
}
public class TxnDA extends BaseDA {
public Txn getTxn(long id) {
....
}
}