[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Interfaces, abstract classes. Why?
to expand on Steve's example
Lets say you are working on a project called zoo
and you write code which when you are looking at a certain animal
you can hear its typical noise.
Lets say different people are writing each animal. You would create an
interface( or Abstract class) called Animal, which would define the method
tell each programmer that they had to implement Animal. That way you would
that in your code all you have to do is call the method Animal.makeNoise()
and you wouldn't have to figure out what the animal is first.
From: Steve Ardis [mailto:email@example.com]
Sent: Wednesday, April 02, 2003 2:37 PM
Subject: 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
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 <firstname.lastname@example.org>
> Hi all. I hope someone can help me understand
> 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
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
"The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential, proprietary, and/or
privileged material. Any review, retransmission, dissemination or other use
of, or taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from all