Re: What is the practical use of "abstract" and "interface"?

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

 



Just adding one line to the topic...
Interfaces are like C or C++ headers files. Them are used to another
class(program in C) to call methods without care the implementation. In
other hand abstract classes are (as the name says) an abstract way to use
multiple specializations of the same group of classes. Like vehicle is an
abstraction to car, motorbike, bike... with that you can use the method ride
to all these vehicles using an vehicle variable pointing to an instance of
car, motorbike or bike.

Cheers.

Rodrigo Reis.

2008/4/15, Jay Blanchard <jblanchard@xxxxxxxxxx>:
>
> [snip]
> ...stuff...
> [/snip]
>
> The practical use of an abstract class is in its ability to define
> criteria for classes that inherit from it. How practical would it be to
> define a 'truck' class with 4 wheels and then define a 'car' class with
> 4 wheels when we could define an abstract class that defines vehicles
> with 4 wheels? Both of our classes can now inherit from that abstract
> class and we can define features only relevant to them. If you refactor
> diligently you will no doubt find places where you need to create
> abstract classes.
>
> The methods that are exposed by an object define the interface for that
> object. It is how everything outside of the object interacts with the
> object. You don't have to know how the method works all you need is the
> interface....like the gas pedal on the car.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Atenciosamente,
Rodrigo.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux