• Post Reply Bookmark Topic Watch Topic
  • New Topic

Abstract class or Interface?

 
Luna Bora
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have an interface DBOperations which has all the public methods of Data class. This interface is implemented by two classes for local and remote modes. The client has an instance variable of type DBOperations so that it does not need to know whether the database is local or remote. Now, my question is, is it better to leave DBOperations as an interface or to change it to abstract class? What difference it makes if it is interface and if it is an abstract class? Thanks in advance for the help.
 
David Meyers
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would recommend in interface in cases where you aren't implementing any of the methods in the abstract class. This is because you can always implement multiple interfaces, but are limited to one extend.
Good luck
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!