[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interfaces, abstract classes. Why?

Interfaces allow you to keep logical layers of your
code from knowing about a specific implementation. 
For example, it allows me to write client code that
adheres to a contract defined by an interface.  As
long as my code only directly references the
interface, I can determine at runtime the
implementation class to use (do a Google search on
Factory Method).

An abstract class allows for things like OO's
polymorphism to occur.  By defining an "Animal" class,
I can define an abstract method "makeNoise()" - it is
up to the "Dog" and "Cat" subclasses of "Animal" to
determine what happens when "makeNoise()" is called.

Hope this helps

--- Jennifer Fisher <jenniferfisher@programmer.net>
> Hi all.  I hope someone can help me understand
> better.
> What are the uses for interfaces and abstract
> classes?  Why would one need them in a project and
> what for?
> Thank you in advance.
> Jennifer Fisher
> Developer, Gaye Systems
> IITP 2.0
> -- 
> Sign-up for your own FREE Personalized E-mail at
> Mail.com
> http://www.mail.com/?sr=signup

Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more