Course Notes
Computer Engineering

Code Artistry - Interfaces

Initial Thoughts:

Interfaces are mechanisms to provide access to something, e.g., an electrical outlet in a room provides an interface to the electrical distribution system in the building containing the room. In the context of software systems there are two distinct meanings of the word interface: For the remainder of this discussion we will use the second definition, e.g., a contract for communication.

So why use interfaces?

Interfaces do several important things to support well crafted code:
  1. When client code binds to an instance of a class, using an interface the class implements, that client doesn't bind to any of the class's implementation details, as long as the client didn't have to create an instance of the class it's using. We support this by providing an object factory that returns to the client a reference with the type of the interface, not the type of the class.

Summary: