T
tshad
I am trying to figure out when it is best to use Interfaces and when to use
classes.
The only reason I can figure out to use interface is if you need to
implement multiple interfaces.
The problem with interfaces over classes seem to be that you need to create
multiple implementations for the same interface using interfaces (which may
be the same for all your classes).
Why would you not just implement an class where you can extend the class and
just override the classes you want to be different?
I was looking at a program from a book that set up interfaces for its
database class but then just implements the Database class itself. Not sure
why the interface was necessary.
I see a lot of discussions on Interfaces, but not a lot of discussions on
why you would use one over the other (other than the multiple interface
issue). It's one thing to know how to do it, quite another to know when to
use it (just because you can, doesn't mean you should)
Am trying to find the pros and cons of each method.
Thanks,
Tom
classes.
The only reason I can figure out to use interface is if you need to
implement multiple interfaces.
The problem with interfaces over classes seem to be that you need to create
multiple implementations for the same interface using interfaces (which may
be the same for all your classes).
Why would you not just implement an class where you can extend the class and
just override the classes you want to be different?
I was looking at a program from a book that set up interfaces for its
database class but then just implements the Database class itself. Not sure
why the interface was necessary.
I see a lot of discussions on Interfaces, but not a lot of discussions on
why you would use one over the other (other than the multiple interface
issue). It's one thing to know how to do it, quite another to know when to
use it (just because you can, doesn't mean you should)
Am trying to find the pros and cons of each method.
Thanks,
Tom