Interfaces Used to Add External Capabilities to a Class

   

Java™ 2 Primer Plus
By Steven Haines, Steve Potts

Table of Contents
Chapter 8.  Interfaces


Another common use of interfaces is to add external capabilities to an existing class, as we did by making the car classes serviceable. This is more of a conceptual differentiator when deciding what functionality to add to a class and what functionality to put into an interface, but from a strict object-oriented perspective, you want to keep your classes pure.

You should design your classes so that they encapsulate the attributes and behaviors of the object they are representing. Functionality that resides external to the object can be implemented through interfaces. This is only a conceptual distinction, but if you follow it you will find your classes to be more reusable, and the methods you use to service interfaces infinitely more versatile.


       
    Top
     



    Java 2 Primer Plus
    Java 2 Primer Plus
    ISBN: 0672324156
    EAN: 2147483647
    Year: 2001
    Pages: 332

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net